Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Directory.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
<PropertyGroup Label="NuGet">
<PackageTags>dotnet roslyn</PackageTags>
<PackOnBuild>true</PackOnBuild>
<PackFolder>analyzers/dotnet/cs</PackFolder>
<ThisAssemblyMinimumRoslynVersion>4.0</ThisAssemblyMinimumRoslynVersion>
<PackFolder>analyzers/dotnet/roslyn$(ThisAssemblyMinimumRoslynVersion)/cs</PackFolder>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<RestoreSources>https://api.nuget.org/v3/index.json</RestoreSources>
<RestoreSources Condition="Exists('$(MSBuildThisFileDirectory)..\..\nugetizer\bin\')">$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\..\nugetizer\bin'));$(RestoreSources)</RestoreSources>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<PropertyGroup>
<PackageId>ThisAssembly.AssemblyInfo</PackageId>
<Description>** C# 9.0+ ONLY **
<Description>
This package generates a static `ThisAssembly.Info` class with public
constants exposing the following attribute values generated by default for SDK style projects:

Expand Down
2 changes: 1 addition & 1 deletion src/ThisAssembly.Constants/ThisAssembly.Constants.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<PropertyGroup>
<PackageId>ThisAssembly.Constants</PackageId>
<Description>** C# 9.0+ ONLY **
<Description>
This package generates a static `ThisAssembly.Constants` class with public
constants for each Constant MSBuild item in the project.

Expand Down
2 changes: 1 addition & 1 deletion src/ThisAssembly.Metadata/ThisAssembly.Metadata.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<PropertyGroup>
<PackageId>ThisAssembly.Metadata</PackageId>
<Description>** C# 9.0+ ONLY **
<Description>
This package generates a static `ThisAssembly.Metadata` class with public
constants exposing each `[System.Reflection.AssemblyMetadata(..)]` defined for the project,
such as when using .NET 5.0+ support for `AssemblyMetadata` MSBuild items.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@

<PropertyGroup>
<PackageId>ThisAssembly.Prerequisites</PackageId>
<Description>Ensures that referencing project satisfies the prerequisites for ThisAssembly, namely:

* MSBuild 16.8+: contains the Roslyn support for source generators
* C# 9.0 or greater language: it's the only language supported by Roslyn source generators at the moment.
</Description>
<Description>Ensures that referencing project is using a compatible Compiler API (Roslyn).</Description>
</PropertyGroup>

<ItemGroup>
Expand Down
10 changes: 6 additions & 4 deletions src/ThisAssembly.Prerequisites/ThisAssembly.Prerequisites.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<Project>

<ItemGroup>
<CompilerVisibleProperty Include="DebugSourceGenerators" />
</ItemGroup>

<PropertyGroup>
<!-- Incremental source generator interface appeared first on Roslyn 4.0.1, see
https://learn.microsoft.com/en-us/dotnet/api/microsoft.codeanalysis.iincrementalgenerator?view=roslyn-dotnet-4.0.1 -->
<ThisAssemblyMinimumRoslynVersion>4.0</ThisAssemblyMinimumRoslynVersion>
</PropertyGroup>

</Project>
25 changes: 14 additions & 11 deletions src/ThisAssembly.Prerequisites/ThisAssembly.Prerequisites.targets
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
<Project>

<Target Name="EnsureSourceGenerators" BeforeTargets="BeforeCompile;CoreCompile">
<Target Name="_ThisAssemblyCheckCompilerVersion" BeforeTargets="CoreCompile">

<Error Text="ThisAssembly requires MSBuild 16.8+ or .NET SDK 5.0+."
Condition="$([System.Version]::Parse('16.8.0').CompareTo($([System.Version]::Parse($(MSBuildVersion))))) == 1" />
<!-- Version comparison functions require MSBuild 16.5+ -->
<Error Text="ThisAssembly requires MSBuild 16.5 or greater."
Condition="$([System.Version]::Parse('16.5.0').CompareTo($([System.Version]::Parse($(MSBuildVersion))))) == 1" />

<!-- See https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/langversion-compiler-option -->
<Warning Code="THIS001"
Text="ThisAssembly uses Roslyn source generators, which are only supported in C# 9.0 or greater at the moment."
Condition="'$(Language)' != 'C#' OR
('$(LangVersion)' != 'preview' AND
'$(LangVersion)' != 'latest' AND
'$(LangVersion)' != 'latestMajor' AND
'$(LangVersion)' &lt; '9.0')" />
<PropertyGroup>
<!-- CompilerApiVersion comes from Microsoft.Managed.Core.CurrentVersions.targets -->
<RoslynVersion Condition="'$(CompilerApiVersion)' != ''">$(CompilerApiVersion.Substring(6))</RoslynVersion>
<RoslynVersion Condition="'$(RoslynVersion)' == ''">0.0</RoslynVersion>
</PropertyGroup>

