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

75 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge 417236e279
[docs] Bring back documentation updates from the documentation repository. (#20453)
It's been a few years since we've synchronized the documentation here with the
documentation in the documentation repository
(https://github.com/MicrosoftDocs/xamarin-docs-pr/), so bring all updates done
there over here.

This PR is probably best reviewed commit-by-commit.
2024-04-22 18:32:21 +02:00
Rolf Bjarne Kvinge 2f4dae9e00
[mmp] Don't ignore failures to execute pkg-config and simplify/improve logic. (#7969)
* [mmp] Don't ignore failures to execute pkg-config and simplify/improve logic.

* Show proper errors if pkg-config fails to execute.
* Extract logic to verify system mono version into its own function.
* Extract logic to execute pkg-config into its own function.

* Simplify code slightly.

* [mmp] Remove the MM5301 error message.

It's never used in mmp, and the same error code is already used in mtouch.
2020-02-26 00:38:20 +01:00
Sebastien Pouliot d83e13edf1
[mtouch][mmp] Add a `--warn-on-type-ref=X` option (#7949)
Using this option it's possible to test for the presence of a type
reference in both pre-linked and post-linked assemblies.

This makes it possible to detect if
* a 3rd party assemblies are using some specific type you would like to avoid;
* a type reference has been removed during the build (e.g. linker)

Notes:
* Custom attributes are encoded differently and not included in the assembly type references metadata.
* Assembly that define a type `X` do not have a reference (but the definition) of the type (and won't be reported).

If either the pre or post-linked warnings are not useful then it's possible
 to add `-nowarn:150x` to exclude the results.

E.g.
* `-nowarn:1502` would not report references in pre-linked assemblies;
* `-nowarn:1503` would not report references in post-linked assemblies;

Finally `-warnaserror:150x` can be used to stop a build that would not
satisfy either the pre or post-linked condition.

* `-warnaserror:1502` would not report references in pre-linked assemblies;
* `-warnaserror:1503` would not report references in post-linked assemblies;

_side note_ same as https://github.com/xamarin/xamarin-macios/pull/7925
except that this one uses the localized mtouch/mmp errors only in master (so far)
2020-02-20 22:25:23 -05:00
michizhou 00f7069b23 [mmp] [mtouch] Expand error message for MM4162 and MT4162. Fixes #4286 (#7313) 2019-11-04 11:09:28 -05:00
Vincent Dondain 61d0e1809f Merge remote-tracking branch 'origin/master' into master-merge-d16-4 2019-10-14 18:17:35 -04:00
Rolf Bjarne Kvinge a8fdf6db6e
Implement a different escaping/quoting algorithm for arguments to System.Diagnostics.Process. (#7177)
* Implement a different escaping/quoting algorithm for arguments to System.Diagnostics.Process.

mono changed how quotes should be escaped when passed to
System.Diagnostic.Process, so we need to change accordingly.

The main difference is that single quotes don't have to be escaped anymore.

This solves problems like this:

    System.ComponentModel.Win32Exception : ApplicationName='nuget', CommandLine='restore '/Users/vsts/agent/2.158.0/work/1/s/tests/sampletester/bin/Debug/repositories/ios-samples/WorkingWithTables/Part 3 - Customizing a Table\'s appearance/3 - CellCustomTable/CellCustomTable.sln' -Verbosity detailed -SolutionDir '/Users/vsts/agent/2.158.0/work/1/s/tests/sampletester/bin/Debug/repositories/ios-samples/WorkingWithTables/Part 3 - Customizing a Table\'s appearance/3 - CellCustomTable'', CurrentDirectory='/Users/vsts/agent/2.158.0/work/1/s/tests/sampletester/bin/Debug/repositories', Native error= Cannot find the specified file
      at System.Diagnostics.Process.StartWithCreateProcess (System.Diagnostics.ProcessStartInfo startInfo) [0x0029f] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-08/external/bockbuild/builds/mono-x64/mcs/class/System/System.Diagnostics/Process.cs:778

ref: https://github.com/mono/mono/pull/15047

* Rework process arguments to pass arrays/lists around instead of quoted strings.

And then only convert to a string at the very end when we create the Process
instance.

In the future there will be a ProcessStartInfo.ArgumentList property we can
use to give the original array/list of arguments directly to the BCL so that
we can avoid quoting at all. These changes gets us almost all the way there
already (except that the ArgumentList property isn't available quite yet).

We also have to bump to target framework version v4.7.2 from v4.5 in several
places because of 'Array.Empty<T> ()' which is now used in more places.

* Parse linker flags from LinkWith attributes.

* [sampletester] Bump to v4.7.2 for Array.Empty<T> ().

* Fix typo.

* Rename GetVerbosity -> AddVerbosity.

* Remove unnecessary string interpolation.

* Remove unused variable.

* [mtouch] Simplify code a bit.

* Use implicitly typed arrays.
2019-10-14 16:18:46 +02:00
Vincent Dondain a3076f29a3 Merge branch 'xcode11.1' into d16-4 2019-10-07 21:46:13 -04:00
Rolf Bjarne Kvinge 1e92a732ef
[mtouch] Tweak watchOS architecture test to build for bitcode when building with llvm. Fixes xamarin/maccore#1994. (#7097)
Tweak the watchOS architecture test to build for bitcode when building with
llvm, since that's what's usually done.

Also tweak the MT0145 error message a bit.

Fixes https://github.com/xamarin/maccore/issues/1994.
2019-09-25 17:06:27 +02:00
Rolf Bjarne Kvinge 382083c992
[mmp] Don't ignore failures to execute pkg-config. (#7066)
Also bump system mono to a version whose pkg-config executable actually works
on Catalina.
2019-09-23 16:59:14 +02:00
Rolf Bjarne Kvinge f62791c1eb Renumber an error so that it doesn't clash with another error. 2019-09-16 15:18:34 +02:00
Rolf Bjarne Kvinge 303aa0a649 Merge remote-tracking branch 'origin/xcode11' into master-xcode11 2019-09-13 18:35:18 +02:00
Rolf Bjarne Kvinge f7363ecfbf Renumber an error so that it doesn't clash with another error. 2019-09-12 08:35:21 +02:00
Rolf Bjarne Kvinge f6e0531197 Merge xcode11 into d16-3. 2019-09-12 08:29:02 +02:00
Rolf Bjarne Kvinge 15f0af7a1a
[registrar] Report a warning when the registrar export an abstract INativeObject type to Objective-C. (#6659)
* [registrar] Report a warning when the registrar export an abstract INativeObject type to Objective-C.

Exporting abstract types to Objective-C can lead to problems when at runtime
we're asked to create an instance of such a type (which we can't), so warn
when this happens.

This would have caught #6655, and the problems explained in #4969 as well.

Since this may trigger for code that's currently working fine, I'm making it a
warning instead of an error (which means adding some extra code to be able to
easily report warnings from the generator code).

* Don't assume a TypeReference can be successfully resolved every time.
2019-09-10 04:35:59 -07:00
Rolf Bjarne Kvinge b8e9c83ce0
[mtouch] Detect when we run into the 32-bit arm size limitation, and report a better error. Fixes #6526. (#6855)
Also limit the output from the native compiler, so that we don't overload the
IDEs with output if the native compiler produces tens of thousands of errors.

Fixes https://github.com/xamarin/xamarin-macios/issues/6526.
2019-08-28 04:54:26 -07:00
Rolf Bjarne Kvinge d4192a59f0
[xcode11] Remove the WatchKit framework from iOS while keeping API stability. Fixes #6492. (#6503)
* [WatchKit] Remove this framework for iOS while keeping backwards compatibility. Fixes #6492.

* Copy all generated sources and modify them to throw PlatformNotSupported exceptions.
* Adjust some existing source code to also throw PlatformNotSupported exceptions.
* Sprinkle Obsolete attributes generously.
* Stop generating code for the WatchKit framework for iOS.

Fixes https://github.com/xamarin/xamarin-macios/issues/6492.

* [introspection] Adjust test.

* [mtouch] Don't link with WatchKit, and show a warning if we detect code that want to use WatchKit.

* [xtro] Remove WatchKit for iOS.

* [introspection] Don't check obsoleted NSString fields for null.

There's probably a reason the field was obsoleted.

* [introspection] Add exception for the WatchKit framework.

* [xtro] Ignore obsolete enums.

There's probably a reason they're obsoleted.

In particular it solves a confusion between WKWebKit.WKErrorCode and
WatchKit.WKErrorCode: for iOS, the latter is obsoleted, and this way we always
process the former instead.

* [mtouch] Adjust wording for MT4178 to be more accurate.

* [WatchKit] Make more API obsolete/hidden.

Two classes managed to slip past the first time.

* [tests] Adjust test after WatchKit removal.
2019-08-14 17:46:55 +02:00
Rolf Bjarne Kvinge a495077533
[xcode11] Stop building/shipping 32-bit Xamarin.Mac bits. Partial fix for #6300. (#6393)
This includes:

* 32-bit version of Xamarin.Mac.dll and OpenTK.dll
* XamMac.dll and XamMac.CFNetwork.dll
* 32-bit versions of the runtime libraries (libxammac.a and friends).
* 32-bit version of the partial static library for Xamarin.Mac.
* Classic support in the generator.

We still ship a few Classic files so that Visual Studio for Mac continue to detect that Xamarin.Mac is installed (otherwise VSfM won't open Classic projects, which makes it impossible to use the migration wizard).

This makes our build slightly faster.

Partial fix for #6300.
2019-07-15 10:19:24 -07:00
Sebastien Pouliot fc5b9e24d4
[mmp] Ignore, by default, frameworks that cause rejection from App Store. Fix #6039 (#6107)
So far this only applies to `QTKit`...

XM will now, by default, avoid natively link with QTKit unless it's
instructed to so explicitly using `--link-prohibited-frameworks`

ref: https://github.com/xamarin/xamarin-macios/issues/6039
2019-05-23 15:59:40 -05:00
Rolf Bjarne Kvinge 045945817b [registrar] Extract code to create a managed array from an NSArray to a separate method. 2019-04-30 14:29:24 +00:00
Rolf Bjarne Kvinge 2cb20de784 [registrar] Extract code to create an NSArray from a managed array to a separate method. 2019-04-30 14:29:24 +00:00
Rolf Bjarne Kvinge d9c0d5e93a [runtime] Report which element failed to convert when marshalling an array between Objective-C and managed code. 2019-04-30 14:29:24 +00:00
Rolf Bjarne Kvinge 7a9cb8372a [registrar] Extract code to create a managed array from an NSArray to a separate method. 2019-04-26 11:20:15 +02:00
Rolf Bjarne Kvinge 4f3b6115fc [registrar] Extract code to create an NSArray from a managed array to a separate method. 2019-04-26 11:20:15 +02:00
Rolf Bjarne Kvinge f83df952de [runtime] Report which element failed to convert when marshalling an array between Objective-C and managed code. 2019-04-26 11:20:15 +02:00
Rolf Bjarne Kvinge c8ed014af7
[runtime] Improve exception creation. (#5944)
* [runtime] Add an inner exception parameter to Runtime.CreateProductException.

This allows us to simplify code by using inner (and outer) exceptions as
a means to provide information instead of passing extra information
around in order to create decent exceptions.

One example is how we pass the selector and method name to the method
that converts from a native id to a managed NSObject instance: passing
this information is not necessary anymore if we can use two exceptions,
one for the failure to convert from an id to a NSObject instance,
wrapped in a second that tells which method/selector call ran into this
conversion problem.

* [runtime] Throw better exceptions when the dynamic registrar can't marshal something.

* [runtime] Throw a better exception when something goes wrong when trying to marshal a return value.

* [runtime] Use inner exceptions to convey failure information instead of trying to create a single exception with all we know.

* Fix merge problem.
2019-04-26 11:16:23 +02:00
Rolf Bjarne Kvinge c8ff37a3f2
[docs] Fix issues that look like merge problems in the mtouch/mmp docs. (#5933)
* Fix formatting for a few errors.
* Add a few missing mtouch errors.

It looks like all of this is due to incorrect merges.
2019-04-23 13:59:39 +01:00
Sebastien Pouliot 5c321ac89d
[mtouch] Update validations around --interpreter (#5772)
This also centralize other interpreter checks and options in the same
location (making it easier to read / update).

* Warn and switch the REPL if the interpreter is enabled on simulator

Why ? It's confusing to build the same code using different options for
simulator and devices. This is what happens if you try to use features
like `dynamic` or `System.Reflection.Emit`.

So instead of an error, we warn that the interpreter is not supported
and switch to the existing REPL mode.

The JIT remains the only option for the simulator but it allows testing
features without a device.

* Fail early if the interpreter is used on 32bits [1]

The current interpreter only works on 64 bits (so ARM64). However the
error won't be reported, back to the developer, until deployment time.

This temporary [1] fix spot the condition very early and report an error

```
error MT0099 : Internal error : The interpreter is currently only available for 64 bits.
```

instead of the current one at deploy time

```
IncorrectArchitecture: Failed to find matching arch for 32-bit Mach-O input file /private/var/installd/Library/Caches/com.apple.mobile.installd.staging/temp.tNKDlx/extracted/X.app/X
error MT1006: Could not install the application 'X.app' on the device 'Mercure': AMDeviceSecureInstallApplicationBundle returned: 0xe8000087 (kAMDIncorrectArchitectureError).

Application could not be uploaded to the device.
```

[1] https://github.com/mono/mono/issues/9871

* [tests] Fix/renumbered MT0138

The test was using simulator + interpreter which is not _really_
possible, we use REPL in that case - so we're now checking if
assemblies were specified with `--interpreter` to cover both cases.

Also 0138 was already used by `mmp` and the warning was **not**
registered or documented in the errors documents. To avoid
confusion it has been renumbered to 0142 and documented.
2019-03-19 08:22:39 -05:00
Chris Hamons e91ba9f93a
[mmp] Fix typo (#5123)
- https://github.com/xamarin/xamarin-macios/issues/5121
2018-11-13 17:56:05 -05:00
Chris Hamons c41673dce8
Add mmp error when combining partial static registrar and linking (#4932)
- https://github.com/xamarin/xamarin-macios/issues/4825
2018-10-05 09:43:53 -05:00
Chris Hamons 3119129ab7 Remove references to bugzilla and replace with github (#4920)
https://github.com/xamarin/xamarin-macios/issues/3647
2018-10-04 09:43:55 -04:00
Chris Hamons 2b85512509
Update MM0134 with url to fix #3577 (#4879) 2018-09-26 10:24:22 -05:00
Rolf Bjarne Kvinge 11d9fe68db
[mtouch/mmp/docs] Improve MT0091 to include how to enable the linker. Fixes #4549. (#4852)
Fixes https://github.com/xamarin/xamarin-macios/issues/4549.
2018-09-21 16:51:23 +02:00
Vincent Dondain dbb151c63e [docs] Fix errors after broken merge 2018-09-19 11:03:56 -04:00
Vincent Dondain 2174ec41a2 Merge branch 'xcode10' 2018-09-18 14:12:39 -04:00
Rolf Bjarne Kvinge 385592b128
[runtime] Throw a managed exception instead of trying to call a null function pointer if the runtime tries to call a function that has been linked away. (#4770)
* [runtime] Throw a managed exception instead of trying to call a null function pointer if the runtime tries to call a function that has been linked away.

* [tests] Add new file for Xamarin.Mac tests.

* Direct people to file issues in github.
2018-09-10 10:56:02 +02:00
Rolf Bjarne Kvinge bd32b74347
Add support for delegates as return values in protocol members. Fixes #4102. (#4758)
* Add support for delegates as return values in protocol members. Fixes #4102.

This required a few changes:

* The generator now emits the DelegateProxy attribute for property getters in
  protocol interfaces.
* The generator now emits the DelegateProxy attribute in ProtocolMember
  attributes (and the ProtocolMember attribute has been extended with
  additional properties for this purpose).
* The generator now emits the BlockProxy attribute for the parameter in
  property setters.
* The generator now emits the BlockProxy attribute in ProtocolMember
  attributes for property setters.
* The static registrar now emits the metadata token for the
  DelegateProxy.DelegateType property into the generated code so that the
  DelegateProxy attribute itself isn't needed at runtime. This is required
  when the dynamic registrar has been optimized away.

Fixes https://github.com/xamarin/xamarin-macios/issues/4102.

* [tests] Update MX4105 test to expect new warnings.
2018-09-06 16:20:23 +02:00
Rolf Bjarne Kvinge 5da88bfbc7
[mmp] Show an error if trying to build a 32-bit app with Xcode 10. Fixes #4569. (#4684)
Fixes https://github.com/xamarin/xamarin-macios/issues/4569.
2018-08-24 12:28:10 +02:00
Vincent Dondain eec95e881c Merge branch 'd15-8' into xcode10-rebase-15.8 2018-08-13 21:04:56 -04:00
Rolf Bjarne Kvinge fd05ba6a79
[mtouch] Show warnings when we can't find referenced assemblies. (#4511)
* [mtouch] Show warnings when we can't find referenced assemblies.

This would have helped track down #4235.

* Improve MT0137 warning to indicate the type of the attribute causing the warning.
2018-07-30 10:55:23 +02:00
Rolf Bjarne Kvinge e110612118
[registrar] Improve error message when failing to create a managed wrapper for a native handle. (#4360)
* Convert it into a MM8027/MT8027 error (with documentation).
* Add information about the selector and managed method that triggered the error.

Now the problem reported in issue #4254 shows up as:

> ObjCRuntime.RuntimeException: Failed to marshal the Objective-C object 0x7f8080412810 (type: UIView). Could not find an existing managed instance for this object, nor was it possible to create a new managed instance (because the type 'UIKit.UIView&' does not have a constructor that takes one IntPtr argument).
> Additional information:
> 	Selector: popoverController:willRepositionPopoverToRect:inView:
> 	Method: UIKit.UIPopoverController+_UIPopoverControllerDelegate.WillReposition(UIKit.UIPopoverController, CoreGraphics.CGRect ByRef, UIKit.UIView ByRef)

instead of just:

> ObjCRuntime.RuntimeException: Failed to marshal the Objective-C object 0x7f8080412810 (type: UIView). Could not find an existing managed instance for this object, nor was it possible to create a new managed instance (because the type 'UIKit.UIView&' does not have a constructor that takes one IntPtr argument).

which makes it much easier to understand, track down, and fix/work around,
both for customers and ourselves.
2018-06-29 14:38:28 +02:00
Rolf Bjarne Kvinge a28fa8b56f
[docs] Fix bugzilla link to file bugs for Xamarin.Mac for mmp errors. (#4358) 2018-06-29 09:47:14 +02:00
Rolf Bjarne Kvinge a88a79cfc0
[mtouch/mmp] Handle invalid types in BlockProxy attributes better. Fixes #4072. (#4073)
* [mtouch/mmp] Handle invalid types in BlockProxy attributes better. Fixes #4072.

BlockProxy attributes may have types we don't expect, so handle those cases
gracefully by showing a warning when we encounter them:

    testApp.cs(11): warning MT4175: The parameter 'completionHandler' in the method 'Issue4072Session.CreateDataTask(Foundation.NSUrl,Foundation.NSUrlSessionResponse)' has an invalid BlockProxy attribute (the type passed to the attribute does not have a 'Create' method).

instead of an ugly MT0000:

    MTOUCH : error MT0000: Unexpected error - Please file a bug report at http://bugzilla.xamarin.com
    System.InvalidOperationException: Sequence contains no matching element
      at System.Linq.Enumerable.First[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] predicate) [0x00012] in /Users/builder/jenkins/workspace/build-package-osx-mono/2017-12/external/bockbuild/builds/mono-x64/external/corefx/src/System.Linq/src/System/Linq/First.cs:30
      at Registrar.StaticRegistrar.GetBlockProxyAttributeMethod (Mono.Cecil.MethodDefinition method, System.Int32 parameter) [0x00020] in /Users/builder/data/lanes/5944/7e782c1e/source/xamarin-macios/tools/common/StaticRegistrar.cs:4121
      at Registrar.StaticRegistrar.GetBlockWrapperCreator (Registrar.Registrar+ObjCMethod obj_method, System.Int32 parameter) [0x00011] in /Users/builder/data/lanes/5944/7e782c1e/source/xamarin-macios/tools/common/StaticRegistrar.cs:4065
      at Registrar.StaticRegistrar.Specialize (Registrar.AutoIndentStringBuilder sb, Registrar.Registrar+ObjCMethod method, System.Collections.Generic.List`1[T] exceptions) [0x0216b] in /Users/builder/data/lanes/5944/7e782c1e/source/xamarin-macios/tools/common/StaticRegistrar.cs:3683
      at Registrar.StaticRegistrar.Specialize (Registrar.AutoIndentStringBuilder sb) [0x00f1e] in /Users/builder/data/lanes/5944/7e782c1e/source/xamarin-macios/tools/common/StaticRegistrar.cs:2963

Fixes #4072.

* [docs] Improve text for MT4175.

* [registrar] Comment some code.
2018-05-11 14:42:27 +02:00
Rolf Bjarne Kvinge a54b471713
[docs] Fix MT -> MM prefix for Xamarin.Mac errors. (#4054) 2018-05-10 07:40:48 +02:00
Brad Umbaugh 334473b50b Removed an unnecessary period (#3967) 2018-04-20 16:20:04 -04:00
Sebastien Pouliot c80edcea02
Synchronize back docs moved to https://docs.microsoft.com (#3771) 2018-04-17 09:02:42 -04:00
Chris Hamons 3627e87344 [mmp][mtouch] Better guard framework SDK checks (#3757) (#3796)
- https://github.com/xamarin/xamarin-macios/issues/3725
- These frameworks "CoreAudioKit Metal MetalKit MetalPerformanceShaders CoreNFC DeviceCheck"
 were special cased, but that special case did do an SDK check.
- Create a helper method to share check
- Add test for MM0135
2018-03-21 21:00:23 -04:00
Chris Hamons ab7ba02fe7
Move MM2100 to a 2109 as mtouch collided with it (#3773) 2018-03-20 09:28:06 -05:00
Chris Hamons a73b200f59
[mmp][mtouch] Better guard framework SDK checks (#3757)
- https://github.com/xamarin/xamarin-macios/issues/3725
- These frameworks "CoreAudioKit Metal MetalKit MetalPerformanceShaders CoreNFC DeviceCheck"
 were special cased, but that special case did do an SDK check.
- Create a helper method to share check
- Add test for MM0135
2018-03-20 09:26:25 -05:00
Rolf Bjarne Kvinge 835f65897f
[static registrar] Optimize creation of delegates for blocks. (#3623) (#3644)
* [static registrar] Optimize creation of delegates for blocks.

Optimize creation of delegates for blocks so that it doesn't require the
dynamic registrar.

This is done by getting the metadata token for the Create method that creates
the delegate, and embed that metadata token in the generated code from the
static registrar.

Also add tests, since this scenario was not covered by tests already.

* [mmptest] Fix test after recent changes.

* [test-libraries] Avoid duplicate symbols.

* [tests] Update according to changes.
2018-03-05 07:41:28 +01:00
Chris Hamons cabc4fbe2c [mmp] Add stripping of 32-bit dylibs to work with new App Store restrictions (#3387) (#3633)
- https://github.com/xamarin/xamarin-macios/issues/3367
- App Store will now fail builds if you add in a 32-bit dylib
- If you are a 32-bit app you don't need the 64-bit part of your fat
dylib anyway
- Add --optimize=-trim-architectures to allow customization of behavior, as not everyone
uses app store

In addition, while writing tests for this is was noticed that mmp tests did not "really" run Release configuration correctly in most cases. Fixing this turned out to be a bit of a pain, but necessary to correctly test this (and other things).

- Turns out that /p:configuration:debug is not sufficient to tell mmp to
do the right thing
- That, in most projects, sets the DebugSymbols property, which really
is what is checked.
- However, two of our projects did not have that, so we always did
release mmp work.
- Removed configuration property for tests and added real "Release"
configuration option
2018-03-02 14:33:27 +01:00