Skip to content

Commit 492a823

Browse files
keegan-carusoKeegan Carusowestin-m
authored
Enable PublicApiAnalyzers (#2782)
* Enable PublicApiAnalyzers See: https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md Remove apiCompat files. Include internals as there are friend assemblies. * Add mark-shipped.ps1 * update changes to internal api --------- Co-authored-by: Keegan Caruso <keegancaruso@microsoft.com> Co-authored-by: Westin Musser <127992899+westin-m@users.noreply.github.com> Co-authored-by: Westin Musser <westinmusser@microsoft.com>
1 parent 83b7118 commit 492a823

103 files changed

Lines changed: 5891 additions & 81 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,16 @@ csharp_space_between_square_brackets = false
157157
dotnet_code_quality.ca1802.api_surface = private, internal
158158
dotnet_code_quality.CA2208.api_surface = public
159159

160+
# https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/Microsoft.CodeAnalysis.PublicApiAnalyzers.md
161+
dotnet_diagnostic.RS0051.severity = error
162+
dotnet_diagnostic.RS0052.severity = error
163+
dotnet_diagnostic.RS0053.severity = error
164+
dotnet_diagnostic.RS0054.severity = error
165+
dotnet_diagnostic.RS0055.severity = error
166+
dotnet_diagnostic.RS0057.severity = error
167+
dotnet_diagnostic.RS0058.severity = error
168+
dotnet_diagnostic.RS0061.severity = error
169+
160170
# RS0030: Do not used banned APIs
161171
dotnet_diagnostic.RS0030.severity = error
162172

@@ -184,6 +194,9 @@ dotnet_diagnostic.CA1845.severity = warning
184194
# CA1846: Prefer AsSpan over Substring
185195
dotnet_diagnostic.CA1846.severity = warning
186196

197+
# RS0037: Enable tracking of nullability of reference types in the declared API
198+
dotnet_diagnostic.RS0037.severity = silent
199+
187200
[{GlobalSuppressions.cs,TrimmingAttributes.cs}]
188201
dotnet_diagnostic.IDE0073.severity = none
189202

Tools/apiCompat/ApiCompatExcludeAttributeList.txt

Whitespace-only changes.

Tools/apiCompat/baseline/ApiCompatBaseline.net461.txt

Lines changed: 0 additions & 19 deletions
This file was deleted.

Tools/apiCompat/baseline/ApiCompatBaseline.net462.txt

Lines changed: 0 additions & 11 deletions
This file was deleted.

Tools/apiCompat/baseline/ApiCompatBaseline.net472.txt

Lines changed: 0 additions & 11 deletions
This file was deleted.

Tools/apiCompat/baseline/ApiCompatBaseline.net6.0.txt

Lines changed: 0 additions & 17 deletions
This file was deleted.

Tools/apiCompat/baseline/ApiCompatBaseline.netstandard2.0.txt

Lines changed: 0 additions & 21 deletions
This file was deleted.

Tools/mark-shipped.ps1

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
[CmdletBinding(PositionalBinding=$false)]
2+
param ()
3+
4+
Set-StrictMode -version 2.0
5+
$ErrorActionPreference = "Stop"
6+
7+
function MarkShipped([string]$dir) {
8+
$shippedFilePath = Join-Path $dir "PublicAPI.Shipped.txt"
9+
$shipped = @()
10+
$shipped += Get-Content $shippedFilePath
11+
12+
$unshippedFilePath = Join-Path $dir "PublicAPI.Unshipped.txt"
13+
$unshipped = Get-Content $unshippedFilePath
14+
$removed = @()
15+
$removedPrefix = "*REMOVED*";
16+
Write-Host "Processing $dir"
17+
18+
foreach ($item in $unshipped) {
19+
if ($item.Length -gt 0) {
20+
if ($item.StartsWith($removedPrefix)) {
21+
$item = $item.Substring($removedPrefix.Length)
22+
$removed += $item
23+
}
24+
else {
25+
$shipped += $item
26+
}
27+
}
28+
}
29+
30+
$shipped | Sort-Object -Unique |Where-Object { -not $removed.Contains($_) } | Out-File $shippedFilePath -Encoding Ascii
31+
Clear-Content $unshippedFilePath
32+
}
33+
34+
try {
35+
foreach ($file in Get-ChildItem -re -in "PublicApi.Shipped.txt") {
36+
$dir = Split-Path -parent $file
37+
MarkShipped $dir
38+
}
39+
}
40+
catch {
41+
Write-Host $_
42+
Write-Host $_.Exception
43+
exit 1
44+
}

build/common.props

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@
6868
</PackageReference>
6969
</ItemGroup>
7070

71+
<ItemGroup>
72+
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.4">
73+
<PrivateAssets>all</PrivateAssets>
74+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
75+
</PackageReference>
76+
</ItemGroup>
77+
7178
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">
7279
<IsAotCompatible>true</IsAotCompatible>
7380
</PropertyGroup>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+


0 commit comments

Comments
 (0)