From c40d0e807e1406f3d5d0f871adfdce24f9d22d6a Mon Sep 17 00:00:00 2001 From: William Li Date: Mon, 29 Jun 2020 21:59:20 -0700 Subject: [PATCH 1/8] Add platform-specific attributes Spec https://github.com/dotnet/runtime/issues/33331 --- .../InteropServices/MinimumOSAttribute.cs | 38 +++++++++++++++++++ .../ObsoletedInPlatformAttribute.cs | 31 +++++++++++++++ .../InteropServices/PlatformAttribute.cs | 17 +++++++++ .../RemovedInPlatformAttribute.cs | 26 +++++++++++++ .../TargetPlatformAttribute.cs | 16 ++++++++ 5 files changed, 128 insertions(+) create mode 100644 src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MinimumOSAttribute.cs create mode 100644 src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ObsoletedInPlatformAttribute.cs create mode 100644 src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/PlatformAttribute.cs create mode 100644 src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RemovedInPlatformAttribute.cs create mode 100644 src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TargetPlatformAttribute.cs diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MinimumOSAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MinimumOSAttribute.cs new file mode 100644 index 0000000000000..7e572a942cf96 --- /dev/null +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MinimumOSAttribute.cs @@ -0,0 +1,38 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Runtime.InteropServices +{ + // Records the minimum platform that is required in order to the marked thing. + // + // * When applied to an assembly, it means the entire assembly cannot be called + // into on earlier versions. It records the TargetPlatformMinVersion property. + // + // * When applied to an API, it means the API cannot be called from an earlier + // version. + // + // In either case, the caller can either mark itself with MinimumPlatformAttribute + // or guard the call with a platform check. + // + // The attribute can be applied multiple times for different operating systems. + // That means the API is supported on multiple operating systems. + // + // A given platform should only be specified once. + + [AttributeUsage(AttributeTargets.Assembly | + AttributeTargets.Class | + AttributeTargets.Constructor | + AttributeTargets.Event | + AttributeTargets.Method | + AttributeTargets.Module | + AttributeTargets.Property | + AttributeTargets.Struct, + AllowMultiple = true, Inherited = false)] + public sealed class MinimumOSAttribute : PlatformAttribute + { + public MinimumOSAttribute(string platformName) : base(platformName) + { + } + } +} diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ObsoletedInPlatformAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ObsoletedInPlatformAttribute.cs new file mode 100644 index 0000000000000..d353a1ede7832 --- /dev/null +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ObsoletedInPlatformAttribute.cs @@ -0,0 +1,31 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Runtime.InteropServices +{ + // 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. + [AttributeUsage(AttributeTargets.Assembly | + AttributeTargets.Class | + AttributeTargets.Constructor | + AttributeTargets.Event | + AttributeTargets.Method | + AttributeTargets.Module | + AttributeTargets.Property | + AttributeTargets.Struct, + AllowMultiple = true, Inherited = false)] + public sealed class ObsoletedInPlatformAttribute : PlatformAttribute + { + public ObsoletedInPlatformAttribute(string platformName, string url, string message) : base(platformName) + { + Url = url; + Message = message; + } + + public string Url { get; set; } + public string Message { get; } + } +} diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/PlatformAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/PlatformAttribute.cs new file mode 100644 index 0000000000000..750139723332e --- /dev/null +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/PlatformAttribute.cs @@ -0,0 +1,17 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Runtime.InteropServices +{ + // Base type for all platform-specific attributes. Primarily used to allow grouping + // in documentation. + public abstract class PlatformAttribute : Attribute + { + internal PlatformAttribute(string platformName) + { + PlatformName = platformName; + } + public string PlatformName { get; } + } +} diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RemovedInPlatformAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RemovedInPlatformAttribute.cs new file mode 100644 index 0000000000000..07c22fbf33a1a --- /dev/null +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RemovedInPlatformAttribute.cs @@ -0,0 +1,26 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Runtime.InteropServices +{ + // Marks APIs that were removed in a given operating system version. + // + // Primarily used by OS bindings to indicate APIs that are only available in + // earlier versions. + [AttributeUsage(AttributeTargets.Assembly | + AttributeTargets.Class | + AttributeTargets.Constructor | + AttributeTargets.Event | + AttributeTargets.Method | + AttributeTargets.Module | + AttributeTargets.Property | + AttributeTargets.Struct, + AllowMultiple = true, Inherited = false)] + public sealed class RemovedInPlatformAttribute : PlatformAttribute + { + public RemovedInPlatformAttribute(string platformName) : base(platformName) + { + } + } +} diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TargetPlatformAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TargetPlatformAttribute.cs new file mode 100644 index 0000000000000..b04a478cb992a --- /dev/null +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TargetPlatformAttribute.cs @@ -0,0 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Runtime.InteropServices +{ + // Records the platform that the project targeted. + [AttributeUsage(AttributeTargets.Assembly, + AllowMultiple = false, Inherited = false)] + public sealed class TargetPlatformAttribute : PlatformAttribute + { + public TargetPlatformAttribute(string platformName) : base(platformName) + { + } + } +} From 74751693b8e0d24f4c22b141b36b272df8908abc Mon Sep 17 00:00:00 2001 From: William Li Date: Mon, 29 Jun 2020 22:42:45 -0700 Subject: [PATCH 2/8] Convert to xml doc --- .../InteropServices/MinimumOSAttribute.cs | 36 +++++++++++-------- .../ObsoletedInPlatformAttribute.cs | 10 +++--- .../InteropServices/PlatformAttribute.cs | 7 ++-- .../RemovedInPlatformAttribute.cs | 11 +++--- .../TargetPlatformAttribute.cs | 4 ++- 5 files changed, 42 insertions(+), 26 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MinimumOSAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MinimumOSAttribute.cs index 7e572a942cf96..d1a9e089b3015 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MinimumOSAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MinimumOSAttribute.cs @@ -4,22 +4,28 @@ namespace System.Runtime.InteropServices { - // Records the minimum platform that is required in order to the marked thing. - // - // * When applied to an assembly, it means the entire assembly cannot be called - // into on earlier versions. It records the TargetPlatformMinVersion property. - // - // * When applied to an API, it means the API cannot be called from an earlier - // version. - // - // In either case, the caller can either mark itself with MinimumPlatformAttribute - // or guard the call with a platform check. - // - // The attribute can be applied multiple times for different operating systems. - // That means the API is supported on multiple operating systems. - // - // A given platform should only be specified once. + /// + /// Records the minimum platform that is required in order to the marked thing. + /// + /// + /// When applied to an assembly, it means the entire assembly cannot be called + /// into on earlier versions. It records the TargetPlatformMinVersion property. + /// + /// + /// When applied to an API, it means the API cannot be called from an earlier + /// version. + /// + /// + /// + /// In either case, the caller can either mark itself with MinimumPlatformAttribute + /// or guard the call with a platform check. + /// + /// The attribute can be applied multiple times for different operating systems. + /// That means the API is supported on multiple operating systems. + /// + /// A given platform should only be specified once. + /// [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ObsoletedInPlatformAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ObsoletedInPlatformAttribute.cs index d353a1ede7832..35003199cf0a5 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ObsoletedInPlatformAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ObsoletedInPlatformAttribute.cs @@ -4,10 +4,12 @@ namespace System.Runtime.InteropServices { - // 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. + /// + /// 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. + /// [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/PlatformAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/PlatformAttribute.cs index 750139723332e..4637c73b51520 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/PlatformAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/PlatformAttribute.cs @@ -4,8 +4,11 @@ namespace System.Runtime.InteropServices { - // Base type for all platform-specific attributes. Primarily used to allow grouping - // in documentation. + + /// + /// Base type for all platform-specific attributes. Primarily used to allow grouping + /// in documentation. + /// public abstract class PlatformAttribute : Attribute { internal PlatformAttribute(string platformName) diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RemovedInPlatformAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RemovedInPlatformAttribute.cs index 07c22fbf33a1a..92164c31b7a51 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RemovedInPlatformAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RemovedInPlatformAttribute.cs @@ -4,10 +4,13 @@ namespace System.Runtime.InteropServices { - // Marks APIs that were removed in a given operating system version. - // - // Primarily used by OS bindings to indicate APIs that are only available in - // earlier versions. + + /// + /// Marks APIs that were removed in a given operating system version. + /// + /// Primarily used by OS bindings to indicate APIs that are only available in + /// earlier versions. + /// [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TargetPlatformAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TargetPlatformAttribute.cs index b04a478cb992a..5406d8982ec16 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TargetPlatformAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TargetPlatformAttribute.cs @@ -4,7 +4,9 @@ namespace System.Runtime.InteropServices { - // Records the platform that the project targeted. + /// + /// Records the platform that the project targeted. + /// [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)] public sealed class TargetPlatformAttribute : PlatformAttribute From a426eb20a25206c9d515c6669f51cdd75e41f6eb Mon Sep 17 00:00:00 2001 From: William Li Date: Tue, 30 Jun 2020 10:54:16 -0700 Subject: [PATCH 3/8] Update src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MinimumOSAttribute.cs Co-authored-by: Jeremy Barton --- .../src/System/Runtime/InteropServices/MinimumOSAttribute.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MinimumOSAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MinimumOSAttribute.cs index d1a9e089b3015..dbb13c54231ed 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MinimumOSAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MinimumOSAttribute.cs @@ -6,7 +6,7 @@ namespace System.Runtime.InteropServices { /// - /// Records the minimum platform that is required in order to the marked thing. + /// Records the minimum platform that is required in order to [something goes here] the marked thing. /// /// /// When applied to an assembly, it means the entire assembly cannot be called From 7df9b8d0e3ce7d5159d07be7d1117721f6fbb9e5 Mon Sep 17 00:00:00 2001 From: William Li Date: Tue, 30 Jun 2020 10:56:20 -0700 Subject: [PATCH 4/8] Update src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ObsoletedInPlatformAttribute.cs Co-authored-by: Jeff Handley --- .../Runtime/InteropServices/ObsoletedInPlatformAttribute.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ObsoletedInPlatformAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ObsoletedInPlatformAttribute.cs index 35003199cf0a5..61057a0c816d4 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ObsoletedInPlatformAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ObsoletedInPlatformAttribute.cs @@ -6,10 +6,11 @@ namespace System.Runtime.InteropServices { /// /// 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. - /// + /// [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | From e930a2bb7c3952251d4baaf59951b915a7a99371 Mon Sep 17 00:00:00 2001 From: William Li Date: Tue, 30 Jun 2020 11:13:23 -0700 Subject: [PATCH 5/8] Address code review --- .../InteropServices/MinimumOSAttribute.cs | 44 ------------------- .../MinimumOSPlatformAttribute.cs | 32 ++++++++++++++ ...ormAttribute.cs => OSPlatformAttribute.cs} | 8 ++-- ...e.cs => ObsoletedInOSPlatformAttribute.cs} | 16 ++++--- ...ute.cs => RemovedInOSPlatformAttribute.cs} | 10 ++--- .../TargetPlatformAttribute.cs | 2 +- 6 files changed, 50 insertions(+), 62 deletions(-) delete mode 100644 src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MinimumOSAttribute.cs create mode 100644 src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MinimumOSPlatformAttribute.cs rename src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/{PlatformAttribute.cs => OSPlatformAttribute.cs} (64%) rename src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/{ObsoletedInPlatformAttribute.cs => ObsoletedInOSPlatformAttribute.cs} (77%) rename src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/{RemovedInPlatformAttribute.cs => RemovedInOSPlatformAttribute.cs} (82%) diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MinimumOSAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MinimumOSAttribute.cs deleted file mode 100644 index dbb13c54231ed..0000000000000 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MinimumOSAttribute.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace System.Runtime.InteropServices -{ - - /// - /// Records the minimum platform that is required in order to [something goes here] the marked thing. - /// - /// - /// When applied to an assembly, it means the entire assembly cannot be called - /// into on earlier versions. It records the TargetPlatformMinVersion property. - /// - /// - /// When applied to an API, it means the API cannot be called from an earlier - /// version. - /// - /// - /// - /// In either case, the caller can either mark itself with MinimumPlatformAttribute - /// or guard the call with a platform check. - /// - /// The attribute can be applied multiple times for different operating systems. - /// That means the API is supported on multiple operating systems. - /// - /// A given platform should only be specified once. - /// - [AttributeUsage(AttributeTargets.Assembly | - AttributeTargets.Class | - AttributeTargets.Constructor | - AttributeTargets.Event | - AttributeTargets.Method | - AttributeTargets.Module | - AttributeTargets.Property | - AttributeTargets.Struct, - AllowMultiple = true, Inherited = false)] - public sealed class MinimumOSAttribute : PlatformAttribute - { - public MinimumOSAttribute(string platformName) : base(platformName) - { - } - } -} diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MinimumOSPlatformAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MinimumOSPlatformAttribute.cs new file mode 100644 index 0000000000000..54f0a7583095b --- /dev/null +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MinimumOSPlatformAttribute.cs @@ -0,0 +1,32 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Runtime.InteropServices +{ + /// + /// Records the operating system (and minimum version) that supports an API. Multiple attributes can be + /// applied to indicate support on multiple operating systems. + /// + /// + /// Callers can apply a + /// or use guards to prevent calls to APIs on unsupported operating systems. + /// + /// A given platform should only be specified once. + /// + [AttributeUsage(AttributeTargets.Assembly | + AttributeTargets.Class | + AttributeTargets.Constructor | + AttributeTargets.Event | + AttributeTargets.Method | + AttributeTargets.Module | + AttributeTargets.Property | + AttributeTargets.Struct, + AllowMultiple = true, Inherited = false)] + public sealed class MinimumOSPlatformAttribute : OSPlatformAttribute + { + public MinimumOSPlatformAttribute(string platformName) : base(platformName) + { + } + } +} diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/PlatformAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/OSPlatformAttribute.cs similarity index 64% rename from src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/PlatformAttribute.cs rename to src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/OSPlatformAttribute.cs index 4637c73b51520..8f0214acb49db 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/PlatformAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/OSPlatformAttribute.cs @@ -4,14 +4,12 @@ namespace System.Runtime.InteropServices { - /// - /// Base type for all platform-specific attributes. Primarily used to allow grouping - /// in documentation. + /// Base type for all platform-specific API attributes. /// - public abstract class PlatformAttribute : Attribute + public abstract class OSPlatformAttribute : Attribute { - internal PlatformAttribute(string platformName) + private protected OSPlatformAttribute(string platformName) { PlatformName = platformName; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ObsoletedInPlatformAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ObsoletedInOSPlatformAttribute.cs similarity index 77% rename from src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ObsoletedInPlatformAttribute.cs rename to src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ObsoletedInOSPlatformAttribute.cs index 61057a0c816d4..a67f360dfb578 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ObsoletedInPlatformAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ObsoletedInOSPlatformAttribute.cs @@ -6,11 +6,10 @@ namespace System.Runtime.InteropServices { /// /// 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. - /// + /// [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | @@ -20,15 +19,18 @@ namespace System.Runtime.InteropServices AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)] - public sealed class ObsoletedInPlatformAttribute : PlatformAttribute + public sealed class ObsoletedInOSPlatformAttribute : OSPlatformAttribute { - public ObsoletedInPlatformAttribute(string platformName, string url, string message) : base(platformName) + public ObsoletedInOSPlatformAttribute(string platformName) : base(platformName) + { + } + + public ObsoletedInOSPlatformAttribute(string platformName, string message) : base(platformName) { - Url = url; Message = message; } - public string Url { get; set; } public string Message { get; } + public string Url { get; set; } } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RemovedInPlatformAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RemovedInOSPlatformAttribute.cs similarity index 82% rename from src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RemovedInPlatformAttribute.cs rename to src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RemovedInOSPlatformAttribute.cs index 92164c31b7a51..01879fa99d6a8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RemovedInPlatformAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RemovedInOSPlatformAttribute.cs @@ -4,13 +4,13 @@ namespace System.Runtime.InteropServices { - /// /// Marks APIs that were removed in a given operating system version. - /// + /// + /// /// Primarily used by OS bindings to indicate APIs that are only available in /// earlier versions. - /// + /// [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | @@ -20,9 +20,9 @@ namespace System.Runtime.InteropServices AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)] - public sealed class RemovedInPlatformAttribute : PlatformAttribute + public sealed class RemovedInOSPlatformAttribute : OSPlatformAttribute { - public RemovedInPlatformAttribute(string platformName) : base(platformName) + public RemovedInOSPlatformAttribute(string platformName) : base(platformName) { } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TargetPlatformAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TargetPlatformAttribute.cs index 5406d8982ec16..b005c98cc343b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TargetPlatformAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TargetPlatformAttribute.cs @@ -9,7 +9,7 @@ namespace System.Runtime.InteropServices /// [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)] - public sealed class TargetPlatformAttribute : PlatformAttribute + public sealed class TargetPlatformAttribute : OSPlatformAttribute { public TargetPlatformAttribute(string platformName) : base(platformName) { From 94ac5982d8a84963e2640222fb1215ebf6fe7f0c Mon Sep 17 00:00:00 2001 From: Buyaa Namnan Date: Tue, 30 Jun 2020 18:10:55 -0700 Subject: [PATCH 6/8] Add to ref assembly, test and fix build errors --- .../System.Private.CoreLib.Shared.projitems | 5 ++ .../InteropServices/OSPlatformAttribute.cs | 2 + .../ObsoletedInOSPlatformAttribute.cs | 4 +- .../System.Runtime/ref/System.Runtime.cs | 31 ++++++++++ .../tests/System.Runtime.Tests.csproj | 61 ++++++------------- .../OSPlatformAttributeTests.cs | 55 +++++++++++++++++ 6 files changed, 114 insertions(+), 44 deletions(-) create mode 100644 src/libraries/System.Runtime/tests/System/Runtime/InteropServices/OSPlatformAttributeTests.cs diff --git a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems index 78f6a5ddbdd98..7e43ef90fb27c 100644 --- a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems +++ b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems @@ -764,10 +764,14 @@ + + + + @@ -775,6 +779,7 @@ + diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/OSPlatformAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/OSPlatformAttribute.cs index 8f0214acb49db..677c562f5b016 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/OSPlatformAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/OSPlatformAttribute.cs @@ -7,7 +7,9 @@ namespace System.Runtime.InteropServices /// /// Base type for all platform-specific API attributes. /// +#pragma warning disable CS3015 // Type has no accessible constructors which use only CLS-compliant types public abstract class OSPlatformAttribute : Attribute +#pragma warning restore CS3015 // Type has no accessible constructors which use only CLS-compliant types { private protected OSPlatformAttribute(string platformName) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ObsoletedInOSPlatformAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ObsoletedInOSPlatformAttribute.cs index a67f360dfb578..5d49f31016f67 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ObsoletedInOSPlatformAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ObsoletedInOSPlatformAttribute.cs @@ -30,7 +30,7 @@ public ObsoletedInOSPlatformAttribute(string platformName, string message) : bas Message = message; } - public string Message { get; } - public string Url { get; set; } + public string? Message { get; } + public string? Url { get; set; } } } diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index 6caea918b33e0..9a403445de835 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -9635,11 +9635,37 @@ public enum LayoutKind Explicit = 2, Auto = 3, } + [System.AttributeUsageAttribute(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Event | System.AttributeTargets.Method | System.AttributeTargets.Module | System.AttributeTargets.Property | System.AttributeTargets.Struct, AllowMultiple = true, Inherited = false)] + public sealed class MinimumOSPlatformAttribute : System.Runtime.InteropServices.OSPlatformAttribute + { + public MinimumOSPlatformAttribute(string platformName) : base(platformName) { } + } + [System.AttributeUsageAttribute(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Event | System.AttributeTargets.Method | System.AttributeTargets.Module | System.AttributeTargets.Property | System.AttributeTargets.Struct, AllowMultiple = true, Inherited = false)] + public sealed class ObsoletedInOSPlatformAttribute : System.Runtime.InteropServices.OSPlatformAttribute + { + public ObsoletedInOSPlatformAttribute(string platformName) : base(platformName) { } + public ObsoletedInOSPlatformAttribute(string platformName, string message) : base(platformName) { } + public string? Message { get; } + public string? Url { get; set; } + } +#pragma warning disable CS3015 // Type has no accessible constructors which use only CLS-compliant types + public abstract class OSPlatformAttribute : System.Attribute +#pragma warning restore CS3015 // Type has no accessible constructors which use only CLS-compliant types + { + private protected OSPlatformAttribute(string platformName) { } + public string PlatformName { get; } + } [System.AttributeUsageAttribute(System.AttributeTargets.Parameter, Inherited=false)] public sealed partial class OutAttribute : System.Attribute { public OutAttribute() { } } + [System.CLSCompliantAttribute(false)] + [System.AttributeUsageAttribute(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Event | System.AttributeTargets.Method | System.AttributeTargets.Module | System.AttributeTargets.Property | System.AttributeTargets.Struct, AllowMultiple = true, Inherited = false)] + public sealed class RemovedInOSPlatformAttribute : System.Runtime.InteropServices.OSPlatformAttribute + { + public RemovedInOSPlatformAttribute(string platformName) : base(platformName) { } + } public abstract partial class SafeBuffer : Microsoft.Win32.SafeHandles.SafeHandleZeroOrMinusOneIsInvalid { protected SafeBuffer(bool ownsHandle) : base (default(bool)) { } @@ -9695,6 +9721,11 @@ public sealed partial class SuppressGCTransitionAttribute : System.Attribute { public SuppressGCTransitionAttribute() { } } + [System.AttributeUsageAttribute(System.AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)] + public sealed class TargetPlatformAttribute : System.Runtime.InteropServices.OSPlatformAttribute + { + public TargetPlatformAttribute(string platformName) : base (platformName) { } + } } namespace System.Runtime.Remoting { diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests.csproj b/src/libraries/System.Runtime/tests/System.Runtime.Tests.csproj index a565661a5f401..6b751de5629de 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests.csproj +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests.csproj @@ -7,32 +7,19 @@ $(NetCoreAppCurrent)-Windows_NT;$(NetCoreAppCurrent)-Unix - - - - - - - - - - - - - + + + + + + + + + + + + + @@ -80,7 +67,6 @@ - @@ -117,6 +103,7 @@ + @@ -135,7 +122,6 @@ - @@ -228,8 +214,7 @@ - + @@ -242,31 +227,26 @@ - - + - + - + System.Reflection.Tests.EmbeddedImage.png System.Reflection.Tests.EmbeddedTextFile.txt - + @@ -275,7 +255,4 @@ - - - diff --git a/src/libraries/System.Runtime/tests/System/Runtime/InteropServices/OSPlatformAttributeTests.cs b/src/libraries/System.Runtime/tests/System/Runtime/InteropServices/OSPlatformAttributeTests.cs new file mode 100644 index 0000000000000..593b464ccf104 --- /dev/null +++ b/src/libraries/System.Runtime/tests/System/Runtime/InteropServices/OSPlatformAttributeTests.cs @@ -0,0 +1,55 @@ +using System.Diagnostics.CodeAnalysis; +using Xunit; + +namespace System.Runtime.InteropServices.Tests +{ + public class OSPlatformAttributeTests + { + [Theory] + [InlineData("Windows10.0")] + [InlineData("iOS")] + [InlineData("")] + public void TestTargetPlatformAttribute(string platformName) + { + var tpa = new TargetPlatformAttribute(platformName); + + Assert.Equal(platformName, tpa.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("")] + public void TestRemovedInOSPlatformAttribute(string platformName) + { + var tpa = new RemovedInOSPlatformAttribute(platformName); + + Assert.Equal(platformName, tpa.PlatformName); + } + + [Theory] + [InlineData("Windows10.0")] + [InlineData("OSX")] + [InlineData("")] + public void TestMinimumOSPlatformAttribute(string platformName) + { + var tpa = new MinimumOSPlatformAttribute(platformName); + + Assert.Equal(platformName, tpa.PlatformName); + } + } +} From c16ab651a10040c713e7e1f32b2eb536984fc279 Mon Sep 17 00:00:00 2001 From: Buyaa Namnan Date: Tue, 30 Jun 2020 18:24:02 -0700 Subject: [PATCH 7/8] Fix spacing, revert unwanted changes --- .../System.Private.CoreLib.Shared.projitems | 10 +-- .../tests/System.Runtime.Tests.csproj | 64 +++++++++++++------ 2 files changed, 49 insertions(+), 25 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems index 7e43ef90fb27c..a662c840d69de 100644 --- a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems +++ b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems @@ -764,14 +764,14 @@ - - + + - + - + @@ -779,7 +779,7 @@ - + diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests.csproj b/src/libraries/System.Runtime/tests/System.Runtime.Tests.csproj index 6b751de5629de..d17584b18c21c 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests.csproj +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests.csproj @@ -7,19 +7,32 @@ $(NetCoreAppCurrent)-Windows_NT;$(NetCoreAppCurrent)-Unix - - - - - - - - - - - - - + + + + + + + + + + + + + @@ -67,6 +80,7 @@ + @@ -103,7 +117,6 @@ - @@ -122,6 +135,7 @@ + @@ -204,6 +218,7 @@ + @@ -214,7 +229,8 @@ - + @@ -227,26 +243,31 @@ + - + - + - + System.Reflection.Tests.EmbeddedImage.png System.Reflection.Tests.EmbeddedTextFile.txt - + @@ -255,4 +276,7 @@ - + + + + \ No newline at end of file From d79d8330b6ad12891a68814acd081e6c12a11fca Mon Sep 17 00:00:00 2001 From: Buyaa Namnan Date: Tue, 30 Jun 2020 22:56:35 -0700 Subject: [PATCH 8/8] Namespace was wrong, updated --- .../System.Private.CoreLib.Shared.projitems | 10 +-- .../MinimumOSPlatformAttribute.cs | 4 +- .../OSPlatformAttribute.cs | 4 +- .../ObsoletedInOSPlatformAttribute.cs | 2 +- .../RemovedInOSPlatformAttribute.cs | 2 +- .../TargetPlatformAttribute.cs | 2 +- .../System.Runtime/ref/System.Runtime.cs | 61 +++++++++---------- .../tests/System.Runtime.Tests.csproj | 2 +- .../OSPlatformAttributeTests.cs | 2 +- 9 files changed, 44 insertions(+), 45 deletions(-) rename src/libraries/System.Private.CoreLib/src/System/Runtime/{InteropServices => Versioning}/MinimumOSPlatformAttribute.cs (89%) rename src/libraries/System.Private.CoreLib/src/System/Runtime/{InteropServices => Versioning}/OSPlatformAttribute.cs (81%) rename src/libraries/System.Private.CoreLib/src/System/Runtime/{InteropServices => Versioning}/ObsoletedInOSPlatformAttribute.cs (96%) rename src/libraries/System.Private.CoreLib/src/System/Runtime/{InteropServices => Versioning}/RemovedInOSPlatformAttribute.cs (96%) rename src/libraries/System.Private.CoreLib/src/System/Runtime/{InteropServices => Versioning}/TargetPlatformAttribute.cs (93%) rename src/libraries/System.Runtime/tests/System/Runtime/{InteropServices => Versioning}/OSPlatformAttributeTests.cs (97%) diff --git a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems index a662c840d69de..fcd3398d24589 100644 --- a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems +++ b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems @@ -764,14 +764,10 @@ - - - - @@ -779,7 +775,6 @@ - @@ -823,10 +818,15 @@ + + + + + diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MinimumOSPlatformAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/MinimumOSPlatformAttribute.cs similarity index 89% rename from src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MinimumOSPlatformAttribute.cs rename to src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/MinimumOSPlatformAttribute.cs index 54f0a7583095b..86df4b11d47f2 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MinimumOSPlatformAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/MinimumOSPlatformAttribute.cs @@ -2,14 +2,14 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace System.Runtime.InteropServices +namespace System.Runtime.Versioning { /// /// Records the operating system (and minimum version) that supports an API. Multiple attributes can be /// applied to indicate support on multiple operating systems. /// /// - /// Callers can apply a + /// Callers can apply a /// or use guards to prevent calls to APIs on unsupported operating systems. /// /// A given platform should only be specified once. diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/OSPlatformAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/OSPlatformAttribute.cs similarity index 81% rename from src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/OSPlatformAttribute.cs rename to src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/OSPlatformAttribute.cs index 677c562f5b016..7a91110132aa0 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/OSPlatformAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/OSPlatformAttribute.cs @@ -2,14 +2,14 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace System.Runtime.InteropServices +namespace System.Runtime.Versioning { /// /// Base type for all platform-specific API attributes. /// #pragma warning disable CS3015 // Type has no accessible constructors which use only CLS-compliant types public abstract class OSPlatformAttribute : Attribute -#pragma warning restore CS3015 // Type has no accessible constructors which use only CLS-compliant types +#pragma warning restore CS3015 { private protected OSPlatformAttribute(string platformName) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ObsoletedInOSPlatformAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/ObsoletedInOSPlatformAttribute.cs similarity index 96% rename from src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ObsoletedInOSPlatformAttribute.cs rename to src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/ObsoletedInOSPlatformAttribute.cs index 5d49f31016f67..0deaedcbc4ac6 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ObsoletedInOSPlatformAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/ObsoletedInOSPlatformAttribute.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace System.Runtime.InteropServices +namespace System.Runtime.Versioning { /// /// Marks APIs that were obsoleted in a given operating system version. diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RemovedInOSPlatformAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/RemovedInOSPlatformAttribute.cs similarity index 96% rename from src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RemovedInOSPlatformAttribute.cs rename to src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/RemovedInOSPlatformAttribute.cs index 01879fa99d6a8..a3e4e338c04e3 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RemovedInOSPlatformAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/RemovedInOSPlatformAttribute.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace System.Runtime.InteropServices +namespace System.Runtime.Versioning { /// /// Marks APIs that were removed in a given operating system version. diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TargetPlatformAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/TargetPlatformAttribute.cs similarity index 93% rename from src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TargetPlatformAttribute.cs rename to src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/TargetPlatformAttribute.cs index b005c98cc343b..ce148e2f4e84c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TargetPlatformAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/TargetPlatformAttribute.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace System.Runtime.InteropServices +namespace System.Runtime.Versioning { /// /// Records the platform that the project targeted. diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index 9a403445de835..dc3d863e359a5 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -9635,37 +9635,11 @@ public enum LayoutKind Explicit = 2, Auto = 3, } - [System.AttributeUsageAttribute(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Event | System.AttributeTargets.Method | System.AttributeTargets.Module | System.AttributeTargets.Property | System.AttributeTargets.Struct, AllowMultiple = true, Inherited = false)] - public sealed class MinimumOSPlatformAttribute : System.Runtime.InteropServices.OSPlatformAttribute - { - public MinimumOSPlatformAttribute(string platformName) : base(platformName) { } - } - [System.AttributeUsageAttribute(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Event | System.AttributeTargets.Method | System.AttributeTargets.Module | System.AttributeTargets.Property | System.AttributeTargets.Struct, AllowMultiple = true, Inherited = false)] - public sealed class ObsoletedInOSPlatformAttribute : System.Runtime.InteropServices.OSPlatformAttribute - { - public ObsoletedInOSPlatformAttribute(string platformName) : base(platformName) { } - public ObsoletedInOSPlatformAttribute(string platformName, string message) : base(platformName) { } - public string? Message { get; } - public string? Url { get; set; } - } -#pragma warning disable CS3015 // Type has no accessible constructors which use only CLS-compliant types - public abstract class OSPlatformAttribute : System.Attribute -#pragma warning restore CS3015 // Type has no accessible constructors which use only CLS-compliant types - { - private protected OSPlatformAttribute(string platformName) { } - public string PlatformName { get; } - } [System.AttributeUsageAttribute(System.AttributeTargets.Parameter, Inherited=false)] public sealed partial class OutAttribute : System.Attribute { public OutAttribute() { } } - [System.CLSCompliantAttribute(false)] - [System.AttributeUsageAttribute(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Event | System.AttributeTargets.Method | System.AttributeTargets.Module | System.AttributeTargets.Property | System.AttributeTargets.Struct, AllowMultiple = true, Inherited = false)] - public sealed class RemovedInOSPlatformAttribute : System.Runtime.InteropServices.OSPlatformAttribute - { - public RemovedInOSPlatformAttribute(string platformName) : base(platformName) { } - } public abstract partial class SafeBuffer : Microsoft.Win32.SafeHandles.SafeHandleZeroOrMinusOneIsInvalid { protected SafeBuffer(bool ownsHandle) : base (default(bool)) { } @@ -9721,11 +9695,6 @@ public sealed partial class SuppressGCTransitionAttribute : System.Attribute { public SuppressGCTransitionAttribute() { } } - [System.AttributeUsageAttribute(System.AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)] - public sealed class TargetPlatformAttribute : System.Runtime.InteropServices.OSPlatformAttribute - { - public TargetPlatformAttribute(string platformName) : base (platformName) { } - } } namespace System.Runtime.Remoting { @@ -9944,6 +9913,31 @@ public FrameworkName(string identifier, System.Version version, string? profile) public static bool operator !=(System.Runtime.Versioning.FrameworkName? left, System.Runtime.Versioning.FrameworkName? right) { throw null; } public override string ToString() { throw null; } } + [System.AttributeUsageAttribute(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Event | System.AttributeTargets.Method | System.AttributeTargets.Module | System.AttributeTargets.Property | System.AttributeTargets.Struct, AllowMultiple = true, Inherited = false)] + public sealed class MinimumOSPlatformAttribute : System.Runtime.Versioning.OSPlatformAttribute + { + public MinimumOSPlatformAttribute(string platformName) : base(platformName) { } + } + [System.AttributeUsageAttribute(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Event | 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; } + } +#pragma warning disable CS3015 // Type has no accessible constructors which use only CLS-compliant types + public abstract class OSPlatformAttribute : System.Attribute +#pragma warning restore CS3015 // Type has no accessible constructors which use only CLS-compliant types + { + private protected OSPlatformAttribute(string platformName) { } + public string PlatformName { get; } + } + [System.AttributeUsageAttribute(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Event | System.AttributeTargets.Method | System.AttributeTargets.Module | System.AttributeTargets.Property | System.AttributeTargets.Struct, AllowMultiple = true, Inherited = false)] + public sealed class RemovedInOSPlatformAttribute : System.Runtime.Versioning.OSPlatformAttribute + { + public RemovedInOSPlatformAttribute(string platformName) : base(platformName) { } + } [System.AttributeUsageAttribute(System.AttributeTargets.Constructor | System.AttributeTargets.Method | System.AttributeTargets.Property, Inherited=false)] [System.Diagnostics.ConditionalAttribute("RESOURCE_ANNOTATION_WORK")] public sealed partial class ResourceConsumptionAttribute : System.Attribute @@ -9978,6 +9972,11 @@ public TargetFrameworkAttribute(string frameworkName) { } public string? FrameworkDisplayName { get { throw null; } set { } } public string FrameworkName { get { throw null; } } } + [System.AttributeUsageAttribute(System.AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)] + public sealed class TargetPlatformAttribute : System.Runtime.Versioning.OSPlatformAttribute + { + public TargetPlatformAttribute(string platformName) : base(platformName) { } + } public static partial class VersioningHelper { public static string MakeVersionSafeName(string? name, System.Runtime.Versioning.ResourceScope from, System.Runtime.Versioning.ResourceScope to) { throw null; } diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests.csproj b/src/libraries/System.Runtime/tests/System.Runtime.Tests.csproj index d17584b18c21c..548ac964d8584 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests.csproj +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests.csproj @@ -218,10 +218,10 @@ - + diff --git a/src/libraries/System.Runtime/tests/System/Runtime/InteropServices/OSPlatformAttributeTests.cs b/src/libraries/System.Runtime/tests/System/Runtime/Versioning/OSPlatformAttributeTests.cs similarity index 97% rename from src/libraries/System.Runtime/tests/System/Runtime/InteropServices/OSPlatformAttributeTests.cs rename to src/libraries/System.Runtime/tests/System/Runtime/Versioning/OSPlatformAttributeTests.cs index 593b464ccf104..e642e946cfc53 100644 --- a/src/libraries/System.Runtime/tests/System/Runtime/InteropServices/OSPlatformAttributeTests.cs +++ b/src/libraries/System.Runtime/tests/System/Runtime/Versioning/OSPlatformAttributeTests.cs @@ -1,7 +1,7 @@ using System.Diagnostics.CodeAnalysis; using Xunit; -namespace System.Runtime.InteropServices.Tests +namespace System.Runtime.Versioning.Tests { public class OSPlatformAttributeTests {