Skip to content

Commit b89f76a

Browse files
committed
Refactor WinRT metadata attributes and conditionals
Adjust conditional compilation and attribute placement for WinRT metadata types. Add conditional import of System.Runtime.Versioning and split ApiContractAttribute between implementation (WindowsRuntimeMetadata) and reference (SupportedOSPlatform + ContractVersion) builds, moving AttributeUsage to a shared location. Do the same reordering for ContractVersionAttribute, and remove redundant remarks comments from FoundationContract and UniversalApiContract to clean up source.
1 parent 0805548 commit b89f76a

4 files changed

Lines changed: 8 additions & 10 deletions

File tree

src/WinRT.Runtime2/Windows.Foundation/FoundationContract.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ namespace Windows.Foundation;
1010
/// <summary>
1111
/// Represents the Windows Foundation API contract.
1212
/// </summary>
13-
/// <remarks>
14-
/// This type is required for ABI projection of the value types and delegates, but marshalling it is not supported.
15-
/// </remarks>
1613
#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY
1714
[ApiContract]
1815
[ContractVersion(262144u)]

src/WinRT.Runtime2/Windows.Foundation/Metadata/ApiContractAttribute.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,21 @@
22
// Licensed under the MIT License.
33

44
using System;
5+
#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY
56
using System.Runtime.Versioning;
7+
#endif
68
using WindowsRuntime;
79

810
namespace Windows.Foundation.Metadata;
911

1012
/// <summary>
1113
/// Specifies that the type represents an API contract.
1214
/// </summary>
15+
#if WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY
1316
[WindowsRuntimeMetadata("Windows.Foundation.FoundationContract")]
14-
[AttributeUsage(AttributeTargets.Enum, AllowMultiple = false)]
17+
#elif WINDOWS_RUNTIME_REFERENCE_ASSEMBLY
1518
[SupportedOSPlatform("Windows10.0.10240.0")]
1619
[ContractVersion(typeof(FoundationContract), 65536u)]
20+
#endif
21+
[AttributeUsage(AttributeTargets.Enum, AllowMultiple = false)]
1722
public sealed class ApiContractAttribute : Attribute;

src/WinRT.Runtime2/Windows.Foundation/Metadata/ContractVersionAttribute.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@ namespace Windows.Foundation.Metadata;
1616
/// </summary>
1717
#if WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY
1818
[WindowsRuntimeMetadata("Windows.Foundation.FoundationContract")]
19-
#endif
20-
[AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
21-
#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY
19+
#elif WINDOWS_RUNTIME_REFERENCE_ASSEMBLY
2220
[SupportedOSPlatform("Windows10.0.10240.0")]
2321
[ContractVersion(typeof(FoundationContract), 65536u)]
2422
#endif
23+
[AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
2524
public sealed class ContractVersionAttribute : Attribute
2625
{
2726
/// <summary>

src/WinRT.Runtime2/Windows.Foundation/UniversalApiContract.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ namespace Windows.Foundation;
1010
/// <summary>
1111
/// Represents the Universal API contract.
1212
/// </summary>
13-
/// <remarks>
14-
/// This type is required for ABI projection of the value types and delegates, but marshalling it is not supported.
15-
/// </remarks>
1613
#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY
1714
[ApiContract]
1815
[ContractVersion(1245184u)]

0 commit comments

Comments
 (0)