diff --git a/PolyShim/Net50/OSPlatformAttribute.cs b/PolyShim/Net50/OSPlatformAttribute.cs new file mode 100644 index 0000000..aec60df --- /dev/null +++ b/PolyShim/Net50/OSPlatformAttribute.cs @@ -0,0 +1,18 @@ +#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#nullable enable +// ReSharper disable RedundantUsingDirective +// ReSharper disable CheckNamespace +// ReSharper disable InconsistentNaming +// ReSharper disable PartialTypeWithSinglePart + +using System.Diagnostics.CodeAnalysis; + +namespace System.Runtime.Versioning; + +// https://learn.microsoft.com/en-us/dotnet/api/system.runtime.versioning.osplatformattribute +[ExcludeFromCodeCoverage] +internal abstract class OSPlatformAttribute(string platformName) : Attribute +{ + public string PlatformName { get; } = platformName; +} +#endif diff --git a/PolyShim/Net50/SupportedOSPlatformAttribute.cs b/PolyShim/Net50/SupportedOSPlatformAttribute.cs new file mode 100644 index 0000000..6cd0c4e --- /dev/null +++ b/PolyShim/Net50/SupportedOSPlatformAttribute.cs @@ -0,0 +1,31 @@ +#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#nullable enable +// ReSharper disable RedundantUsingDirective +// ReSharper disable CheckNamespace +// ReSharper disable InconsistentNaming +// ReSharper disable PartialTypeWithSinglePart + +using System.Diagnostics.CodeAnalysis; + +namespace System.Runtime.Versioning; + +// https://learn.microsoft.com/en-us/dotnet/api/system.runtime.versioning.supportedosplatformattribute +[AttributeUsage( + AttributeTargets.Assembly + | AttributeTargets.Class + | AttributeTargets.Constructor + | AttributeTargets.Enum + | AttributeTargets.Event + | AttributeTargets.Field + | AttributeTargets.Interface + | AttributeTargets.Method + | AttributeTargets.Module + | AttributeTargets.Property + | AttributeTargets.Struct, + AllowMultiple = true, + Inherited = false +)] +[ExcludeFromCodeCoverage] +internal class SupportedOSPlatformAttribute(string platformName) + : OSPlatformAttribute(platformName); +#endif diff --git a/PolyShim/Net50/TargetPlatformAttribute.cs b/PolyShim/Net50/TargetPlatformAttribute.cs new file mode 100644 index 0000000..79f0dbd --- /dev/null +++ b/PolyShim/Net50/TargetPlatformAttribute.cs @@ -0,0 +1,16 @@ +#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#nullable enable +// ReSharper disable RedundantUsingDirective +// ReSharper disable CheckNamespace +// ReSharper disable InconsistentNaming +// ReSharper disable PartialTypeWithSinglePart + +using System.Diagnostics.CodeAnalysis; + +namespace System.Runtime.Versioning; + +// https://learn.microsoft.com/en-us/dotnet/api/system.runtime.versioning.targetplatformattribute +[AttributeUsage(AttributeTargets.Assembly)] +[ExcludeFromCodeCoverage] +internal class TargetPlatformAttribute(string platformName) : OSPlatformAttribute(platformName); +#endif diff --git a/PolyShim/Net50/UnsupportedOSPlatformAttribute.cs b/PolyShim/Net50/UnsupportedOSPlatformAttribute.cs new file mode 100644 index 0000000..1a09db9 --- /dev/null +++ b/PolyShim/Net50/UnsupportedOSPlatformAttribute.cs @@ -0,0 +1,34 @@ +#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#nullable enable +// ReSharper disable RedundantUsingDirective +// ReSharper disable CheckNamespace +// ReSharper disable InconsistentNaming +// ReSharper disable PartialTypeWithSinglePart + +using System.Diagnostics.CodeAnalysis; + +namespace System.Runtime.Versioning; + +// https://learn.microsoft.com/en-us/dotnet/api/system.runtime.versioning.unsupportedosplatformattribute +[AttributeUsage( + AttributeTargets.Assembly + | AttributeTargets.Class + | AttributeTargets.Constructor + | AttributeTargets.Enum + | AttributeTargets.Event + | AttributeTargets.Field + | AttributeTargets.Interface + | AttributeTargets.Method + | AttributeTargets.Module + | AttributeTargets.Property + | AttributeTargets.Struct, + AllowMultiple = true, + Inherited = false +)] +[ExcludeFromCodeCoverage] +internal class UnsupportedOSPlatformAttribute(string platformName, string? message = null) + : OSPlatformAttribute(platformName) +{ + public string? Message { get; } = message; +} +#endif diff --git a/PolyShim/Net60/SupportedOSPlatformGuardAttribute.cs b/PolyShim/Net60/SupportedOSPlatformGuardAttribute.cs new file mode 100644 index 0000000..9631f60 --- /dev/null +++ b/PolyShim/Net60/SupportedOSPlatformGuardAttribute.cs @@ -0,0 +1,29 @@ +#if (NETCOREAPP && !NET6_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#nullable enable +// ReSharper disable RedundantUsingDirective +// ReSharper disable CheckNamespace +// ReSharper disable InconsistentNaming +// ReSharper disable PartialTypeWithSinglePart + +using System.Diagnostics.CodeAnalysis; + +namespace System.Runtime.Versioning; + +// https://learn.microsoft.com/en-us/dotnet/api/system.runtime.versioning.supportedosplatformguardattribute +[AttributeUsage( + AttributeTargets.Field | AttributeTargets.Method | AttributeTargets.Property, + AllowMultiple = true, + Inherited = false +)] +[ExcludeFromCodeCoverage] +internal class SupportedOSPlatformGuardAttribute(string platformName) + // OSPlatformAttribute's constructor is not accessible where that type is natively defined +#if !(NETCOREAPP && NET5_0_OR_GREATER) + : OSPlatformAttribute(platformName); +#else + : Attribute +{ + public string PlatformName { get; } = platformName; +} +#endif +#endif diff --git a/PolyShim/Net60/UnsupportedOSPlatformGuardAttribute.cs b/PolyShim/Net60/UnsupportedOSPlatformGuardAttribute.cs new file mode 100644 index 0000000..b64ee0b --- /dev/null +++ b/PolyShim/Net60/UnsupportedOSPlatformGuardAttribute.cs @@ -0,0 +1,29 @@ +#if (NETCOREAPP && !NET6_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#nullable enable +// ReSharper disable RedundantUsingDirective +// ReSharper disable CheckNamespace +// ReSharper disable InconsistentNaming +// ReSharper disable PartialTypeWithSinglePart + +using System.Diagnostics.CodeAnalysis; + +namespace System.Runtime.Versioning; + +// https://learn.microsoft.com/en-us/dotnet/api/system.runtime.versioning.unsupportedosplatformguardattribute +[AttributeUsage( + AttributeTargets.Field | AttributeTargets.Method | AttributeTargets.Property, + AllowMultiple = true, + Inherited = false +)] +[ExcludeFromCodeCoverage] +internal class UnsupportedOSPlatformGuardAttribute(string platformName) + // OSPlatformAttribute's constructor is not accessible where that type is natively defined +#if !(NETCOREAPP && NET5_0_OR_GREATER) + : OSPlatformAttribute(platformName); +#else + : Attribute +{ + public string PlatformName { get; } = platformName; +} +#endif +#endif diff --git a/PolyShim/Net70/ObsoletedOSPlatformAttribute.cs b/PolyShim/Net70/ObsoletedOSPlatformAttribute.cs new file mode 100644 index 0000000..f8cab83 --- /dev/null +++ b/PolyShim/Net70/ObsoletedOSPlatformAttribute.cs @@ -0,0 +1,45 @@ +#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#nullable enable +// ReSharper disable RedundantUsingDirective +// ReSharper disable CheckNamespace +// ReSharper disable InconsistentNaming +// ReSharper disable PartialTypeWithSinglePart + +using System.Diagnostics.CodeAnalysis; + +namespace System.Runtime.Versioning; + +// https://learn.microsoft.com/en-us/dotnet/api/system.runtime.versioning.obsoletedosplatformattribute +[AttributeUsage( + AttributeTargets.Assembly + | AttributeTargets.Class + | AttributeTargets.Constructor + | AttributeTargets.Enum + | AttributeTargets.Event + | AttributeTargets.Field + | AttributeTargets.Interface + | AttributeTargets.Method + | AttributeTargets.Module + | AttributeTargets.Property + | AttributeTargets.Struct, + AllowMultiple = true, + Inherited = false +)] +[ExcludeFromCodeCoverage] +internal class ObsoletedOSPlatformAttribute(string platformName, string? message = null) + // OSPlatformAttribute's constructor is not accessible where that type is natively defined +#if !(NETCOREAPP && NET5_0_OR_GREATER) + : OSPlatformAttribute(platformName) +#else + : Attribute +#endif +{ +#if (NETCOREAPP && NET5_0_OR_GREATER) + public string PlatformName { get; } = platformName; +#endif + + public string? Message { get; } = message; + + public string? Url { get; init; } +} +#endif