<!-- -->
<Warning Code="THIS001"
Text="ThisAssembly requires Compiler API (Roslyn) version $(ThisAssemblyMinimumRoslynVersion) or greater."
Condition="$([MSBuild]::VersionLessThan('$(RoslynVersion)', '$(ThisAssemblyMinimumRoslynVersion)'))" />
</Target>

</Project>
2 changes: 1 addition & 1 deletion src/ThisAssembly.Project/ThisAssembly.Project.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<PropertyGroup>
<PackageId>ThisAssembly.Project</PackageId>
<Description>** C# 9.0+ ONLY **
<Description>
This package generates a static `ThisAssembly.Project` class with public
constants exposing project properties that have been opted into this mechanism by adding
them as `ProjectProperty` MSBuild items in project file, such as:
Expand Down
1 change: 0 additions & 1 deletion src/ThisAssembly.Resources/ThisAssembly.Resources.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
<PropertyGroup>
<PackageId>ThisAssembly.Resources</PackageId>
<Description>
** C# 9.0+ ONLY **
This package generates a static `ThisAssembly.Resources` class with public
properties exposing `string` and `Stream` shortcuts to access embedded resources.
</Description>
Expand Down
2 changes: 1 addition & 1 deletion src/ThisAssembly.Strings/ThisAssembly.Strings.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<PropertyGroup>
<PackageId>ThisAssembly.Strings</PackageId>
<Description>** C# 9.0+ ONLY **
<Description>
This package generates a static `ThisAssembly.Strings` class with public
constants exposing string resources in .resx files or methods with the right number of
parameters for strings that use formatting parameters.
Expand Down
9 changes: 0 additions & 9 deletions src/ThisAssembly.Tests/ThisAssembly.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<TargetFramework Condition="'$(BuildingInsideVisualStudio)' == 'true'">net472</TargetFramework>
<RootNamespace>ThisAssemblyTests</RootNamespace>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<GetTargetPathDependsOn>$(GetTargetPathDependsOn);GetDependencyTargetPaths</GetTargetPathDependsOn>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
</PropertyGroup>

Expand Down Expand Up @@ -64,14 +63,6 @@
<ItemGroup>
<Compile Include="..\ThisAssembly.Strings\Model.cs" Link="Model.cs" />
</ItemGroup>

<Target Name="GetDependencyTargetPaths" Returns="@(TargetPathWithTargetPlatformMoniker)">
<ItemGroup>
<!--<TargetPathWithTargetPlatformMoniker Include="$(PKGCsvTextFieldParser)\lib\netstandard2.0\CsvTextFieldParser.dll" IncludeRuntimeDependency="false" />
<TargetPathWithTargetPlatformMoniker Include="$(PKGHandlebars_Net)\lib\netstandard2.0\Handlebars.dll" IncludeRuntimeDependency="false" />
<TargetPathWithTargetPlatformMoniker Include="$(PKGNewtonsoft_Json)\lib\netstandard2.0\Newtonsoft.Json.dll" IncludeRuntimeDependency="false" />-->
</ItemGroup>
</Target>

<Import Project="..\*\*.targets" />

Expand Down
4 changes: 2 additions & 2 deletions src/ThisAssembly/ThisAssembly.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<PropertyGroup>
<PackageId>ThisAssembly</PackageId>
<Description>Meta-package that includes all ThisAssembly.* packages. ** C# 9.0 ONLY **</Description>
<Description>Meta-package that includes all ThisAssembly.* packages.</Description>
</PropertyGroup>

<ItemGroup>
Expand All @@ -26,11 +26,11 @@

<ItemGroup>
<ProjectReference Include="..\ThisAssembly.AssemblyInfo\ThisAssembly.AssemblyInfo.csproj" PrivateAssets="none" />
<ProjectReference Include="..\ThisAssembly.Constants\ThisAssembly.Constants.csproj" PrivateAssets="none" />
<ProjectReference Include="..\ThisAssembly.Metadata\ThisAssembly.Metadata.csproj" PrivateAssets="none" />
<ProjectReference Include="..\ThisAssembly.Project\ThisAssembly.Project.csproj" PrivateAssets="none" />
<ProjectReference Include="..\ThisAssembly.Resources\ThisAssembly.Resources.csproj" PrivateAssets="none" />
<ProjectReference Include="..\ThisAssembly.Strings\ThisAssembly.Strings.csproj" PrivateAssets="none" />
<ProjectReference Include="..\ThisAssembly.Constants\ThisAssembly.Constants.csproj" PrivateAssets="none" />
</ItemGroup>

</Project>