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

9 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge 1b3cb7747e [linker] Always create the [Core]RemoveAttributes steps, and instead detect if it should be active using the LinkContext field. 2020-05-07 15:51:38 +02:00
Sebastien Pouliot 61580b15af
[linker] Update custom attributes that can be removed (#8535)
Some are no longer part of the SDK (or converted into new ones
at build time), others were new (and missing).

A full list of attributes and their usage frequency in what we ship can
be seen in https://gist.github.com/spouliot/ca03c6da7d4d75670ca77749350eb8a2

Also update tests: no need to check for removals of stuff that does not
exists anymore.
2020-05-06 20:44:52 -04:00
Rolf Bjarne Kvinge 6be77427f3 [mtouch/mmp] Register complete protocol information in the static registrar, and link away unneeded metadata/code.
Improved linker to:

* Not mark protocol interfaces by the mere virtue of having a type that
  implements them. This is implemented by not marking protocol interfaces when
  they're implementing a class, but instead when a method implementation is
  found to implement a method from a protocol interface.
* Mark the wrapper type for protocols (this allows us to remove the Protocol
  attribute, since that's the link between the protocol and its wrapper type).
* Remove the [Protocol], [ProtocolMember] and [Adopts] attributes.

The static registrar still needs some of the information linked away, so a few
changes are required to make it available post linker.
2018-02-12 14:46:01 +01:00
Rolf Bjarne Kvinge b2bcad7a94
Add a BindingImpl attribute and use to to teach the linker look for it to search for optimizable code. (#3299)
* [ObjCRuntime] Add a BindingImplAttribute.

* [linker] Make ProviderToString an extension method on ICustomAttributeProvider to make it more discoverable.

* [generator] Use [BindingImpl] instead of [CompilerGenerated].

The entire diff is big (89MB), so it can't be gisted. However, most of it is
either removal of `using System.Runtime.CompilerServices;` or the change from
`[CompilerGenerated]` to `[BindingImpl (...)]` like this:
https://gist.github.com/rolfbjarne/8bfda3ed37b956d0342a1c1e9b079244

If I remove those parts of the diff, there's nothing significant left:
https://gist.github.com/rolfbjarne/4156164d6bdb1376366200394eb8a091

* [linker] Teach the linker about the new [BindingImpl] attribute.

In addition to the existing logic where the linker would optimize some
[CompilerGenerated] code (sometimes with additional requirements), it will now
also optimize all [BindingImpl (Optimizable)] code (without any additional
requirements).

* [tests] Add tests to make sure [BindingImpl (Optimizable)] works as expected.

* [linker] Check for [BindingImpl] before [CompilerGenerated] and stop checking for [CompilerGenerated] in XAMCORE_4_0.

Check for [BindingImpl] before checking for [CompilerGenerated], since the
former is more common.

Also stop checking for [CompilerGenerated] (at least to mean that code is
optimizable) in our next non-compatible evolutionary leap (XAMCORE_4_0):

* [introspection] Impl a better typo check.
2018-01-26 18:38:23 +01:00
Rolf Bjarne Kvinge 90a2ac27b1
[linker] Implement a generic method of storing attributes the linker removes. (#3280)
* [linker] Implement a generic method of storing attributes that may be removed by the linker.

Implement a generic method of storing attributes that may be removed by the
linker, so that those attributes can be accessed after the linker has linked
them away.

* [linker] Store availability attributes using the new generic location.

* [linker] Store the CompilerGenerated attribute using the new generic location.
2018-01-24 15:58:47 +01:00
Sebastien Pouliot ec744533b9
[generator] Add support for [RequiresSuper] attribute. Fixes #58350 (#3147)
* Add new attribute;
* Add generator support (re-copy attribute);
* Add xtro rule to detect missing/extra [RequiresSuper] attributes;
* Add attributes to the required API;

The generated code changes (reversed) can be verified with
https://gist.github.com/spouliot/1c91d6ee7c084a06890e5f3f2a475001

Reference:
https://bugzilla.xamarin.com/show_bug.cgi?id=58350
2018-01-04 11:48:00 -05:00
Rolf Bjarne Kvinge f660667990 [registrar] Store the attribute type separately for availability attributes saved for the registrar. (#2807)
The registrar requires the availability attributes to work properly, which is
non-trivial when the linker is being used, because the linker runs before the
registrar, and will remove availability attributes.

For this reason we store the availability attributes separately when the
linker removes them so that the registrar can still find them, but
unfortunately it's not enough to store the CustomAttribute instance, because
it may end up crippled: if the attribute type itself is removed by the linker,
then it's not possible to get the attribute type from the CustomAttribute
instance, because 'attribute.Constructor.DeclaringType' returns null (the
linker sets the declaring type of the constructor to null).

Solution: store the attribute type separately; now we use a Tuple of
CustomAttribute and TypeReference.

Fixes this ugly exception:

    System.NullReferenceException: Object reference not set to an instance of an object
      at XamCore.Registrar.Registrar.RegisterAssembly (Mono.Cecil.AssemblyDefinition assembly) [0x00146] in /work/maccore/master/xamarin-macios/src/ObjCRuntime/Registrar.cs:2316
      at XamCore.Registrar.StaticRegistrar.Generate (System.Collections.Generic.IEnumerable`1[T] assemblies, System.String header_path, System.String source_path) [0x00035] in /work/maccore/master/xamarin-macios/tools/common/StaticRegistrar.cs:4197
      at Xamarin.Bundler.RunRegistrarTask.Execute () [0x00001] in /work/maccore/master/xamarin-macios/tools/mtouch/BuildTasks.mtouch.cs:154
2017-09-29 17:19:08 +02:00
Alex Soto 43e220df7f [generator] Keep [NotImplemented] info so it is usable in 3rd party bindings. Fixes bug 52664 (#2131)
* [generator] Keep [NotImplemented] info so it is usable in 3rd party bindings. Fixes bug 52664

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

Currently we do not keep the [NotImplemented](0) information and the
generator gets a little confused because it will not find an Export
inside the getters/setters of properties and there is no way to tell
if this was intentional or not. We now keep the [NotImplemented]
and also add some null checks in the generator where needed.

Reenabled tests disabled in 9f036b218a

[0]: https://developer.xamarin.com/guides/cross-platform/macios/binding/objective-c-libraries/#Objective-C_Mutable_Pattern_and_Properties

* [generator] Implement feedback

* Added quote method
* Teach linker about NotImplementedAttribute

* [generator] Improve Quote method

* [generator] Fix quote now for realsssss
2017-05-25 14:42:25 -05:00
Rolf Bjarne Kvinge 82ab3fc106 Build mmp. 2016-04-24 14:47:26 -04:00