Skip to content

Commit

Permalink
New BannedSymbols feature
Browse files Browse the repository at this point in the history
  • Loading branch information
scottbilas committed Dec 1, 2024
1 parent f161aac commit 76c2bc1
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/Core/BannedSymbols.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.BannedApiAnalyzers/BannedApiAnalyzers.Help.md
2 changes: 1 addition & 1 deletion src/Core/Core.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup><OkFeatures>T4;NetMulti</OkFeatures></PropertyGroup>
<PropertyGroup><OkFeatures>T4;NetMulti;BannedSymbols</OkFeatures></PropertyGroup>
<Import Project="$(OkTargetsRoot)Library.targets" />

<PropertyGroup>
Expand Down
6 changes: 6 additions & 0 deletions src/Terminal/BannedSymbols.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.BannedApiAnalyzers/BannedApiAnalyzers.Help.md

T:System.IO.Path;Use NiceIO NPath instead
T:System.IO.Directory;Use NiceIO NPath instead
M:System.Text.StringBuilder.AppendLine;Use AppendLf instead
M:System.Text.StringBuilder.AppendLine(System.String);Use AppendLf instead
3 changes: 2 additions & 1 deletion src/Terminal/Terminal.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup><OkFeatures>Core;NetMulti</OkFeatures></PropertyGroup>
<PropertyGroup><OkFeatures>Core;NetMulti;BannedSymbols</OkFeatures></PropertyGroup>
<Import Project="$(OkTargetsRoot)Library.targets" />

<PropertyGroup>
Expand All @@ -25,6 +25,7 @@
<None Include="../../LICENSE.md" Pack="true" PackagePath="/" />
</ItemGroup>

<!-- dependencies -->
<ItemGroup>
<PackageReference Include="docopt.net" />
<PackageReference Include="Spectre.Console" />
Expand Down
10 changes: 10 additions & 0 deletions targets/Library.targets
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@
<NoWarn>$(NoWarn);RS0030</NoWarn>
</PropertyGroup>

<!-- Feature: BannedSymbols -->

<ItemGroup Condition=" $(OkFeatures.Contains(';BannedSymbols;')) ">
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<!-- put this in the csproj also: <AdditionalFiles Include="BannedSymbols.txt"/> -->
</ItemGroup>

<!-- Feature: T4 -->
<!-- TEMPORARILY DISABLED - T4.Build does not support .NET 8 SDK, gets an error from a missing assembly.
just go with manual Rider-based T4 for now. -->
Expand Down

0 comments on commit 76c2bc1

Please sign in to comment.