Skip to content

Commit d05f5f9

Browse files
committed
Unify use of public API analyzers across projects
1 parent 7b32a5f commit d05f5f9

File tree

6 files changed

+30
-16
lines changed

6 files changed

+30
-16
lines changed

Funcky.Async/Funcky.Async.csproj

+1-6
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@
3030
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">
3131
<IsAotCompatible>true</IsAotCompatible>
3232
</PropertyGroup>
33-
<!-- These files are included by Microsoft.CodeAnalysis.PublicApiAnalyzers is included. -->
34-
<ItemGroup Condition="'$(TargetFramework)' != '$(FunckyNewestTargetFramework)'">
35-
<AdditionalFiles Include="PublicAPI.Shipped.txt" />
36-
<AdditionalFiles Include="PublicAPI.Unshipped.txt" />
37-
</ItemGroup>
3833
<ItemGroup>
3934
<Compile Include="..\Funcky\Internal\Aggregators\DecimalAverageAggregator.cs" Link="Internal\Aggregators\DecimalAverageAggregator.cs" />
4035
<Compile Include="..\Funcky\Internal\Aggregators\DoubleAverageAggregator.cs" Link="Internal\Aggregators\DoubleAverageAggregator.cs" />
@@ -49,7 +44,6 @@
4944
<Compile Include="..\Funcky\Internal\PartitionBuilder.cs" Link="Internal\PartitionBuilder.cs" />
5045
</ItemGroup>
5146
<ItemGroup>
52-
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" PrivateAssets="all" Condition="'$(TargetFramework)' == '$(FunckyNewestTargetFramework)'" />
5347
<PackageReference Include="PolySharp" PrivateAssets="all" />
5448
<PackageReference Include="Polyadic.Build.SemanticVersioning" PrivateAssets="all" />
5549
<PackageReference Include="System.Linq.Async" />
@@ -64,4 +58,5 @@
6458
<Import Project="..\Analyzers.props" />
6559
<Import Project="..\GlobalUsings.props" />
6660
<Import Project="..\FrameworkFeatureConstants.props" />
61+
<Import Project="..\PublicApiAnalyzers.targets" />
6762
</Project>

Funcky.Xunit.v3/Funcky.Xunit.v3.csproj

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
3+
<FunckyNewestTargetFramework>net6.0</FunckyNewestTargetFramework>
4+
<TargetFrameworks>$(FunckyNewestTargetFramework);netstandard2.0</TargetFrameworks>
45
<LangVersion>preview</LangVersion>
56
<Nullable>enable</Nullable>
67
<Description>Package to use Funcky with xUnit v3</Description>
@@ -36,7 +37,6 @@
3637
<PackageReference Include="Polyadic.Build.SemanticVersioning" PrivateAssets="all" />
3738
<PackageReference Include="xunit.v3.assert" />
3839
<PackageReference Include="xunit.v3.extensibility.core" />
39-
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" PrivateAssets="all" Condition="'$(TargetFramework)' == 'net6.0'" />
4040
</ItemGroup>
4141
<ItemGroup>
4242
<ProjectReference Include="../Funcky/Funcky.csproj" />
@@ -46,4 +46,5 @@
4646
</ItemGroup>
4747
<Import Project="..\Analyzers.props" />
4848
<Import Project="..\GlobalUsings.props" />
49+
<Import Project="..\PublicApiAnalyzers.targets" />
4950
</Project>

Funcky.Xunit/Funcky.Xunit.csproj

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
3+
<FunckyNewestTargetFramework>net6.0</FunckyNewestTargetFramework>
4+
<TargetFrameworks>$(FunckyNewestTargetFramework);netstandard2.0</TargetFrameworks>
45
<LangVersion>preview</LangVersion>
56
<Nullable>enable</Nullable>
67
<Description>Package to use Funcky with xUnit</Description>
@@ -24,7 +25,6 @@
2425
<PackageReference Include="Polyadic.Build.SemanticVersioning" PrivateAssets="all" />
2526
<PackageReference Include="xunit.assert" />
2627
<PackageReference Include="xunit.extensibility.core" />
27-
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" PrivateAssets="all" Condition="'$(TargetFramework)' == 'net6.0'" />
2828
</ItemGroup>
2929
<ItemGroup>
3030
<ProjectReference Include="../Funcky/Funcky.csproj" />
@@ -35,4 +35,5 @@
3535
</ItemGroup>
3636
<Import Project="..\Analyzers.props" />
3737
<Import Project="..\GlobalUsings.props" />
38+
<Import Project="..\PublicApiAnalyzers.targets" />
3839
</Project>

