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

38 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge d12c04689f
Enable nullability in various places (#18082)
I started fixing nullability in one place, and then it snowballed a bit
and I had to fix nullability in a lot of places.

Most are trivial, except for the `generate-frameworks-constants`
project: I had to create a .NET version of the project in order to
compile a .NET version of the tool.
2023-05-04 07:39:56 +02:00
Rolf Bjarne Kvinge 8e6104c497 [tests] Add a HotRestart version of the BundleStructure test. 2023-04-20 18:21:17 +02:00
Rolf Bjarne Kvinge 736662d8ee
[tests] Remove files from the generator tests to fix compiler warnings. (#18092)
Also fix a nullability warning.

Fixes these warnings:

    "tests/generator/generator-tests.csproj" (default target) (1:7) ->
    (CoreCompile target) ->
      tests/generator/AttributeFactoryTests.cs(43,29): warning CS0436: The type 'AttributeFactory' in 'tests/generator/../../src/bgen/AttributeFactory.cs' conflicts with the imported type 'AttributeFactory' in 'bgen, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'tests/generator/../../src/bgen/AttributeFactory.cs'.
      tests/generator/AttributeFactoryTests.cs(44,29): warning CS0436: The type 'AttributeFactory' in 'tests/generator/../../src/bgen/AttributeFactory.cs' conflicts with the imported type 'AttributeFactory' in 'bgen, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'tests/generator/../../src/bgen/AttributeFactory.cs'.
      tests/generator/AttributeFactoryTests.cs(45,29): warning CS0436: The type 'AttributeFactory' in 'tests/generator/../../src/bgen/AttributeFactory.cs' conflicts with the imported type 'AttributeFactory' in 'bgen, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'tests/generator/../../src/bgen/AttributeFactory.cs'.
      tests/generator/ConstructorArgumentsTests.cs(17,19): warning CS0436: The type 'AttributeFactory' in 'tests/generator/../../src/bgen/AttributeFactory.cs' conflicts with the imported type 'AttributeFactory' in 'bgen, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'tests/generator/../../src/bgen/AttributeFactory.cs'.
      tests/generator/ConstructorArgumentsTests.cs(34,19): warning CS0436: The type 'AttributeFactory' in 'tests/generator/../../src/bgen/AttributeFactory.cs' conflicts with the imported type 'AttributeFactory' in 'bgen, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'tests/generator/../../src/bgen/AttributeFactory.cs'.
      tests/generator/AttributeFactoryTests.cs(53,39): warning CS0436: The type 'AttributeFactory' in 'tests/generator/../../src/bgen/AttributeFactory.cs' conflicts with the imported type 'AttributeFactory' in 'bgen, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'tests/generator/../../src/bgen/AttributeFactory.cs'.
      tests/generator/AttributeFactoryTests.cs(54,39): warning CS0436: The type 'AttributeFactory' in 'tests/generator/../../src/bgen/AttributeFactory.cs' conflicts with the imported type 'AttributeFactory' in 'bgen, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'tests/generator/../../src/bgen/AttributeFactory.cs'.
      tests/generator/AttributeFactoryTests.cs(55,39): warning CS0436: The type 'AttributeFactory' in 'tests/generator/../../src/bgen/AttributeFactory.cs' conflicts with the imported type 'AttributeFactory' in 'bgen, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'tests/generator/../../src/bgen/AttributeFactory.cs'.
      tests/generator/AttributeFactoryTests.cs(56,39): warning CS0436: The type 'AttributeFactory' in 'tests/generator/../../src/bgen/AttributeFactory.cs' conflicts with the imported type 'AttributeFactory' in 'bgen, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'tests/generator/../../src/bgen/AttributeFactory.cs'.
      tests/generator/AttributeFactoryTests.cs(64,34): warning CS0436: The type 'AttributeFactory' in 'tests/generator/../../src/bgen/AttributeFactory.cs' conflicts with the imported type 'AttributeFactory' in 'bgen, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'tests/generator/../../src/bgen/AttributeFactory.cs'.
      tests/generator/AttributeFactoryTests.cs(69,11): warning CS0436: The type 'AttributeFactory' in 'tests/generator/../../src/bgen/AttributeFactory.cs' conflicts with the imported type 'AttributeFactory' in 'bgen, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'tests/generator/../../src/bgen/AttributeFactory.cs'.
      tests/generator/AttributeFactoryTests.cs(76,34): warning CS0436: The type 'AttributeFactory' in 'tests/generator/../../src/bgen/AttributeFactory.cs' conflicts with the imported type 'AttributeFactory' in 'bgen, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'tests/generator/../../src/bgen/AttributeFactory.cs'.
      tests/generator/ConstructorArgumentsTests.cs(55,19): warning CS0436: The type 'AttributeFactory' in 'tests/generator/../../src/bgen/AttributeFactory.cs' conflicts with the imported type 'AttributeFactory' in 'bgen, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'tests/generator/../../src/bgen/AttributeFactory.cs'.
      tests/generator/AttributeFactoryTests.cs(83,34): warning CS0436: The type 'AttributeFactory' in 'tests/generator/../../src/bgen/AttributeFactory.cs' conflicts with the imported type 'AttributeFactory' in 'bgen, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'tests/generator/../../src/bgen/AttributeFactory.cs'.
      tests/generator/ConstructorArgumentsTests.cs(78,19): warning CS0436: The type 'AttributeFactory' in 'tests/generator/../../src/bgen/AttributeFactory.cs' conflicts with the imported type 'AttributeFactory' in 'bgen, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'tests/generator/../../src/bgen/AttributeFactory.cs'.
      tests/generator/AttributeFactoryTests.cs(111,16): warning CS0436: The type 'AttributeFactory' in 'tests/generator/../../src/bgen/AttributeFactory.cs' conflicts with the imported type 'AttributeFactory' in 'bgen, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'tests/generator/../../src/bgen/AttributeFactory.cs'.
      tests/generator/AttributeFactoryTests.cs(138,16): warning CS0436: The type 'AttributeFactory' in 'tests/generator/../../src/bgen/AttributeFactory.cs' conflicts with the imported type 'AttributeFactory' in 'bgen, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'tests/generator/../../src/bgen/AttributeFactory.cs'.
      tests/generator/ConstructorArgumentsTests.cs(95,19): warning CS0436: The type 'AttributeFactory' in 'tests/generator/../../src/bgen/AttributeFactory.cs' conflicts with the imported type 'AttributeFactory' in 'bgen, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'tests/generator/../../src/bgen/AttributeFactory.cs'.
      tests/generator/AttributeFactoryTests.cs(178,16): warning CS0436: The type 'AttributeFactory' in 'tests/generator/../../src/bgen/AttributeFactory.cs' conflicts with the imported type 'AttributeFactory' in 'bgen, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'tests/generator/../../src/bgen/AttributeFactory.cs'.
      tests/generator/ConstructorArgumentsTests.cs(116,19): warning CS0436: The type 'AttributeFactory' in 'tests/generator/../../src/bgen/AttributeFactory.cs' conflicts with the imported type 'AttributeFactory' in 'bgen, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'tests/generator/../../src/bgen/AttributeFactory.cs'.]
      tests/generator/ConstructorArgumentsTests.cs(194,18): warning CS0436: The type 'AttributeFactory' in 'tests/generator/../../src/bgen/AttributeFactory.cs' conflicts with the imported type 'AttributeFactory' in 'bgen, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'tests/generator/../../src/bgen/AttributeFactory.cs'.]
      tests/generator/ConstructorArgumentsTests.cs(210,18): warning CS0436: The type 'AttributeFactory' in 'tests/generator/../../src/bgen/AttributeFactory.cs' conflicts with the imported type 'AttributeFactory' in 'bgen, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'tests/generator/../../src/bgen/AttributeFactory.cs'.]
      tests/generator/ConstructorArgumentsTests.cs(197,44): warning CS8602: Dereference of a possibly null reference.
      tests/generator/ConstructorArgumentsTests.cs(201,43): warning CS8602: Dereference of a possibly null reference.
2023-04-20 07:34:30 +02:00
Manuel de la Pena cc695a8196
[Generator] Clean the attribute work. (#17570)
Some changes:

1. Move all the static attr related methods to the attr factory.
2. Make it simpler to see the diff between NET and not by using a
partial class.

---------

Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
2023-03-23 16:54:08 -04:00
Manuel de la Pena b462bfde99
[Generator] Move naming logic to its own class and add tests. (#17562)
Naming could be problematic when generating code, move the logic out of
the generator class to a helper class whose only job is to name classes
and keep track of names.

---------

Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
2023-02-17 15:33:53 -05:00
Manuel de la Pena c744a8bbc7
[Generator] Refactor AsyncMethodInfo, set nullability and add collection extensions. (#17538)
Several changes:

- Refactored AsyncMethodInfo and move the collection extensions out of
the Generator class.
- Added tests for the collection extension methods.
- Fix a mistake/bug in which Last was used instead of LastOrDefault
(funny comment was close to the right reason).

---------

Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
2023-02-16 08:47:28 -05:00
Manuel de la Pena b0683b90d5
[Generator] Move PlatformName maps out of the generator and add tests. (#17539)
Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
2023-02-15 12:12:13 -05:00
Manuel de la Pena f02135887b
[Generator] Refactor extension methods and fix bug. (#17406)
Moved the extension methods to their own file and enabled nullable.

Fixed the following underlying bug:

The extension method that creates a valid parameter named does not do
the right thing in the following cases:

1. When the starting illegal char is NOT a number. It will prepend @
fixing nothing. Example " OHOH" to "@ OHOH"
2. When the illegal chars is in the middle of the param name. Example
"OH OH" to "@OH OH"

I have fixed the method to return null in those ocassions (we will need
to enable nullability later in the generator, is too much for this PR).
Tests have been added to ensure we do not have such an issue again.

---------

Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
2023-01-31 16:05:25 -05:00
Manuel de la Pena c201466d78
[Generator] Add support for nullability. Part 1. (#17384)
This is the first part of a 2 or more changes that will allow the APIs
to use ? as a way to mark a nullable field, parameter, property and
return method.

The way it works follows the documentation from the runtime that can be
found here:
https://github.com/dotnet/roslyn/blob/main/docs/features/nullable-metadata.md

The tldr; of the documentation is as follows:

1. If we are looking at a value type, the compiler converts int? into
Nullable<int>. This was already considered in the old code.
2. If we are inspecting a generic type we have to look for the
information in two different attributes added by the compiler: -
NullableAttribute: Each type reference in metadata may have an
associated NullableAttribute with a byte[] where each byte represents
nullability: 0 for oblivious, 1 for not annotated, and 2 for annotated.
- NullableContextAttribute is valid in metadata on type and method
declarations. The byte value represents the implicit NullableAttribute
value for type reference within that scope that do not have an explicit
NullableAttribute and would not otherwise be represented by an empty
byte[].

The API is very similar to that provided by dotnet6 but it allows us to
support classic. The move to the dotnet6 API should not be hard and
probably can be done by an IDE.

Once this API lands we will have to find the old usages of the check for
nullability and combine both. This new API should fix several issues we
have with nullability and nullability + generics.

---------

Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
2023-01-30 10:34:24 -05:00
Rolf Bjarne Kvinge 6a5176ad50
Bump to MSBuild.StructuredLogger v2.1.758. (#17229)
To get new log format:

> System.NotSupportedException : Unsupported log file format. Latest
supported version is 14, the log file has version 15.
2023-01-16 07:32:45 +01:00
Manuel de la Pena fae8c53bbf
[Tests] Add missing nuget. (#15313)
Tests work because other tests do use the nugets and gets picked up by
the runner. Yet, if we execute this projects witjout others, the tests
will fail when trying to use the nunit2 format.

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2022-06-22 17:10:27 -04:00
Rolf Bjarne Kvinge 3be1d9d760
Use unix-style line endings in project files. (#15303)
This also removes the BOM in a few project files.

This is a whitespace-only change, as can be seen here: https://github.com/xamarin/xamarin-macios/pull/15303/files?w=1
2022-06-21 17:22:58 +02:00
Sebastien Pouliot cffd57d681
[cecil] Update all package references to the latest 0.11.4 (#12379) 2021-08-09 10:18:16 -04:00
dotnet-maestro[bot] 0d3ecfc065
[main] Update dependencies from dotnet/installer (#11747)
* Update dependencies from https://github.com/dotnet/installer build 20210530.2

Microsoft.Dotnet.Sdk.Internal
 From Version 6.0.100-preview.6.21274.3 -> To Version 6.0.100-preview.6.21280.2

Dependency coherency updates

Microsoft.NET.ILLink.Tasks
 From Version 6.0.100-preview.5.21271.1 -> To Version 6.0.100-preview.6.21277.2 (parent: Microsoft.Dotnet.Sdk.Internal

* Bump to MSBuild.StructuredLogger v2.1.500 to get support for log format v14.

* [tests] Skip code that needs System.ComponentModel.Composition or System.Json due to #11710.

Ref: https://github.com/xamarin/xamarin-macios/issues/11710

* [tests] Adjust logic to find MSBuild items after the last MSBuild.StructuredLogger update.

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2021-06-02 07:48:29 +02:00
Sebastien Pouliot 72a6d60d2b
[tests][dotnet] Bump MSBuild.StructuredLogger to 2.1.472 to fix ArgumentNullException in our tests (#11422) 2021-05-03 19:51:52 -04:00
Sebastien Pouliot a9251bb9ae
Bump MSBuild.StructuredLogger to 2.1.404 (#11182)
Required to bump dotnet runtime to preview 4 as the binary log format
was updated (and this affects our ability to run some tests)

https://vsdrop.corp.microsoft.com/file/v1/xamarin-macios/device-tests/20210407.33/4632319/sim/;/tests/vsdrops_index.html
2021-04-09 19:58:28 -04:00
Rolf Bjarne Kvinge b30777f420
Bump to .NET 6.0.100-preview.3.21161.23 (#10772)
* Bump to .NET 6.0.100-preview.3.21152.10

* Bump to 6.0.100-preview.3.21152.10.

* Bump to 6.0.100-preview.3.21161.7.

* Bump to .NET 6.0.100-preview.3.21161.23.

* [dotnet-linker] Bump ILink and use the supported method of getting an assembly's location.

* Bump to MSBuild.StructuredLogger 2.1.364 to get support for newer binlog versions.

* Fix build failure

Fixes:

    TestHelpers/BuildEngine.cs(161,24): error CS0433: The type 'ProjectEvaluationFinishedEventArgs' exists in both 'Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'StructuredLogger, Version=2.1.0.0, Culture=neutral, PublicKeyToken=d4c7181801cb6448' [/Users/builder/azdo/_work/1/s/xamarin-macios/tests/msbuild/Xamarin.MacDev.Tests/Xamarin.MacDev.Tests.csproj]

* Update parsing binlog properties.

* Be more defensive.

* [tests] Make sure the InternalsVisibleToAttribute constructor isn't linked away.

* [tests] Implement better printing of binlogs.

The latest MSBuild.StructuredLogger made some internal changes to the Message
property which confuses some of our test logic. So implement manual printing
of the log entries that we care about to make sure they conform to the
expected format by the tests (the output is mimicing what 'msbuild /v:diag
foo.binlog' would show).
2021-03-24 16:59:33 +01:00
Rolf Bjarne Kvinge 85fe6340f6
Bump .NET to 6.0.100-preview.2.21114.3. (#10666)
* Bump .NET to 6.0.100-preview.2.21114.3.

* [dotnet-linker] Several steps are now gone, so load our custom step before the new first step (MarkStep).

* [dotnet-linker] Dump the current steps if we fail to call InsertBefore/InsertAfter.

* [dotnet-linker] Load the CollectAssembliesStep as the first step, and make it load every assembly.

* [dotnet] Set InvariantGlobalization=true because that's the only thing .NET supports for now.

* [dotnet-linker] Use recommended workaround for linker's inability to do load assemblies in custom step.

* [tests] Bump version of MSBuild.StructuredLogger to get support for new log version.

Otherwise this happens in tests that read binary logs:

    System.NotSupportedException : Unsupported log file format. Latest supported version is 9, the log file has version 10.

* [introspection] Ignore P/Invokes to QCall for LogThreadPool* P/Invokes.

* [dotnet-linker] Inject a dummy implementation of mono_config_parse_memory as a temporary solution for mono's removal of the same method.
2021-02-23 07:49:09 +01:00
Rolf Bjarne Kvinge 9e20285ebb
[tests] Merge the msbuild-mac tests into the Xamarin.MacDev.Tests project. (#10129) 2020-12-04 13:05:51 +01:00
Rolf Bjarne Kvinge 22fe547944
[tests] Make the .NET bgen tests actually reference the .NET BCL. (#9693)
Make the bgen tests pass in the path to the attribute library, platform
assembly and all the .NET reference assemblies to bgen. This way we execute
these tests using the .NET version of everything.
2020-09-24 14:57:05 +02:00
Rolf Bjarne Kvinge 2e59986723
[tests] Migrate the generator tests to use package references. (#9239) 2020-07-30 16:20:39 +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 3ee1329e0e
[generator] Handle inheriting the same member from multiple protocols. Fixes #6366. (#6961)
* [generator] Handle inheriting the same member from multiple protocols. Fixes #6366.

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

* Update xtro.
2019-09-11 05:12:43 -07:00
Rolf Bjarne Kvinge cce789d481
[generator] Handle subclasses of NSObject as ref/out parameters in third-party libraries. Fixes #6828. (#6829) (#6847)
For third-party libraries we need to look up the base type using the BaseType attribute.

Fixes https://github.com/xamarin/xamarin-macios/issues/6828.
2019-08-26 07:14:26 -07:00
Rolf Bjarne Kvinge 4e70034b96
[generator] Handle subclasses of NSObject as ref/out parameters in third-party libraries. Fixes #6828. (#6829)
For third-party libraries we need to look up the base type using the BaseType attribute.

Fixes https://github.com/xamarin/xamarin-macios/issues/6828.
2019-08-26 01:06:13 -07:00
Rolf Bjarne Kvinge ff86152ecc [generator] Fix generation of ReturnRelease code for third-party bindings. (#6135)
Don't use internal platform API (the Selector.Release field), and make sure
the void_objc_msgSend function exists in the binding.
2019-05-30 07:12:38 +02:00
Rolf Bjarne Kvinge 50149daa1f
[generator] Fix generation of ReturnRelease code for third-party bindings. (#6135)
Don't use internal platform API (the Selector.Release field), and make sure
the void_objc_msgSend function exists in the binding.
2019-05-27 23:08:45 -07:00
Ankit Jain 7dddfb657c [xibuild] Fix incorrect mscorlib.dll being used (#6068)
* [xibuild] Fix incorrect mscorlib.dll being used

The `GuiUnit_NET_4_5` project, when built with `xibuild` uses the wrong `mscorlib.dll`.

From https://github.com/xamarin/xamarin-macios/issues/5760#issuecomment-472457202 :

```
- mscorlib.dll is being used from mono/4.5 and the other system assemblies are from mono/4.5-api
- GuiNet* project is built with xibuild

What is happening here is:

	xibuild sets[1] `SetToolsetProperty ("TargetFrameworkRootPath", FrameworksDirectory + Path.DirectorySeparatorChar);`
	which points to `/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/xbuild-frameworks`.
	This causes $(FrameworkPathOverride) to be set[2] to `/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/xbuild-frameworks/.NETFramework/v4.5`,
	but that doesn't have a mscorlib.dll, so it gets reset[3] to /Library/Frameworks/Mono.framework/Versions/5.22.0/lib/mono/4.5/.

	If we don't set TargetFrameworkRoothPath, then we get `FrameworkPathOverride = /Library/Frameworks/Mono.framework/Versions/5.22.0/lib/mono/4.5-api`,
	causing `_ExplicitReference=/Library/Frameworks/Mono.framework/Versions/5.22.0/lib/mono/4.5-api/mscorlib.dll`(correct one) to be used.
```

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

1. https://github.com/xamarin/xamarin-macios/blob/master/tools/xibuild/Main.cs#L209
2. https://github.com/mono/msbuild/blob/xplat-master/src/Tasks/Microsoft.Common.CurrentVersion.targets#L79
3. https://github.com/mono/msbuild/blob/xplat-master/src/Tasks/Microsoft.Common.CurrentVersion.targets#L84

* Revert "Workaround https://github.com/xamarin/xamarin-macios/issues/5760 in generator csproj"

This reverts commit 9bd927bb7f.

The previous commit for xibuild removes the need for this.
2019-05-17 09:12:05 -07:00
Rolf Bjarne Kvinge e3bafafff0 [tests] Add tests for out/ref parameters. 2019-04-30 14:29:24 +00:00
Rolf Bjarne Kvinge b51aaf4b8b [tests] Add tests for out/ref parameters. 2019-04-26 11:20:15 +02:00
Alexander Köplinger 9bd927bb7f Workaround https://github.com/xamarin/xamarin-macios/issues/5760 in generator csproj 2019-04-16 17:59:23 +02:00
Rolf Bjarne Kvinge ff82af4576 [bgen] Make it possible to run the tests using an in-process generator.
This means referencing the generator project, and create an array of the
arguments (since Main takes an array of strings) instead of a quoted string.
2019-04-11 08:32:58 +02:00
Rolf Bjarne Kvinge 6af4f139c2
[tests] Use latest version of NUnit for test projects to get support for parallelized tests. (#5538)
* [tests] Use latest version of NUnit for test projects to get support for parallelized tests.

* [xharness] Automatically find the correct nunit-console executable for NUnit tests.
2019-02-04 15:22:00 +01:00
Rolf Bjarne Kvinge f905427739
[tests] Share supporting code between the mtouch and mmp tests. (#3374)
* [tests] Share supporting code between the mtouch and mmp tests.

Create a new class 'BundlerTool', which now contains most of the code in
MTouchTool that's also applicable to mmp (and the new MmpTool class).

This will make it easier to share tests between the mtouch and mmp tests.

Some tweaks are still probably required, but this should get us most of the
way.

* [tests] Fix generator tests after changes in shared test code.

* [tests] Add new file to the MSBuild/XM tests.
2018-02-02 07:09:04 +01:00
Rolf Bjarne Kvinge dd95d17b5f
[generator] Properly set the IsDirectBinding value. (#3063)
* [generator] Properly set the IsDirectBinding value.

Properly set the IsDirectBinding value to false for models and synthetic types.

This also means we can now stop excluding models when testing if the
IsDirectBinding value is correct.

Also set IsDirectBinding value to true for sealed wrapper types, since those
will always be direct bindings since they can't be subclassed.

https://gist.github.com/rolfbjarne/24028bf944db848fed4083c460d0ec71

* [tests] Add introspection exclusion for XM.

* [introspection] Add back exclusions for Classic, since we can't modify/fix Classic assemblies anymore.

* [generator] Print the correct protocol name with the protocol attribute.

Fixes this test failure:

    [FAIL] Foundation.NSUrlDownloadDelegate : ConformsToProtocol(null) failed

because our binding code claimed that our `NSUrlDownloadDelegate` class
implemented the `NSUrlDownloadDelegate` protocol, but since the
`NSUrlDownloadDelegate` protocol doesn't exist (it's `NSURLDownloadDelegate` -
different case), we'd verify against a null protocol (and return true from
`ConformsToProtocol(null)`, which would fail the test).

* [xtro] Only treat interfaces as protocols.

Unfortunately we add [Protocol] to [Model]s as well as on interfaces, but we
must not process those in xtro, since they don't correspond with the actual protocol.
2017-12-01 15:18:20 +01:00
Rolf Bjarne Kvinge efebe2b73b
[tests] Port the makefile-based generator tests to NUnit. (#3019)
* [tests][generator] Port bindas1048error to NUnit.

* [tests][generator] Port bindas1049error to NUnit.

* [tests][generator] Port bindas1050modelerror to NUnit.

* [tests][generator] Port bindas1050protocolerror to NUnit.

* [tests][generator] Port bug42855 to NUnit.

* [tests][generator] Port bug57070 to NUnit.

* [tests][generator] Port bug52570classinternal to NUnit.

* [tests][generator] Port bug52570methodinternal to NUnit.

* [tests][generator] Port bug52570allowstaticmembers to NUnit.

* [tests][generator] Port protocol-duplicate-abstract-error to NUnit.

* [tests][generator] Port protocol-duplicate-method-diff-length to NUnit.

* [tests][generator] Port protocol-duplicate-method-diff-out to NUnit.

* [tests][generator] Port protocol-duplicate-method-diff-type to NUnit.

* [tests][generator] Port protocol-duplicate-method-diff-return to NUnit.

* [tests][generator] Port warnaserror to NUnit.

* [tests][generator] Port nowarn to NUnit.

* [tests][generator] Add support for inspecting/asserting the generated content.

* [tests][generator] Port some Xamarin.Mac tests to NUnit.

Ported:

* bmac_smoke
* bmac-with-hyphen-in-name
* property-redefination-mac
* NSApplicationPublicEnsureMethods
* protocol-duplicate-abstract

* [tests][generator] Point bgen to our local installation.

* [tests][generator] Port the bug31788 test to a unit test.

* [generator] Make the 'bgen' helper target more complete.

* [tests][generator] Port non-custom iOS tests to unit tests.

* [tests][generator] Add new test.

* [tests][generator] Port the forum54078 test to a unit test.

* [tests][generator] Port the desk63279 test to a unit test.

* [tests][generator] Port the desk79124 test to a unit test.

* [tests][generator] Port the multiple-api-definitions tests to unit tests.

* [generator] Use mono code style.

* [tests][generator] Port the bug29493 test to a unit test.

* [tests][generator] Port the classNameCollision test to a unit test.

* [tests][generator] Port the bi1036 test to a unit test.

* [tests][generator] Port the bug37527 test to a unit test.

Also fix BI1112 and BI1113 to show up as errors in the console output (since
they're exceptions they're already treated as errors and would cause bgen to
fail).

* [tests][generator] Port the bug27986 test to a unit test.

* [tests][generator] Port the bug35176 test to a unit test.

* [tests][generator] Port the bi1046 test to a unit test.

* [tests][generator] Port the virtualwrap test to a unit test.

* [tests][generator] Port the bug42742 test to a unit test.

* [tests][generator] Port the noasyncinternalwrapper test to a unit test.

* [tests][generator] Port the noasyncwarningcs0219 test to a unit test.

* [tests][generator] Port the bug53076 test to a unit test.

* [tests][generator] Port the bug53076withmodel test to a unit test.

* [tests][generator] Port the fieldenumtests test to a unit test.

* [tests][generator] Port the smartenumwithframework test to a unit test.

* [tests][generator] Port the forcedtype test to a unit test.

* [tests][generator] Port the bug46292 test to a unit test.

* [tests][generator] Build tests with MSBuild.

There's no need to use xbuild for these tests.

* [tests][generator] Remove dead code.

* [xharness] Don't run the makefile-based generator tests anymore.

Since there aren't any makefile-based generator tests anymore, they've all
been ported to NUnit tests.

* [tests][generator] Make the bug39614 test do what it was supposed to do: make sure a namespace isn't required (but recommended).
2017-11-20 14:55:16 +01:00
Rolf Bjarne Kvinge e8d16c925b
[mtouch/mmp/bgen] Add support for response files. (#2808)
* [mtouch/mmp/bgen] Add support for response files.

This is the first part of the fix for #56501.

https://bugzilla.xamarin.com/show_bug.cgi?id=56501

* [tests] Make sure no single argument starting with a '@' is passed to mtouch unless it's a response file.

--assembly-build-target takes arguments starting with '@', for instance:

    --assembly-build-target @all=framework

which does not work anymore, because that's interpreted as a response file
(mtouch tries to read the file '@all=framework', which obviously doesn't
exist).

The fix is simple, don't put a space between the two arguments:

    --assembly-build-target=@all=framework

* Add --root-assembly to mtouch/mmp and make the MSBuild tasks use this new option.

This makes it possible to pass root assemblies starting with `@` to mtouch/mmp
without getting mistaken for response files.

* [msbuild] Always use the command-line option that takes an equals or colon.

Always use the command-line option that takes an equals or colon instead of a
space.

Do either of these:

    --foo=something
    --foo:something

instead of this:

    --foo something

so that `something` can start with an at (`@`) sign without being mistaken for
a response file.

* [msbuild] Fix tests according to recent task changes.
2017-11-16 16:02:34 +01:00
Rolf Bjarne Kvinge 3d429a106b [generator] Add unit test project, and port a few tests over from the makefile tests. (#2299) 2017-07-10 12:46:31 +02:00