Граф коммитов

73 Коммитов

Автор SHA1 Сообщение Дата
Sebastien Pouliot 8ffb553e9e [linker] Capture and show more information when a MT2001 error occurs (#1947) 2017-03-30 14:41:56 -05:00
Sebastien Pouliot 153056cf7f [mtouch] Provide a more accurate description of the MT0091 error (#1938)
The old one makes it sounds the linker is doing magic ;-)
2017-03-30 07:36:20 -05:00
Vincent Dondain 2302931ceb [doc] Add XIA0004 Missing64BitSupportRule to xamarin-ios-analysis (#1912)
- Also update reference to maccore with the xamarin-analysis bump that includes XIA0004.
2017-03-25 13:02:54 -04:00
Alex Soto 7bc52a12bd [test][introspection] Remove check for void return type on AsyncCandidates test (#1909)
We do support the use of [Async] on methods that do not return void,
we generate an overload with am out parameter to retrieve the returned value

```csharp
[CompilerGenerated]
public unsafe virtual Task BarStringAsync (int arg1)
{
	var tcs = new TaskCompletionSource<bool> ();
	var result = BarString(arg1, (obj_) => {
		if (obj_ != null)
			tcs.SetException (new NSErrorException(obj_));
		else
			tcs.SetResult (true);
	});
	return tcs.Task;
}

[CompilerGenerated]
public unsafe virtual Task BarStringAsync (int arg1, out string result)
{
	var tcs = new TaskCompletionSource<bool> ();
	result = BarString(arg1, (obj_) => {
		if (obj_ != null)
			tcs.SetException (new NSErrorException(obj_));
		else
			tcs.SetResult (true);
	});
	return tcs.Task;
}
```

Modified the introspection test to repor this, updated documentation
and update API definitions reported by introspection.
2017-03-24 11:02:07 -06:00
Rolf Bjarne Kvinge 563f395cac Merge remote-tracking branch 'origin/master' into framework-sdk 2017-03-23 15:33:38 +01:00
Rolf Bjarne Kvinge 8a29f0deae Merge remote-tracking branch 'origin/master' into generator-ikvm 2017-03-22 14:11:00 +01:00
Alex Soto ebcb4ac034 [generator] Fix bug 52573 - Add nowarn and warnaserror to btouch/bmac (#1882)
https://bugzilla.xamarin.com/show_bug.cgi?id=52573

* Added nowarn and warnaserror to btouch/bmac
* Throw a BI0026 if bad args and added error to doc
* Added generator tests
2017-03-22 07:52:24 -05:00
Rolf Bjarne Kvinge 001790ff4e Merge remote-tracking branch 'origin/master' into generator-ikvm 2017-03-16 19:09:33 +01:00
Rolf Bjarne Kvinge 7c8007e4f2 [docs] Add a document for generator error messages. (#1877)
This is the first step for documenting the error messages in the generator:
create a document for the error messages.

The entries in the document are the same as the ones listed in the error.cs
file (which I've now removed to prevent duplication), with some very minor
editing.

The document is not yet published to the documentation repository (since this
is just the first step).
2017-03-16 07:38:56 +01:00
Alex Soto 78052430ab [generator] Fixes bug 52570 - [generator] warn when [Static] is used in a [Category] (#1862)
https://bugzilla.xamarin.com/show_bug.cgi?id=52570

In some cases you will find **static** members inside categories like in the following example:

```objc
@interface FooObject (MyFooObjectExtension)
+ (BOOL)boolMethod:(NSRange *)range;
@end
```

This will lead to an **incorrect** Category C# interface definition:

```csharp
[Category]
[BaseType (typeof (FooObject))]
interface FooObject_Extensions {

	// Incorrect Interface definition
	[Static]
	[Export ("boolMethod:")]
	bool BoolMethod (NSRange range);
}
```

This is incorrect because in order to use the `BoolMethod` extension you need an instance of `FooObject` but you are binding an ObjC **static** extension, this is a side effect due to the fact of how C# extension methods are implemented.

The only way to use the above definitions is by the following ugly code:

```csharp
(null as FooObject).BoolMethod (range);
```

The recommendation to avoid this is to inline the `BoolMethod` definition inside the `FooObject` interface definition itself, this will allow you to call this extension like it is intended `FooObject.BoolMethod (range)`.

```csharp
[BaseType (typeof (NSObject))]
interface FooObject {

	[Static]
	[Export ("boolMethod:")]
	bool BoolMethod (NSRange range);
}
```

We will issue a warning (BI1117) whenever we find a `[Static]` member inside a `[Category]` definition. If you really want to have `[Static]` members inside your `[Category]` definitions you can silence the warning by using `[Category (allowStaticMembers: true)]` or by decorating either your member or `[Category]` interface definition with `[Internal]`.
2017-03-14 13:03:13 -06:00
Rolf Bjarne Kvinge 1e498bce22 Merge remote-tracking branch 'origin/master' into framework-sdk 2017-03-07 07:38:30 +01:00
Rolf Bjarne Kvinge 73b3ac0ddc [doc] Document MT0127. (#1782) 2017-02-28 15:53:04 +01:00
Rolf Bjarne Kvinge 83d1111e10 [mtouch] Use fewer error numbers for code sharing failures. 2017-02-28 13:26:42 +01:00
Rolf Bjarne Kvinge d212b97b1a Merge remote-tracking branch 'origin/master' into framework-sdk 2017-02-21 18:14:29 +01:00
Rolf Bjarne Kvinge cf14456cd5 [mtouch] Add docs and improve MT4146 to be an error if we can detect the generated code won't compile. Fixes #52530. (#1712)
https://bugzilla.xamarin.com/show_bug.cgi?id=52530
2017-02-17 16:00:53 +01:00
Rolf Bjarne Kvinge 07127a76ca [mtouch] Make code sharing failures real warnings. 2017-02-17 10:16:51 +01:00
Rolf Bjarne Kvinge c1f87393ae Merge remote-tracking branch 'origin/master' into framework-sdk 2017-02-17 10:16:41 +01:00
Alex Soto a021c0cd3c [generator] Have WrapAttribute generate virtual members (#1707)
* [generator] Have WrapAttribute generate virtual members

WrapAttribute now has a boolean optional parameter named isVirtual,
this instructs the generator to add the virtual keyword to generated
members.

This is useful when fixing breaking changes so we can keep the wrong
signature generated instead of having manual code files.

* [docs] Add docs about virtual to WrapAttribute
2017-02-16 17:24:40 -06:00
Rolf Bjarne Kvinge 85f28fbd59 [mtouch] Warn if mtouch loads an assembly from a different location than requested.
Warn if mtouch loads an assembly from a different location than requested
(which might be because there are multiple assemblies with the same name).

Also rework the MT0023 check a bit by explicitly loading the root assembly
first, and then detecting if any loaded assemblies matches the root assembly.
This results in code that's a bit more obvious, and it also works correctly
with extensions (previously the entire MT0023 check was skipped for
extensions).
2017-02-10 16:39:15 +01:00
Rolf Bjarne Kvinge 1f7ce2e445 [mtouch] Fix the error message for 'CompileTask'.
The AOT-compilation occurs in the AOT-task now, and then we compile the result
using CompileTask.

This means that the error message in CompileTask was slightly incorrect, so
rectify it.
2017-02-10 14:46:25 +01:00
Rolf Bjarne Kvinge 024d5a92ca [mtouch] Add target-specific error messages.
This removes a little bit of duplicated code, and gives us slightly better error messages.
2017-02-10 14:46:25 +01:00
Rolf Bjarne Kvinge 5787bc0ef2 [mtouch] Validate the assembly build targets. 2017-02-10 14:29:11 +01:00
Rolf Bjarne Kvinge a590612751 [mtouch] Add an --assembly-build-target option. 2017-02-10 14:29:11 +01:00
Rolf Bjarne Kvinge a07085aafa [mtouch] Create a custom AssemblyCollection class.
Create a custom AssemblyCollection class that contains a dictionary with
assembly identity (name) -> Assembly mapping.

This also means that we can detect if we end up loading multiple assemblies
with the same identity, and show an error in that case (even if that case
should never happen since we cache assemblies based on the identity, it's nice
to have code that ensures it).
2017-02-10 14:15:35 +01:00
Rolf Bjarne Kvinge ce2d9fac32 [docs] Improve MT0099 error help text a little bit. 2017-02-10 14:03:25 +01:00
Alex Soto 3b0f1baf69 [mmp/btouch] Better error when bad xml linker input is given to mmp/mtouch (#1614)
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=52238

If you give mtouch/mmp a linker xml file with bad input for
example a Xamarin.iOS app and the linker.xml has a reference
to Xamarin.Mac instead of X.I.dll i.e.

<?xml version="1.0" encoding="UTF-8" ?>
<linker>
	<assembly fullname="Xamarin.Mac">
    	<type fullname="ObjCRuntime.Constants"/>
	</assembly>
</linker>

You will get a not so helpful generic error

MT2001 Could not link assemblies. Reason: Failed to process XML description: <unspecified>

It seems that when you use a xml file for linker you get a
`XmlResolutionException` from cecil when it fails to resolve
and the better error comes from the inner exception so we use
that instead.

New error output for XmlResolutionException:

MT2017: Could not process XML description: Failed to resolve assembly: 'Xamarin.Mac, Culture=neutral, PublicKeyToken=null'
2017-02-03 14:04:06 -06:00
Rolf Bjarne Kvinge d9c23c2ba8 [mtouch] Automatically enable bitcode if LLVM is enabled. Fixes #52241. (#1620)
Currently we can't build watchOS projects if LLVM is enabled, but bitcode is
not (see bug #51634).

Additionally the IDEs do not have UI to select if bitcode is enabled or not,
so automatically enable it if LLVM is enabled (since most likely people will
be building for the App Store if LLVM is enabled).

https://bugzilla.xamarin.com/show_bug.cgi?id=51634
https://bugzilla.xamarin.com/show_bug.cgi?id=52241
2017-02-03 07:16:17 +01:00
Rolf Bjarne Kvinge e9eb52a78a [docs] Improve MT0091's documentation a little bit. (#1609) 2017-02-01 14:58:54 +01:00
Rolf Bjarne Kvinge 35b17da170 [doc] Add blurb about MT1009. (#1608) 2017-02-01 14:30:45 +01:00
Rolf Bjarne Kvinge bac0253848 [mtouch] Automatically disable incremental builds if building to bitcode and any third-party bindings were found. Works around bug #51710. (#1592)
Most projects building to bitcode (any kind of bitcode, this includes the
marker-only version as well), will fail to link when linking with third-party
libraries and incremental builds are enabled.

So automatically disable incremental builds when we detect this scenario.

This is only a workaround until we can make this scenario build correctly.

https://bugzilla.xamarin.com/show_bug.cgi?id=51710
2017-01-31 14:55:54 +01:00
Rolf Bjarne Kvinge f24c8f7331 [docs] Update text about MT4134 to not mention the legacy registrar anymore. (#1558)
Since the legacy registrar is not available anymore.
2017-01-26 15:31:26 +01:00
Rolf Bjarne Kvinge dae598f96a [docs] Update text about MT5211. Fixes #51772. (#1559)
https://bugzilla.xamarin.com/show_bug.cgi?id=51772
2017-01-26 15:23:47 +01:00
Alex Soto 1799c2f489 [generator] Add BindAs support (#1476)
* [generator] Add BindAs support for NSValue and NSNumber
https://trello.com/c/RYCPEnkh

The intent of BindAs attribute is to have a binding definition as

	[return: BindAs (typeof (bool?))]
	[Export ("boolMethod:")]
	NSNumber BoolMethod (int arg1);

and our generator outputs

	[Export ("boolMethod:")]
	public virtual global::System.Nullable<bool> BoolMethod (int arg1) { ...  }

So we internally do the NSNumber <-> bool conversion, this also
applies to properties, parameters and methods.

* [generator] Fix a small formating issue

* [tests] Add BindAsAttribute generator tests

* [generator] Implement @spouliot's feedback

* [tests] Add BI1048 and BI1049 error tests for [BindAs]

* [generator] Implement Rolf's suggestion to avoid almost all string comparisons in [BindAs] for types

* [generator] Add BindAs support for smart enums and arrays with tests

* [generator] Some code clean up and implementation of PR feedback

* [generator] Add Protocol|Model checks and tests also a NRE check in NSArray creator

BindAs attribute cannot be used in Protocol|Model interfaces

* [generator] Add NSNumber <-> Enum support

* [docs] add BindAs documentation

* [docs] Implement documentation feedback for BindAs
2017-01-25 07:14:55 +01:00
Rolf Bjarne Kvinge 3a480b53bf Merge pull request #1506 from rolfbjarne/mtouch-single-invocation
[mtouch] Build extensions and the container app in the same mtouch process.
2017-01-16 18:33:42 +01:00
Sebastien Pouliot a563a66c34 [linker] Update BaseSubStep subclasses to use ExceptionalSubStep (#1507)
This allows mtouch to give better error message when something unexpected
occurs in the linker pipeline (at least for the sub-steps).

Practically it means fewer, contextless MT2001 errors. The replacements
error code are more precise, e.g.
* what was being done;
* what was being processed

and helps both diagnosing and, possibly, gives clues for workarounds
2017-01-16 11:42:41 -05:00
Rolf Bjarne Kvinge 53fc697aad [mtouch] Refactor command-line parsing to be reusable.
Also add a few tests to verify how we treat the root assembly (or lack
thereof).
2017-01-16 13:52:37 +01:00
Vincent Dondain ded6d2f129 [mtouch] Update MT0091 message (#1453)
Fixes bug #40835: Improve enable managed linker error message
(https://bugzilla.xamarin.com/show_bug.cgi?id=40835)
2017-01-09 16:34:58 +01:00
Vincent Dondain 10d7858c4f [docs] Fix binding_types_reference_guide typo 2017-01-04 15:58:49 +01:00
Rolf Bjarne Kvinge ab21da1b85 [xharness] Add support for uninstalling apps from device. (#1413)
The new error message / number is used in mlaunch.
2017-01-02 08:58:46 +01:00
Rolf Bjarne Kvinge ab2548a115 [mtouch] Automatically create the output directory if it doesn't exist. (#1414) 2016-12-24 10:57:08 -05:00
Vincent Dondain 064a747de3 [Doc] Introduce xamarin-analysis-doc-tool (#1374)
* [Doc] Introduce xamarin-analysis-doc-tool

This tool is responsible of producing the xamarin-analysis.md file which is
our Xamarin.Analysis rules documentation.

It will always override the content of the previous xamarin-analysis.md file.

We generate the documentation based on the existing rules in xamarin-analysis/shared/Xamarin.Analysis/Xamarin.iOS.Analysis.targets
2016-12-22 15:06:35 -05:00
Vincent Dondain 6f7c5f77d0 [binding_types_reference_guide] Fix minor typo 2016-12-19 15:25:02 -05:00
Vincent Dondain 887a410fe2 [msbuild] Add error codes for PropertyListEditorTaskBase (#1325)
* [msbuild] Add error codes for PropertyListEditorTaskBase

* [msbuild] Add task names in all errors' descriptions
2016-12-12 10:30:42 +01:00
Rolf Bjarne Kvinge 7842a0b506 [mtouch] Remove deprecated Classic commmand-line arguments. (#1319)
* [mtouch] Remove deprecated Classic commmand-line arguments.

* [mtouch docs] Document MT0022's death.
2016-12-08 18:59:04 +01:00
Vincent Dondain 901b94d6e1 Merge pull request #1237 from VincentDondain/msbuild-mt-errors
[msbuild] Add msbuild error code logic
2016-12-08 12:50:58 -05:00
Vincent Dondain 3d0e140f3c [xi-errors] Add headers for error code ranges 2016-12-07 16:33:34 -05:00
Alex Soto feac0d2315 [Foundation] Adds single object notifications to Notifications class (#1075)
Trello: https://trello.com/c/mKsUDti8

This adds a new overload to our Notifications class

Current:

public static NSObject ObserveDidStart (EventHandler<NSNotificationEventArgs> handler)

New overload:

public static NSObject ObserveDidStart (NSObject objectToObserve, EventHandler<NSNotificationEventArgs> handler)

This allows our users to have single object subscription to our
easy to find notifications.

Also this commit adds an Advice attribute encouraging to use the
Notifications class instead of the NSString based notifications
2016-11-28 10:19:21 -06:00
Vincent Dondain 8ea1509dec [msbuild] Add msbuild error code logic
- `LoggingExtensions` has a new `MTError` extension method that helps generate
  an msbuild error with the proper MTxxx format.
- Added error codes for 44 msbuild errors.
- Updated `docs/website/mtouch-errors.md` and `tools/mtouch/error.cs` accordingly.
- MT7001 contains some extra documentation (troubleshooting steps).
2016-11-24 15:24:30 +01:00
Sebastien Pouliot c92934eb6d [mtouch][mmp] Only allow `appletls` for the TLS provider (#1132)
The old `legacy` option will now be reported as a warning. 

That's by design an warning would require manually editing the .csproj
file (when the UI gets removed, as planned, from the IDE). 

This is part of
https://trello.com/c/SrgU38DN/647-only-ship-support-appletls

Note: The BCL changes will happen in later stages.
2016-11-08 14:42:40 -05:00
Rolf Bjarne Kvinge d42a9f4909 [mtouch] Make MT2015 (invalid HttpMessageHandler) a warning for known http message handlers on watchOS. Fixes #46552. (#1134)
Earlier versions of Xamarin Studio stored an invalid http message handler in
watchOS project files, which would cause a build error. In addition Xamarin
Studio removed the UI to set the http message handler (since only one value is
valid), which meant that the user had to edit the project file by hand to get
around this build error.

So make it a warning instead (and document what the user has to do to fix the
warning).

https://bugzilla.xamarin.com/show_bug.cgi?id=46552
2016-11-08 11:13:53 -05:00