Skip to content

Commit 39ea152

Browse files
committed
Use fixed compilers package to target Roslyn 4.3
- This effectively makes .NET 7 SDK irrelevant. It can be added later when migrating to .NET 7. - Add the problematic Trim Analyzer to $(NoWarn) instead of completely disabling it.
1 parent 8b13049 commit 39ea152

File tree

8 files changed

+40
-18
lines changed

8 files changed

+40
-18
lines changed

CommunityToolkit.Mvvm.SourceGenerators/CommunityToolkit.Mvvm.SourceGenerators.props

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,14 @@
2727
<MvvmToolkitSourceGeneratorRoslynPatchVersion>$(MSBuildProjectName.Substring($([MSBuild]::Subtract($(MSBuildProjectName.Length), 1)), 1))</MvvmToolkitSourceGeneratorRoslynPatchVersion>
2828
<MvvmToolkitSourceGeneratorRoslynVersion>$(MvvmToolkitSourceGeneratorRoslynMajorVersion).$(MvvmToolkitSourceGeneratorRoslynMinorVersion).$(MvvmToolkitSourceGeneratorRoslynPatchVersion)</MvvmToolkitSourceGeneratorRoslynVersion>
2929

30-
<!-- Workaround for https://github.com/dotnet/roslyn/issues/63919 -->
31-
<MvvmToolkitSourceGeneratorRoslynVersion Condition="'$(MvvmToolkitSourceGeneratorRoslynVersion)' == '4.3.0'">4.4.0-1.final</MvvmToolkitSourceGeneratorRoslynVersion>
32-
3330
<!-- Also define "ROSLYN_<MAJOR>_<MINOR>_OR_GREATER" build constants, so the generator code can multi-target whenever needed and add any required polyfills -->
3431
<DefineConstants Condition="$([MSBuild]::VersionGreaterThanOrEquals($(MvvmToolkitSourceGeneratorRoslynVersion), 4.3))">$(DefineConstants);ROSLYN_4_3_0_OR_GREATER</DefineConstants>
3532
</PropertyGroup>
3633

34+
<!-- Mark the package reference implicit so it won't get updated during manual packages update -->
3735
<ItemGroup>
38-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="$(MvvmToolkitSourceGeneratorRoslynVersion)" PrivateAssets="all" Pack="false" />
36+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="$(MvvmToolkitSourceGeneratorRoslynVersion)"
37+
PrivateAssets="All" Pack="false" IsImplicitlyDefined="true" />
3938
</ItemGroup>
4039

4140
</Project>

CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@
3636

3737
<!-- Enable trimming support on .NET 6 -->
3838
<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0'">
39-
40-
<!-- Temporarily disabled as a workaround for https://github.com/dotnet/linker/issues/3032 -->
41-
<EnableTrimAnalyzer>false</EnableTrimAnalyzer>
39+
40+
<!-- Workaround for https://github.com/dotnet/linker/issues/3032 -->
41+
<NoWarn>$(NoWarn);AD0001</NoWarn>
42+
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
4243
<IsTrimmable>true</IsTrimmable>
4344
</PropertyGroup>
4445

@@ -59,10 +60,9 @@
5960
<!--
6061
Pack the source generator to the right package folders (each matching the target Roslyn version).
6162
Roslyn will automatically load the highest version compatible with Roslyn's version in the SDK.
62-
The Roslyn 4.3 target is copied to the 4.4 folder as a workaround for https://github.com/dotnet/roslyn/issues/63919.
6363
-->
6464
<None Include="..\CommunityToolkit.Mvvm.SourceGenerators.Roslyn401\bin\$(Configuration)\netstandard2.0\CommunityToolkit.Mvvm.SourceGenerators.dll" PackagePath="analyzers\dotnet\roslyn4.0\cs" Pack="true" Visible="false" />
65-
<None Include="..\CommunityToolkit.Mvvm.SourceGenerators.Roslyn430\bin\$(Configuration)\netstandard2.0\CommunityToolkit.Mvvm.SourceGenerators.dll" PackagePath="analyzers\dotnet\roslyn4.4\cs" Pack="true" Visible="false" />
65+
<None Include="..\CommunityToolkit.Mvvm.SourceGenerators.Roslyn430\bin\$(Configuration)\netstandard2.0\CommunityToolkit.Mvvm.SourceGenerators.dll" PackagePath="analyzers\dotnet\roslyn4.3\cs" Pack="true" Visible="false" />
6666
</ItemGroup>
6767

6868
</Project>

Directory.Build.props

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,12 @@
4444
</When>
4545
</Choose>
4646

47+
<!--
48+
Fix for https://github.com/dotnet/roslyn/issues/63318
49+
Workaound for https://github.com/dotnet/roslyn/issues/63780
50+
-->
51+
<ItemGroup Condition="'$(ContinuousIntegrationBuild)' != 'true'">
52+
<PackageReference Include="Microsoft.NET.Compilers.ToolSet" Version="4.3.0-3.22470.13" PrivateAssets="All" />
53+
</ItemGroup>
54+
4755
</Project>

Directory.Build.rsp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-NoLogo
2+
-MaxCPUCount
3+
-NodeReuse:True
4+
-Verbosity:Normal

NuGet.config

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<configuration>
2+
<packageSources>
3+
<add key="dotnet-tools" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json"/>
4+
</packageSources>
5+
<packageSourceMapping>
6+
<packageSource key="nuget.org">
7+
<package pattern="*" />
8+
</packageSource>
9+
<packageSource key="dotnet-tools">
10+
<package pattern="Microsoft.NET.Compilers.ToolSet" />
11+
</packageSource>
12+
</packageSourceMapping>
13+
</configuration>

azure-pipelines.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,6 @@ jobs:
2020
timeoutInMinutes: 60
2121
steps:
2222

23-
# Install the .NET 7 SDK
24-
- task: UseDotNet@2
25-
displayName: Install the .NET 7 SDK
26-
inputs:
27-
version: 7.0.x
28-
includePreviewVersions: true
29-
performMultiLevelLookup: true
30-
3123
# Set Build Version
3224
- script: nbgv cloud
3325
displayName: Set NBGV version

global.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"sdk": {
3+
"version": "6.0.400",
4+
"rollForward": "latestFeature"
5+
}
6+
}

tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn430.UnitTests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn430.UnitTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<ItemGroup>
88
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.MSTest" Version="1.1.1" />
9-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.4.0-1.final" />
9+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.3.0" />
1010
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" />
1111
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
1212
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />

0 commit comments

Comments
 (0)