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

25 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge 09f349b8ce
[generator] Fix reporting BI1042. (#13587)
Fix reporting BI1042 to include the type + property that triggered the error +
add a test.
2021-12-17 21:47:24 +01:00
Filip Navara bfe8eb55cd
Replace IKVM.Reflection with MetadataLoadContext (#9864)
IKVM.Reflection is not actively maintained while MetadataLoadContext is actively maintained as part of dotnet/runtime.

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Co-authored-by: Alex Soto <alex@alexsoto.me>
2021-05-21 15:15:59 +02:00
Rolf Bjarne Kvinge c98b51feb7
[bgen] Avoid a NullReferenceException when reporting multiple attributes on a type. Fixes #10310. (#10311)
Fixes https://github.com/xamarin/xamarin-macios/issues/10310.
2020-12-17 15:12:32 +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
Waleed Chaudhry 729e241e4a
[Localization] Add generator error messages (#7531) 2020-01-08 16:07:46 -05:00
Waleed Chaudhry 1dc3beabfa
[Generator] Provide clear error message on type mismatch with BindAs error (#7016)
* [Generator] Provide clear error message on type mismatch with BindAs attribute that results in  generator crashing. Fixes 6863.
2019-09-19 21:05:22 -04: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 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
Rolf Bjarne Kvinge ef0d7a1718
[generator] Show proper errors when failing to compile something. (#6003)
* [mtouch/mmp] Split out the RunCommand[Async] methods to a separate file so that the generator can reuse more easily.

* [generator] Show proper errors when failing to compile something.

* Fix grammar
2019-05-07 13:40:59 +02: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
Rolf Bjarne Kvinge adb57537b5
[bgen] Show an error if trying to bind an array of selectors. (#5923) 2019-04-23 06:29:03 +01:00
Manuel de la Pena 41fe079f9b [Generator] Ensure the correct error is raised when an Export is missing on a Property. (#4604)
The generator had a small bug in which we would get a NRE when a
property missed a Export attribute and had no WrapAttr. The issue is due
to the fact that an || is being used and does not shortcut when the
attribute is missing. In that case, the first Get check would pass and a
second attempt would happen with the set. In the case the set is missing,
we would get a NRE. The correct way is to ensure that we do have the get
and the set BEFORE the attr is checked.

The added test shows an example of the issue.
2018-08-09 16:06:14 -04:00
Alex Soto dca6d79881
[generator] Teach generator about WrapAttribute on Getters and Setters (#3388)
* [generator] Teach generator about WrapAttribute on Getters and Setters

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

`WrapAttribute` can now be used in property getters and setters,
this allows to Wrap virtually anything the way you need, for example
smart enums, consider the following API definition:

```csharp
// Smart enum.
enum PersonRelationship {
	[Field (null)]
	None,

	[Field ("FMFather", "__Internal")]
	Father,

	[Field ("FMMother", "__Internal")]
	Mother
}
```

```csharp
// Property definition.

[Export ("presenceType")]
NSString _PresenceType { get; set; }

PersonRelationship PresenceType {
	[Wrap ("PersonRelationshipExtensions.GetValue (_PresenceType)")]
	get;
	[Wrap ("_PresenceType = value.GetConstant ()")]
	set;
}
```

* Fix Feedback

* Fix doc error

* Update error message
2018-02-05 21:14:08 -06: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
Chris Hamons 4c5161a446
Create classic snapshot of bgen and update tests/scripts (#3153)
Previous PMCS removal changes froze XamMac.BindingAttributes.dll but not bgen.exe which causes interesting issues when we make changes there and run classic XM tests.

This can be seen here: #3147

This PR freezes bgen-classic in macios-binaries (which will need to be added to master and bumped before this goes in) and update various scripts/tests.
2018-01-03 15:41:49 -06:00
Chris Hamons 734850d416
Remove PMCS processing of availability attributes (#3096)
- XamarinPreprocessorVisitor handled processing/generating availability
  attributes but needs to be removed as it depends on PMCS
- Because processing was handled at a preprocessor/token level before and
  now inside generator.cs a number of changes were needed avoid checking
  in a million line diff (literally)
- This commit creates a "shadow" set of availability attributes, with
  the desired names [Mac] [Watch] [NoTV], etc when not in existence before
- Instead of adding hundreds of using statements to force resolution of these
  shadow types, I abuse C# type resolution by storing them in the root
  (not namespaced) so they are resolved first.
- generator-attributes-manager was taught how to process the multitude of
  old-style attributes and how to generate the new-style attributes
- Generator's bug57070 is no longer valid, since we _can_ and do convert [iOS]
2017-12-22 13:03:21 -06:00
Alex Soto f8d7c54a0f [generator] Disallow the use of [Async] when the signature contains ref/out parameters, fixes bug 58792. (#3059)
When a method signature contains any ref/out parameters
it is a hint that this method is not a candidate to be
used with [Async] we now error BI1062 in the generator.

The reason of an error instead of a warning is that we
currently generate not compilable code when ref/out is
used on the method signature or in the signature of the
delegate (completion handler), it is very unlikely we are
breaking someone now that we emit an error instead of broken
code.

* Fix Anchor and Clarify the addition of BI1117 Warning into docs/website/generator-errors.md

BI1117 Warning documentation was missing from docs/website/generator-errors.md
so I added it.
2017-12-18 09:21:23 -05: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
Alex Soto 21a56a5f27
[generator] Improve BI1014 - include name of unsupported field and update valid types on docs, fixes bug 57094. (#3001)
* [generator] Improve BI1014 - include name of unsupported field and update valid types on docs, fixes bug 57094.

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

* Implement feedback

* fix error message

* More feedback
2017-11-14 08:46:46 -06:00
Alex Soto b197eab50e
[generator] Fix slightly incorrect error message when trying to use ref/out parameters with BindAs attributes, fixes 57804. (#2997)
https://bugzilla.xamarin.com/show_bug.cgi?id=57804
2017-11-13 14:21:18 -06:00
Alex Soto ee19c79feb
[Generator] BindAs attribute for smart enums of an array of nullable values generates code that doesn't compile, Fixes bug 57797 (#2954)
* [Generator] BindAs attribute for smart enums of an array of nullable values generates code that doesn't compile, Fixes bug 57797

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

We now correctly compiles the array nullabe types

* Disable Nullable array types in BindAs until we add registrar support
2017-11-13 10:54:21 -06:00
Alex Soto 8e92d2a350
[Generator] BindAs attribute for smart enum to multidimensional array generates code that doesn't compile, Fixes Bug 57795 (#2948)
https://bugzilla.xamarin.com/show_bug.cgi?id=57795

We now error out with "BI1048 Unsupported type Foo[,] decorated with [BindAs]"
2017-11-02 08:34:10 -06: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