Funcky.sln

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build Config", "Build Confi
2727
GlobalUsings.Test.props = GlobalUsings.Test.props
2828
NuGet.config = NuGet.config
2929
typos.toml = typos.toml
30+
PublicApiAnalyzers.targets = PublicApiAnalyzers.targets
3031
EndProjectSection
3132
EndProject
3233
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Funcky.Xunit", "Funcky.Xunit\Funcky.Xunit.csproj", "{F2E98B0D-CC17-4576-89DE-065FF475BE6E}"

Funcky/Funcky.csproj

+1-6
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
<DefineConstants>$(DefineConstants);CONTRACTS_FULL</DefineConstants>
2424
</PropertyGroup>
2525
<ItemGroup>
26-
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" PrivateAssets="all" Condition="'$(TargetFramework)' == '$(FunckyNewestTargetFramework)'" />
2726
<PackageReference Include="Microsoft.Bcl.HashCode" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
2827
<PackageReference Include="PolySharp" PrivateAssets="all" />
2928
<PackageReference Include="System.Collections.Immutable" Condition="'$(TargetFramework)' == 'netstandard2.0' Or '$(TargetFramework)' == 'netstandard2.1'" />
@@ -34,11 +33,6 @@
3433
<ItemGroup>
3534
<ProjectReference Include="..\Funcky.SourceGenerator\Funcky.SourceGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" PrivateAssets="all" />
3635
</ItemGroup>
37-
<!-- These files are included by Microsoft.CodeAnalysis.PublicApiAnalyzers is included. -->
38-
<ItemGroup Condition="'$(TargetFramework)' != '$(FunckyNewestTargetFramework)'">
39-
<AdditionalFiles Include="PublicAPI.Shipped.txt" />
40-
<AdditionalFiles Include="PublicAPI.Unshipped.txt" />
41-
</ItemGroup>
4236
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">
4337
<IsTrimmable>true</IsTrimmable>
4438
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
@@ -63,4 +57,5 @@
6357
<Import Project="..\Analyzers.props" />
6458
<Import Project="..\GlobalUsings.props" />
6559
<Import Project="..\FrameworkFeatureConstants.props" />
60+
<Import Project="..\PublicApiAnalyzers.targets" />
6661
</Project>

PublicApiAnalyzers.targets

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Condition="'$(TargetFramework)' == '$(FunckyNewestTargetFramework)'">
4+
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" PrivateAssets="all" />
5+
</ItemGroup>
6+
<!-- These files are included by Microsoft.CodeAnalysis.PublicApiAnalyzers if it is enabled. -->
7+
<ItemGroup Condition="'$(TargetFramework)' != '$(FunckyNewestTargetFramework)'">
8+
<AdditionalFiles Include="PublicAPI.Shipped.txt" />
9+
<AdditionalFiles Include="PublicAPI.Unshipped.txt" />
10+
</ItemGroup>
11+
<PropertyGroup>
12+
<CoreCompileDependsOn>$(CoreCompileDependsOn);_ValidateFunckyNewestTargetFrameworkIsSet</CoreCompileDependsOn>
13+
</PropertyGroup>
14+
<Target Name="_ValidateFunckyNewestTargetFrameworkIsSet" Condition="'$(FunckyNewestTargetFramework)' == ''">
15+
<PropertyGroup>
16+
<_Text>The 'FunckyNewestTargetFramework' property is not set; public API analyzers will not run</_Text>
17+
</PropertyGroup>
18+
<Warning Text="$(_Text)" File="$(MSBuildProjectFullPath)" Condition="'$(TreatWarningsAsErrors)' != 'true'" />
19+
<Error Text="$(_Text)" File="$(MSBuildProjectFullPath)" Condition="'$(TreatWarningsAsErrors)' == 'true'" />
20+
</Target>
21+
</Project>

0 commit comments

Comments
 (0)