Skip to content

Commit

Permalink
Centralize common CsWinRT options
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio0694 committed Sep 19, 2024
1 parent 57f0a9b commit a79f376
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 38 deletions.
22 changes: 22 additions & 0 deletions build/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,28 @@
MSBuildAllProjects, as that is done by the file that imports us.
-->

<!--
Additional global options for all projects targeting Windows in their TFMs.
These must be in a .targets file because they need to read 'TargetFramework'.
-->
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0-windows'))">

<!--
Enable the CsWinRT trim/AOT analyzer for scenarios involving all types (including built-in types).
The .NET SDK sets this to '1' (which excludes built-in types) by default to reduce false positives.
-->
<CsWinRTAotWarningLevel>2</CsWinRTAotWarningLevel>

<!--
We're only referencing CsWinRT for the source generators, we don't need to read any WinRT metadata.
CsWinRT is in projection mode by default, so we want to disable it (or it'd need the Windows SDK).
-->
<CsWinRTGenerateProjection>false</CsWinRTGenerateProjection>

<!-- We'll never have any IIDs to patch in this library -->
<CsWinRTIIDOptimizerOptOut>true</CsWinRTIIDOptimizerOptOut>
</PropertyGroup>

<!--
Manually set the version if null. This is copied from Microsoft.NET.DefaultAssemblyInfo.targets and is needed
for cases where that target is not being automatically imported (which happens because MSBuild is used instead
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,6 @@
<MvvmToolkitEnableINotifyPropertyChangingSupport>false</MvvmToolkitEnableINotifyPropertyChangingSupport>
</PropertyGroup>

<!-- Additional CsWinRT properties (temporary, until the .NET SDK is updated) -->
<PropertyGroup>

<!--
We're only referencing CsWinRT for the source generators, we don't need to read any WinRT metadata.
CsWinRT is in projection mode by default, so we want to disable it (or it'd need the Windows SDK).
-->
<CsWinRTGenerateProjection>false</CsWinRTGenerateProjection>

<!-- We'll never have any IIDs to patch in this library -->
<CsWinRTIIDOptimizerOptOut>true</CsWinRTIIDOptimizerOptOut>

<!-- Enable AOT warnings for types implementing projected WinRT interfaces mapped to built-in types (eg. 'INotifyPropertyChanged') -->
<CsWinRTAotWarningLevel>2</CsWinRTAotWarningLevel>
</PropertyGroup>

<!-- CsWinRT size saving options -->
<PropertyGroup>
<CsWinRTEnableDynamicObjectsSupport>false</CsWinRTEnableDynamicObjectsSupport>
Expand Down
3 changes: 0 additions & 3 deletions src/ComputeSharp.D2D1.Uwp/ComputeSharp.D2D1.Uwp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@

<PropertyGroup>

<!-- Also disabled in 'ComputeSharp.D2D1.WinUI', see notes there -->
<CsWinRTIIDOptimizerOptOut>true</CsWinRTIIDOptimizerOptOut>

<!-- Same warnings as in 'ComputeSharp.D2D1.WinUI', see notes there -->
<NoWarn>$(NoWarn);CS0419</NoWarn>
<NoWarn>$(NoWarn);IDE0065</NoWarn>
Expand Down
7 changes: 0 additions & 7 deletions src/ComputeSharp.D2D1.WinUI/ComputeSharp.D2D1.WinUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@

<PropertyGroup>

<!--
Disable IIDOptimizer, as it's causing a build error when the debug mode is set to embedded.
This is only needed when generating projections anyway, and not in normal C# class libraries.
See: https://github.com/microsoft/CsWinRT/issues/1478.
-->
<CsWinRTIIDOptimizerOptOut>true</CsWinRTIIDOptimizerOptOut>

<!--
Ignore some warnings about ambiguous cref attribute references. These are because the assembly defines
blittable bindings for several ABI types from Win2D, in the same namespace as the ABI types from the
Expand Down
6 changes: 0 additions & 6 deletions src/ComputeSharp.Uwp/ComputeSharp.Uwp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@
<DefineConstants>$(DefineConstants);WINDOWS_UWP</DefineConstants>
</PropertyGroup>

<PropertyGroup>

<!-- Disable IIDOptimizer, as it's not needed (see comments in ComputeSharp.D2D1.WinUI)-->
<CsWinRTIIDOptimizerOptOut>true</CsWinRTIIDOptimizerOptOut>
</PropertyGroup>

<ItemGroup>

<!-- Reference CsWinRT locally for the source generators (see comments in ComputeSharp.D2D1.WinUI) -->
Expand Down
6 changes: 0 additions & 6 deletions src/ComputeSharp.WinUI/ComputeSharp.WinUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@
<WebView2EnableCsWinRTProjectionExcludeCoreRef>true</WebView2EnableCsWinRTProjectionExcludeCoreRef>
</PropertyGroup>

<PropertyGroup>

<!-- Disable IIDOptimizer, as it's not needed (see comments in ComputeSharp.D2D1.WinUI)-->
<CsWinRTIIDOptimizerOptOut>true</CsWinRTIIDOptimizerOptOut>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240829007" />

Expand Down

0 comments on commit a79f376

Please sign in to comment.