Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable PublicApiAnalyzers #2782

Merged
merged 5 commits into from
Oct 7, 2024
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
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,16 @@ csharp_space_between_square_brackets = false
dotnet_code_quality.ca1802.api_surface = private, internal
dotnet_code_quality.CA2208.api_surface = public

# https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/Microsoft.CodeAnalysis.PublicApiAnalyzers.md
dotnet_diagnostic.RS0051.severity = error
keegan-caruso marked this conversation as resolved.
Show resolved Hide resolved
dotnet_diagnostic.RS0052.severity = error
dotnet_diagnostic.RS0053.severity = error
dotnet_diagnostic.RS0054.severity = error
dotnet_diagnostic.RS0055.severity = error
dotnet_diagnostic.RS0057.severity = error
dotnet_diagnostic.RS0058.severity = error
keegan-caruso marked this conversation as resolved.
Show resolved Hide resolved
dotnet_diagnostic.RS0061.severity = error

# RS0030: Do not used banned APIs
dotnet_diagnostic.RS0030.severity = error

Expand Down Expand Up @@ -184,6 +194,9 @@ dotnet_diagnostic.CA1845.severity = warning
# CA1846: Prefer AsSpan over Substring
dotnet_diagnostic.CA1846.severity = warning

# RS0037: Enable tracking of nullability of reference types in the declared API
dotnet_diagnostic.RS0037.severity = silent

[{GlobalSuppressions.cs,TrimmingAttributes.cs}]
dotnet_diagnostic.IDE0073.severity = none

Expand Down
Empty file.
19 changes: 0 additions & 19 deletions Tools/apiCompat/baseline/ApiCompatBaseline.net461.txt

This file was deleted.

11 changes: 0 additions & 11 deletions Tools/apiCompat/baseline/ApiCompatBaseline.net462.txt

This file was deleted.

11 changes: 0 additions & 11 deletions Tools/apiCompat/baseline/ApiCompatBaseline.net472.txt

This file was deleted.

17 changes: 0 additions & 17 deletions Tools/apiCompat/baseline/ApiCompatBaseline.net6.0.txt

This file was deleted.

21 changes: 0 additions & 21 deletions Tools/apiCompat/baseline/ApiCompatBaseline.netstandard2.0.txt

This file was deleted.

44 changes: 44 additions & 0 deletions Tools/mark-shipped.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[CmdletBinding(PositionalBinding=$false)]
param ()

Set-StrictMode -version 2.0
$ErrorActionPreference = "Stop"

function MarkShipped([string]$dir) {
$shippedFilePath = Join-Path $dir "PublicAPI.Shipped.txt"
$shipped = @()
$shipped += Get-Content $shippedFilePath

$unshippedFilePath = Join-Path $dir "PublicAPI.Unshipped.txt"
$unshipped = Get-Content $unshippedFilePath
$removed = @()
$removedPrefix = "*REMOVED*";
Write-Host "Processing $dir"

foreach ($item in $unshipped) {
if ($item.Length -gt 0) {
if ($item.StartsWith($removedPrefix)) {
$item = $item.Substring($removedPrefix.Length)
$removed += $item
}
else {
$shipped += $item
}
}
}

$shipped | Sort-Object -Unique |Where-Object { -not $removed.Contains($_) } | Out-File $shippedFilePath -Encoding Ascii
Clear-Content $unshippedFilePath
}

try {
foreach ($file in Get-ChildItem -re -in "PublicApi.Shipped.txt") {
$dir = Split-Path -parent $file
MarkShipped $dir
}
}
catch {
Write-Host $_
Write-Host $_.Exception
exit 1
}
7 changes: 7 additions & 0 deletions build/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@
</PackageReference>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.4">
keegan-caruso marked this conversation as resolved.
Show resolved Hide resolved
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">
<IsAotCompatible>true</IsAotCompatible>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Loading
Loading