File tree 12 files changed +51
-14
lines changed
12 files changed +51
-14
lines changed Original file line number Diff line number Diff line change 2
2
3
3
<Import Project =" $(BuildToolsDirectory)Community.Toolkit.Common.targets" />
4
4
5
+ <!--
6
+ The Git Version task from `Nerdbank.GitVersioning` overwrites the `InformationalVersion`
7
+ that was supposed to hold the `SourceRevisionId`. Hence, Add the `SourceRevisionId`
8
+ into Assembly Metadata with the `CommitHash` key.
9
+ -->
5
10
<Target Name =" AddCommitHashToAssemblyAttributes" BeforeTargets =" GetAssemblyAttributes" >
6
11
<ItemGroup >
7
12
<AssemblyAttribute Include =" System.Reflection.AssemblyMetadataAttribute" Condition =" '$(SourceRevisionId)' != ''" >
Original file line number Diff line number Diff line change 13
13
</PropertyGroup >
14
14
15
15
<!--
16
- Suppress ref safety warnings in unsafe contexts (see https://github.com/dotnet/csharplang/issues/6476).
17
- This is used eg. to replace Unsafe.SizeOf<T>() calls with just sizeof(T). The warning is not necessary
18
- since in order to use these APIs the caller already has to be in an unsafe context.
16
+ Suppress ` ref` usage safety warnings in unsafe contexts (see https://github.com/dotnet/csharplang/issues/6476).
17
+ This is used to replace ` Unsafe.*` calls with standard language notations (e.g., `Unsafe. SizeOf<T>()` to ` sizeof(T)`).
18
+ The `CS8500` warning is not necessary, since in order to use these APIs the caller already has to be in an unsafe context.
19
19
-->
20
20
<PropertyGroup >
21
21
<NoWarn >$(NoWarn);CS8500</NoWarn >
Original file line number Diff line number Diff line change 14
14
</PropertyGroup >
15
15
16
16
<PropertyGroup Condition =" '$(IsPackable)' == 'true'" >
17
- <!-- TODO: Dynamically generate Title if one wasn't set -->
18
17
<Title Condition =" '$(Title)' == ''" >$(Product) Asset</Title >
19
18
<PackageTags Condition =" '$(PackageTags)' != ''" >$(CommonTags);$(PackageTags)</PackageTags >
20
19
<PackageTags Condition =" '$(PackageTags)' == ''" >$(CommonTags)</PackageTags >
Original file line number Diff line number Diff line change 1
1
<Project >
2
2
3
- <!-- T4 service used by the Guard APIs -->
3
+ <!-- T4 text template service used by the Visual Studio project system -->
4
4
<ItemGroup >
5
5
<Service Include =" {508349b6-6b84-4df5-91f0-309beebad82d}" />
6
6
</ItemGroup >
7
7
8
+ <!-- Using T4 text templates to generate sources -->
8
9
<ItemGroup >
9
10
<None Update =" **\*.tt" >
10
11
<Generator >TextTemplatingFileGenerator</Generator >
11
12
<LastGenOutput >%(Filename).g.cs</LastGenOutput >
12
13
</None >
13
14
</ItemGroup >
14
15
16
+ <!-- Sources generated based on the above text templates -->
15
17
<ItemGroup >
16
18
<Compile Update =" **\*.g.cs" >
17
19
<AutoGen >True</AutoGen >
Original file line number Diff line number Diff line change 43
43
</When >
44
44
</Choose >
45
45
46
+ <!--
47
+ Adds support for generating sources using T4 text templating engine.
48
+ The Guard APIs in 'Generated' folder is generated using text templates.
49
+ -->
46
50
<Import Project =" $(BuildToolsDirectory)Community.Toolkit.TextTemplates.targets" />
47
51
48
52
</Project >
Original file line number Diff line number Diff line change 5
5
<TargetFramework >netstandard2.0</TargetFramework >
6
6
</PropertyGroup >
7
7
8
+ <!-- Sources that are used by Generator logic in the target projects -->
8
9
<ItemGroup >
9
10
<Compile Remove =" EmbeddedResources\*.cs" />
10
11
<EmbeddedResource Include =" EmbeddedResources\*.cs" >
14
15
</EmbeddedResource >
15
16
</ItemGroup >
16
17
18
+ <!--
19
+ These files enables tracking Analyzer releases for the rules that ship from this project.
20
+ See https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md for more info.
21
+ -->
17
22
<ItemGroup >
18
23
<AdditionalFiles Include =" AnalyzerReleases.Shipped.md" />
19
24
<AdditionalFiles Include =" AnalyzerReleases.Unshipped.md" />
Original file line number Diff line number Diff line change 5
5
<TargetFramework >netstandard2.0</TargetFramework >
6
6
</PropertyGroup >
7
7
8
+ <!-- Sources that are used by Generator logic in the target projects -->
8
9
<ItemGroup >
9
10
<Compile Remove =" EmbeddedResources\*.cs" />
10
11
<EmbeddedResource Include =" EmbeddedResources\*.cs" >
14
15
</EmbeddedResource >
15
16
</ItemGroup >
16
17
18
+ <!--
19
+ These files enables tracking Analyzer releases for the rules that ship from this project.
20
+ See https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md for more info.
21
+ -->
17
22
<ItemGroup >
18
23
<AdditionalFiles Include =" AnalyzerReleases.Shipped.md" />
19
24
<AdditionalFiles Include =" AnalyzerReleases.Unshipped.md" />
Original file line number Diff line number Diff line change 43
43
</ItemGroup >
44
44
45
45
<!--
46
- Include the custom . targets file to check the source generator.
47
- . NET 6 is not needed as it guarantees Roslyn 4.x .
46
+ Include a custom targets file to check the compiler version required for the source generator.
47
+ It needs Roslyn 4.x and including the targets in . NET 6+ is not needed as it guarantees the same .
48
48
-->
49
49
<ItemGroup >
50
50
<None Include =" CommunityToolkit.Mvvm.targets" Pack =" True" PackagePath =" build\netstandard2.0" />
74
74
</ItemGroup >
75
75
76
76
<!--
77
- Pack the source generator to the right package folders (each matching the target Roslyn version).
78
- Roslyn will automatically load the highest version compatible with Roslyn's version in the SDK.
77
+ Pack the source generator build outputs to the correct package folders (for each target Roslyn version)
78
+ for them to be used as analyzers. Roslyn compilers will automatically load the highest version compatible
79
+ with the Roslyn's version in the SDK.
80
+
81
+ HACK: The recommended way to pack is to get the build outputs using the project's built-in targets,
82
+ and include them using NuGet's Pack targets. However, due to a bug in v5 of those targets,
83
+ the outputs were not included in the package. So, including them directly via final
84
+ output path and building it first is the only way to ensure they are included.
79
85
-->
80
86
<ItemGroup >
81
87
<None Include =" ..\CommunityToolkit.Mvvm.SourceGenerators\bin\$(Configuration)\netstandard2.0-roslyn4.0\CommunityToolkit.Mvvm.SourceGenerators.dll" PackagePath =" analyzers\dotnet\roslyn4.0\cs" Pack =" true" Visible =" false" />
Original file line number Diff line number Diff line change 1
1
<Project >
2
2
3
- <!-- Get the analyzer from the CommunityToolkit.Mvvm NuGet package -->
3
+ <!-- Get the analyzer from the ' CommunityToolkit.Mvvm' NuGet package -->
4
4
<Target Name =" MVVMToolkitGatherAnalyzers" >
5
5
<ItemGroup >
6
6
<MVVMToolkitAnalyzer Include =" @(Analyzer)" Condition =" '%(Analyzer.NuGetPackageId)' == 'CommunityToolkit.Mvvm'" />
14
14
DependsOnTargets =" MVVMToolkitGatherAnalyzers" >
15
15
16
16
<!--
17
- Use the CSharpCoreTargetsPath property to find the version of the compiler we are using. This is the same mechanism
17
+ Use the ' CSharpCoreTargetsPath' property to find the version of the compiler we are using. This is the same mechanism
18
18
MSBuild uses to find the compiler. We could check the assembly version for any compiler assembly (since they all have
19
- the same version) but Microsoft.Build.Tasks.CodeAnalysis.dll is where MSBuild loads the compiler tasks from so if
19
+ the same version) but ' Microsoft.Build.Tasks.CodeAnalysis.dll' is where MSBuild loads the compiler tasks from so if
20
20
someone is getting creative with msbuild tasks/targets this is the "most correct" assembly to check.
21
21
-->
22
22
<GetAssemblyIdentity AssemblyFiles =" $([System.IO.Path]::Combine($([System.IO.Path]::GetDirectoryName($(CSharpCoreTargetsPath))), 'Microsoft.Build.Tasks.CodeAnalysis.dll'))" >
23
23
<Output TaskParameter =" Assemblies" ItemName =" MVVMToolkitCurrentCompilerAssemblyIdentity" />
24
24
</GetAssemblyIdentity >
25
25
26
26
<PropertyGroup >
27
- <!-- Transform the resulting item from GetAssemblyIdentity into a property representing its assembly version -->
27
+ <!-- Transform the resulting item from ' GetAssemblyIdentity' task into a property representing its assembly version -->
28
28
<MVVMToolkitCurrentCompilerVersion >@(MVVMToolkitCurrentCompilerAssemblyIdentity->'%(Version)')</MVVMToolkitCurrentCompilerVersion >
29
29
30
- <!-- The CurrentCompilerVersionIsNotNewEnough property can now be defined based on the Roslyn assembly version -->
30
+ <!-- The 'MVVMToolkitCurrentCompilerVersionIsNotNewEnough' property can now be defined based on the Roslyn assembly version -->
31
31
<MVVMToolkitCurrentCompilerVersionIsNotNewEnough Condition =" $([MSBuild]::VersionLessThan($(MVVMToolkitCurrentCompilerVersion), 4.0))" >true</MVVMToolkitCurrentCompilerVersionIsNotNewEnough >
32
32
</PropertyGroup >
33
33
Original file line number Diff line number Diff line change 2
2
3
3
<Import Project =" ..\$(MSBuildThisFile)" />
4
4
5
+ <!-- Common properties for all projects under src folder -->
5
6
<PropertyGroup >
6
7
<IsPackable >true</IsPackable >
7
8
<IsPublishable >true</IsPublishable >
Original file line number Diff line number Diff line change 2
2
3
3
<Import Project =" ..\$(MSBuildThisFile)" />
4
4
5
+ <!-- Configure defaults for projects targeting .NET 6 and above -->
5
6
<PropertyGroup Condition =" '$(_NET_6_OR_GREATER)' == 'true'" >
7
+ <!-- Enable trimming on supported targets -->
6
8
<IsTrimmable >true</IsTrimmable >
7
9
<EnableTrimAnalyzer >true</EnableTrimAnalyzer >
10
+ <!-- Define `NETSTANDARD2_1_OR_GREATER` to include .NET Standard 2.1 shared APIs -->
8
11
<DefineConstants >NETSTANDARD2_1_OR_GREATER</DefineConstants >
9
12
</PropertyGroup >
10
13
14
+ <!-- Common Assembly and Module attributes across projects -->
11
15
<ItemGroup >
12
16
<Compile Include =" $(BuildToolsDirectory)AssemblyInfo.Shared.cs" LinkBase =" Properties" Visible =" False" />
13
17
</ItemGroup >
Original file line number Diff line number Diff line change 2
2
3
3
<Import Project =" ..\$(MSBuildThisFile)" />
4
4
5
+ <!--
6
+ By default, all projects under tests are neither packed nor published.
7
+ This also includes non-test projects as well. But if it's required then
8
+ override the following properties only within those projects.
9
+ -->
5
10
<PropertyGroup >
6
11
<IsPackable >false</IsPackable >
7
12
<IsPublishable >false</IsPublishable >
10
15
11
16
<PropertyGroup >
12
17
<IsTestProject >true</IsTestProject >
18
+ <!-- The MVVM Toolkit unit tests use `Mvvm.ExternalAssembly` project as a `ProjectReference` for testing -->
13
19
<IsTestProject Condition =" $(MSBuildProjectName.Contains('Mvvm.ExternalAssembly'))" >false</IsTestProject >
14
20
</PropertyGroup >
15
21
You can’t perform that action at this time.
0 commit comments