|
79 | 79 | <AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile> |
80 | 80 | </PropertyGroup> |
81 | 81 |
|
82 | | - <!-- |
83 | | - Disable the default 'ProduceReferenceAssembly' behavior. WinRT.Runtime provides its own custom |
84 | | - reference assembly (built with 'CsWinRTBuildReferenceAssembly=true') that strips private implementation |
85 | | - detail types via '#if WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY'. The SDK-generated ref assembly would |
86 | | - include those types (since 'WINDOWS_RUNTIME_REFERENCE_ASSEMBLY' is not defined in normal builds), which |
87 | | - would leak abstract members to downstream ProjectReference consumers and break reference projections. |
88 | | - --> |
| 82 | + <!-- Settings for the implementation assembly --> |
89 | 83 | <PropertyGroup Condition="'$(CsWinRTBuildReferenceAssembly)' != 'true'"> |
| 84 | + |
| 85 | + <!-- |
| 86 | + Disable the default 'ProduceReferenceAssembly' behavior. WinRT.Runtime provides its own custom |
| 87 | + reference assembly (built with 'CsWinRTBuildReferenceAssembly=true') that strips private implementation |
| 88 | + detail types via '#if WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY'. The SDK-generated ref assembly would |
| 89 | + include those types (since 'WINDOWS_RUNTIME_REFERENCE_ASSEMBLY' is not defined in normal builds), which |
| 90 | + would leak abstract members to downstream ProjectReference consumers and break reference projections. |
| 91 | + --> |
90 | 92 | <ProduceReferenceAssembly>false</ProduceReferenceAssembly> |
91 | 93 |
|
92 | 94 | <!-- Build constant to simplify '#ifdef'-s, so they don't need negation expressions --> |
93 | 95 | <DefineConstants>$(DefineConstants);WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY</DefineConstants> |
| 96 | + <WarningsAsErrors>$(WarningsAsErrors);RS0030</WarningsAsErrors> |
94 | 97 | </PropertyGroup> |
95 | 98 |
|
96 | | - <!-- |
97 | | - When producing a reference assembly for packaging, define 'WINDOWS_RUNTIME_REFERENCE_ASSEMBLY'. This is used |
98 | | - to completely strip out the private implementation detail types from the reference assembly, so they're |
99 | | - further hidden. This is conditioned on 'CsWinRTBuildReferenceAssembly' (and NOT 'ProduceReferenceAssembly'), |
100 | | - because 'ProduceReferenceAssembly' is set to 'true' by default by the .NET SDK for library projects. The |
101 | | - stripping should only happen during the explicit reference assembly build step for NuGet packaging. |
102 | | - --> |
| 99 | + <!-- Settings for the reference assembly --> |
103 | 100 | <PropertyGroup Condition="'$(CsWinRTBuildReferenceAssembly)' == 'true'"> |
| 101 | + |
| 102 | + <!-- |
| 103 | + When producing a reference assembly for packaging, define 'WINDOWS_RUNTIME_REFERENCE_ASSEMBLY'. This is used |
| 104 | + to completely strip out the private implementation detail types from the reference assembly, so they're |
| 105 | + further hidden. This is conditioned on 'CsWinRTBuildReferenceAssembly' (and NOT 'ProduceReferenceAssembly'), |
| 106 | + because 'ProduceReferenceAssembly' is set to 'true' by default by the .NET SDK for library projects. The |
| 107 | + stripping should only happen during the explicit reference assembly build step for NuGet packaging. |
| 108 | + --> |
104 | 109 | <DefineConstants>$(DefineConstants);WINDOWS_RUNTIME_REFERENCE_ASSEMBLY</DefineConstants> |
105 | 110 |
|
106 | 111 | <!-- |
|
111 | 116 | - IDE0380: 'unsafe' modifier is unnecessary (some types have 'unsafe' for excluded members). |
112 | 117 | --> |
113 | 118 | <NoWarn>$(NoWarn);CS8597;IDE0005;IDE0380</NoWarn> |
| 119 | + |
| 120 | + <!-- Always make the banned API analyzer warnings errors, since these should always be blocking --> |
| 121 | + <WarningsAsErrors>$(WarningsAsErrors);RS0030</WarningsAsErrors> |
114 | 122 | </PropertyGroup> |
| 123 | + <ItemGroup Condition="'$(CsWinRTBuildReferenceAssembly)' == 'true'"> |
| 124 | + |
| 125 | + <!-- Include the banned API list, for the implementation-only marker attribute --> |
| 126 | + <None Remove="BannedSymbols.txt" /> |
| 127 | + <AdditionalFiles Include="BannedSymbols.txt" /> |
| 128 | + |
| 129 | + <!-- Include the banned API analyzer, which we use to block implementation-only types in the reference assembly --> |
| 130 | + <PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" PrivateAssets="all" /> |
| 131 | + </ItemGroup> |
115 | 132 |
|
116 | 133 | <!-- |
117 | 134 | Strip all files whose top-level type is annotated with '[WindowsRuntimeImplementationOnlyMember]' |
|
0 commit comments