theraot / Theraot

Backporting .NET and more: LINQ expressions in .net 2.0 - nuget Theraot.Core available.
MIT License
158 stars 30 forks source link

TypeExtensions properties #133

Open NN--- opened 3 years ago

NN--- commented 3 years ago

Since C# doesn't support extension properties it is possible to introduce extension methods working for all frameworks like it is done in: https://github.com/rsdn/CodeJam/blob/master/CodeJam.Main/Targeting/TypeExtensions.cs

Example for IsSealed

        [MethodImpl(AggressiveInlining)]
        public static bool GetIsSealed([NotNull] this Type type) =>
#if TARGETS_NET || NETSTANDARD20_OR_GREATER || NETCOREAPP20_OR_GREATER
            type.IsSealed;
#else
            type.GetTypeInfo().IsSealed;
#endif

Another option is to make a class wrapper.