}
/// <summary>
- /// Marks APIs that were obsoleted in a given operating system version.
- ///
- /// Primarily used by OS bindings to indicate APIs that should only be used in
- /// earlier versions.
- /// </summary>
- [AttributeUsage(AttributeTargets.Assembly |
- AttributeTargets.Class |
- AttributeTargets.Constructor |
- AttributeTargets.Enum |
- AttributeTargets.Event |
- AttributeTargets.Field |
- AttributeTargets.Method |
- AttributeTargets.Module |
- AttributeTargets.Property |
- AttributeTargets.Struct,
- AllowMultiple = true, Inherited = false)]
-#if SYSTEM_PRIVATE_CORELIB
- public
-#else
- internal
-#endif
- sealed class ObsoletedInOSPlatformAttribute : OSPlatformAttribute
- {
- public ObsoletedInOSPlatformAttribute(string platformName) : base(platformName)
- {
- }
-
- public ObsoletedInOSPlatformAttribute(string platformName, string message) : base(platformName)
- {
- Message = message;
- }
-
- public string? Message { get; }
- public string? Url { get; set; }
- }
-
- /// <summary>
/// Marks APIs that were removed in a given operating system version.
/// </summary>
/// <remarks>
{
public SupportedOSPlatformAttribute(string platformName) : base(platformName) { }
}
- [System.AttributeUsageAttribute(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Enum | System.AttributeTargets.Event | System.AttributeTargets.Field | System.AttributeTargets.Method | System.AttributeTargets.Module | System.AttributeTargets.Property | System.AttributeTargets.Struct, AllowMultiple = true, Inherited = false)]
- public sealed class ObsoletedInOSPlatformAttribute : System.Runtime.Versioning.OSPlatformAttribute
- {
- public ObsoletedInOSPlatformAttribute(string platformName) : base(platformName) { }
- public ObsoletedInOSPlatformAttribute(string platformName, string message) : base(platformName) { }
- public string? Message { get; }
- public string? Url { get; set; }
- }
public abstract class OSPlatformAttribute : System.Attribute
{
private protected OSPlatformAttribute(string platformName) { }
}
[Theory]
- [InlineData("Windows8.0", "Obsolete", "http://test.com/obsoletedInOSPlatform")]
- [InlineData("Linux", "Message", null)]
- [InlineData("iOS13", null, null)]
- [InlineData("", null, "http://test.com/obsoletedInOSPlatform")]
- public void TestObsoletedInOSPlatformAttribute(string platformName, string message, string url)
- {
- var opa = message == null ? new ObsoletedInOSPlatformAttribute(platformName) { Url = url} : new ObsoletedInOSPlatformAttribute(platformName, message) { Url = url };
-
- Assert.Equal(platformName, opa.PlatformName);
- Assert.Equal(message, opa.Message);
- Assert.Equal(url, opa.Url);
- }
-
- [Theory]
[InlineData("Windows8.0")]
[InlineData("Android4.1")]
[InlineData("")]