Skip to content

Commit 09d7c4a

Browse files
authored
Adding publicAPI, bannedApi, and Async analyzers (#136)
* Adding publicAPI, bannedApi, and Async analyzers * Moving the public API to shipped (so far) * Update dotnetcore.yml Updating GiHub action Signed-off-by: Jean-Marc Prieur <[email protected]> * Removing internal analyzers' * Address PR feedback --------- Signed-off-by: Jean-Marc Prieur <[email protected]>
1 parent 5d2d6fb commit 09d7c4a

17 files changed

+1154
-106
lines changed

.editorconfig

+21-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ insert_final_newline = true
1212
indent_style = space
1313
indent_size = 4
1414
dotnet_diagnostic.CA1308.severity=warning
15+
dotnet_style_operator_placement_when_wrapping = beginning_of_line
16+
tab_width = 4
17+
end_of_line = crlf
18+
dotnet_style_coalesce_expression = true:suggestion
19+
dotnet_style_null_propagation = true:suggestion
20+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
21+
dotnet_style_prefer_auto_properties = true:silent
22+
dotnet_diagnostic.RS0026.severity = suggestion
23+
dotnet_diagnostic.RS0027.severity = suggestion
1524

1625
[project.json]
1726
indent_size = 2
@@ -52,7 +61,7 @@ dotnet_style_predefined_type_for_member_access = true:suggestion
5261
# name all constant fields using PascalCase
5362
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
5463
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
55-
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
64+
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
5665

5766
dotnet_naming_symbols.constant_fields.applicable_kinds = field
5867
dotnet_naming_symbols.constant_fields.required_modifiers = const
@@ -62,7 +71,7 @@ dotnet_naming_style.pascal_case_style.capitalization = pascal_case
6271
# static fields should have s_ prefix
6372
dotnet_naming_rule.static_fields_should_have_prefix.severity = suggestion
6473
dotnet_naming_rule.static_fields_should_have_prefix.symbols = static_fields
65-
dotnet_naming_rule.static_fields_should_have_prefix.style = static_prefix_style
74+
dotnet_naming_rule.static_fields_should_have_prefix.style = static_prefix_style
6675

6776
dotnet_naming_symbols.static_fields.applicable_kinds = field
6877
dotnet_naming_symbols.static_fields.required_modifiers = static
@@ -73,7 +82,7 @@ dotnet_naming_style.static_prefix_style.capitalization = camel_case
7382
# internal and private fields should be _camelCase
7483
dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion
7584
dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields
76-
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
85+
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
7786

7887
dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
7988
dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal
@@ -532,6 +541,15 @@ dotnet_diagnostic.SA1642.severity = none
532541

533542
## SA1649: File name should match first type name
534543
dotnet_diagnostic.SA1649.severity = none
544+
csharp_using_directive_placement = outside_namespace:silent
545+
csharp_prefer_simple_using_statement = true:suggestion
546+
csharp_prefer_braces = true:silent
547+
csharp_style_namespace_declarations = block_scoped:silent
548+
csharp_style_prefer_method_group_conversion = true:silent
549+
csharp_style_prefer_top_level_statements = true:silent
550+
csharp_style_prefer_primary_constructors = true:suggestion
551+
csharp_style_expression_bodied_lambdas = true:silent
552+
csharp_style_expression_bodied_local_functions = false:silent
535553
#########################################################
536554
#########################################################
537555

.github/workflows/dotnetcore.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
name: Abstractions GitHub Action Test
1010
steps:
1111
- name: Checkout repository
12-
uses: actions/checkout@v2.3.4
12+
uses: actions/checkout@v4.1.7
1313
- name: Setup .NET 8.0.x
1414
uses: actions/[email protected]
1515
with:

Directory.Build.props

+75-56
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,82 @@
11
<Project>
2-
<PropertyGroup>
3-
<!--This should be passed from the VSTS build-->
4-
<MicrosoftIdentityAbstractionsVersion Condition="'$(MicrosoftIdentityAbstractionsVersion)' == ''">6.0.0-local</MicrosoftIdentityAbstractionsVersion>
5-
<!--This will generate AssemblyVersion, AssemblyFileVersion and AssemblyInformationVersion-->
6-
<Version>$(MicrosoftIdentityAbstractionsVersion)</Version>
2+
<PropertyGroup>
3+
<!-- This should be passed from the VSTS build -->
4+
<MicrosoftIdentityAbstractionsVersion Condition="'$(MicrosoftIdentityAbstractionsVersion)' == ''">7.0.1</MicrosoftIdentityAbstractionsVersion>
5+
<!-- This will generate AssemblyVersion, AssemblyFileVersion and AssemblyInformationVersion -->
6+
<Version>$(MicrosoftIdentityAbstractionsVersion)</Version>
7+
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)\build\35MSSharedLib1024.snk</AssemblyOriginatorKeyFile>
8+
<RepositoryType>git</RepositoryType>
9+
<Authors>Microsoft</Authors>
10+
<Company>Microsoft Corporation</Company>
11+
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
12+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
13+
<PackageProjectUrl>https://github.com/AzureAD/microsoft-identity-abstractions-for-dotnet</PackageProjectUrl>
14+
<RepositoryUrl>https://github.com/AzureAD/microsoft-identity-abstractions-for-dotnet</RepositoryUrl>
15+
<PackageReleaseNotes>The release notes are available at https://github.com/AzureAD/microsoft-identity-abstractions-for-dotnet/releases and the roadmap at https://github.com/AzureAD/microsoft-identity-abstractions-for-dotnet/wiki#roadmap </PackageReleaseNotes>
16+
<PackageTags>Microsoft Identity Abstractions for dotnet;Microsoft identity platform;Microsoft Identity Web;.NET;ASP.NET Core;Web App;Web API;B2C;Azure Active Directory;AAD;Identity;Authentication;Authorization</PackageTags>
17+
<DefineConstants>$(DefineConstants);WEB</DefineConstants>
18+
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
19+
</PropertyGroup>
20+
21+
<PropertyGroup>
22+
<TargetFrameworks>netstandard2.0;netstandard2.1;net462;net8.0</TargetFrameworks>
23+
<SignAssembly>true</SignAssembly>
24+
<AssemblyOriginatorKeyFile>../../build/MSAL.snk</AssemblyOriginatorKeyFile>
25+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
26+
<Nullable>enable</Nullable>
27+
<LangVersion>12</LangVersion>
28+
<EnablePackageValidation>true</EnablePackageValidation>
29+
<PackageValidationBaselineVersion>7.0.0</PackageValidationBaselineVersion>
30+
<BannedApiAnalyzersVersion>3.3.4</BannedApiAnalyzersVersion>
31+
<MicrosoftCodeAnalysisPublicApiAnalyzers>3.3.4</MicrosoftCodeAnalysisPublicApiAnalyzers>
32+
<MicrosoftCodeAnalysisNetAnalyzersVersion>8.0.0</MicrosoftCodeAnalysisNetAnalyzersVersion>
33+
</PropertyGroup>
734

8-
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)\build\35MSSharedLib1024.snk</AssemblyOriginatorKeyFile>
9-
<RepositoryType>git</RepositoryType>
10-
<Authors>Microsoft</Authors>
11-
<Company>Microsoft Corporation</Company>
12-
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
13-
<PackageLicenseExpression>MIT</PackageLicenseExpression>
14-
<PackageProjectUrl>https://github.com/AzureAD/microsoft-identity-abstractions-for-dotnet</PackageProjectUrl>
15-
<RepositoryUrl>https://github.com/AzureAD/microsoft-identity-abstractions-for-dotnet</RepositoryUrl>
16-
<PackageReleaseNotes>The release notes are available at https://github.com/AzureAD/microsoft-identity-abstractions-for-dotnet/releases and the roadmap at https://github.com/AzureAD/microsoft-identity-abstractions-for-dotnet/wiki#roadmap </PackageReleaseNotes>
17-
<PackageTags>Microsoft Identity Abstractions for dotnet;Microsoft identity platform;Microsoft Identity Web;.NET;ASP.NET Core;Web App;Web API;B2C;Azure Active Directory;AAD;Identity;Authentication;Authorization</PackageTags>
18-
<DefineConstants>$(DefineConstants);WEB</DefineConstants>
19-
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
20-
</PropertyGroup>
35+
<PropertyGroup Label="Source Link">
36+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
37+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
38+
<!-- Build symbol package (.snupkg) to distribute the PDB containing Source Link -->
39+
<IncludeSymbols>true</IncludeSymbols>
40+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
41+
<!-- The MSAL.snk has both private and public keys -->
42+
<DelaySign>false</DelaySign>
43+
<EnableNETAnalyzers>true</EnableNETAnalyzers>
44+
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
45+
</PropertyGroup>
46+
47+
<PropertyGroup Condition="'$(TF_BUILD)' == 'true'">
48+
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
49+
</PropertyGroup>
2150

22-
<PropertyGroup>
23-
<TargetFrameworks>netstandard2.0;netstandard2.1;net462;net8.0</TargetFrameworks>
24-
<SignAssembly>true</SignAssembly>
25-
<AssemblyOriginatorKeyFile>../../build/MSAL.snk</AssemblyOriginatorKeyFile>
26-
<GenerateDocumentationFile>true</GenerateDocumentationFile>
27-
<Nullable>enable</Nullable>
28-
<LangVersion>12</LangVersion>
29-
<EnablePackageValidation>true</EnablePackageValidation>
30-
<PackageValidationBaselineVersion>5.0.0</PackageValidationBaselineVersion>
31-
</PropertyGroup>
51+
<ItemGroup>
52+
<None Include="..\..\LICENSE">
53+
<Pack>True</Pack>
54+
<PackagePath />
55+
</None>
56+
</ItemGroup>
3257

33-
<PropertyGroup Label="Source Link">
34-
<PublishRepositoryUrl>true</PublishRepositoryUrl>
35-
<EmbedUntrackedSources>true</EmbedUntrackedSources>
36-
<!-- Build symbol package (.snupkg) to distribute the PDB containing Source Link -->
37-
<IncludeSymbols>true</IncludeSymbols>
38-
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
39-
<!-- The MSAL.snk has both private and public keys -->
40-
<DelaySign>false</DelaySign>
41-
<EnableNETAnalyzers>true</EnableNETAnalyzers>
42-
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
43-
</PropertyGroup>
58+
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
59+
<Reference Include="System.Net.Http" />
60+
</ItemGroup>
4461

45-
<PropertyGroup Condition="'$(TF_BUILD)' == 'true'">
46-
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
47-
</PropertyGroup>
62+
<ItemGroup Label="Build Tools"
63+
Condition="$([MSBuild]::IsOsPlatform('Windows'))">
64+
<PackageReference Include="Microsoft.SourceLink.GitHub"
65+
Version="1.0.0"
66+
PrivateAssets="All" />
67+
</ItemGroup>
4868

49-
<ItemGroup>
50-
<None Include="..\..\LICENSE">
51-
<Pack>True</Pack>
52-
<PackagePath></PackagePath>
53-
</None>
54-
</ItemGroup>
69+
<ItemGroup>
70+
<!-- Protects against sync-over-async: https://github.com/microsoft/vs-threading/blob/main/doc/analyzers/index.md. -->
71+
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers"
72+
Version="17.11.20"
73+
PrivateAssets="all" />
5574

56-
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
57-
<Reference Include="System.Net.Http" />
58-
</ItemGroup>
59-
60-
<ItemGroup Label="Build Tools" Condition="$([MSBuild]::IsOsPlatform('Windows'))">
61-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
62-
</ItemGroup>
63-
</Project>
75+
<!-- Help understand public API changes -->
76+
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers"
77+
Version="$(MicrosoftCodeAnalysisPublicApiAnalyzers)">
78+
<PrivateAssets>all</PrivateAssets>
79+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
80+
</PackageReference>
81+
</ItemGroup>
82+
</Project>

Microsoft.Identity.Abstractions.sln

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Identity.Abstract
77
EndProject
88
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{97E0DF27-D88E-453A-AFF6-3B656AB8F46B}"
99
ProjectSection(SolutionItems) = preProject
10+
.editorconfig = .editorconfig
1011
Directory.Build.props = Directory.Build.props
1112
NuGet.config = NuGet.config
1213
README.md = README.md

src/Microsoft.Identity.Abstractions/CompatibilitySuppressions.xml

-21
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- https://learn.microsoft.com/en-us/dotnet/fundamentals/package-validation/diagnostic-ids -->
33
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
4-
<Suppression>
5-
<DiagnosticId>CP0006</DiagnosticId>
6-
<Target>M:Microsoft.Identity.Abstractions.IAuthorizationHeaderProvider.CreateAuthorizationHeaderAsync(System.Collections.Generic.IEnumerable{System.String},Microsoft.Identity.Abstractions.AuthorizationHeaderProviderOptions,System.Security.Claims.ClaimsPrincipal,System.Threading.CancellationToken)</Target>
7-
<Left>lib/net462/Microsoft.Identity.Abstractions.dll</Left>
8-
<Right>lib/net462/Microsoft.Identity.Abstractions.dll</Right>
9-
<IsBaselineSuppression>true</IsBaselineSuppression>
10-
</Suppression>
11-
<Suppression>
12-
<DiagnosticId>CP0006</DiagnosticId>
13-
<Target>M:Microsoft.Identity.Abstractions.IAuthorizationHeaderProvider.CreateAuthorizationHeaderAsync(System.Collections.Generic.IEnumerable{System.String},Microsoft.Identity.Abstractions.AuthorizationHeaderProviderOptions,System.Security.Claims.ClaimsPrincipal,System.Threading.CancellationToken)</Target>
14-
<Left>lib/netstandard2.0/Microsoft.Identity.Abstractions.dll</Left>
15-
<Right>lib/netstandard2.0/Microsoft.Identity.Abstractions.dll</Right>
16-
<IsBaselineSuppression>true</IsBaselineSuppression>
17-
</Suppression>
184
<Suppression>
195
<DiagnosticId>CP0006</DiagnosticId>
206
<Target>M:Microsoft.Identity.Abstractions.IDownstreamApi.PatchForAppAsync``1(System.String,``0,System.Action{Microsoft.Identity.Abstractions.DownstreamApiOptionsReadOnlyHttpMethod},System.Threading.CancellationToken)</Target>
@@ -183,11 +169,4 @@
183169
<Left>lib/netstandard2.1/Microsoft.Identity.Abstractions.dll</Left>
184170
<Right>lib/net8.0/Microsoft.Identity.Abstractions.dll</Right>
185171
</Suppression>
186-
<Suppression>
187-
<DiagnosticId>CP0006</DiagnosticId>
188-
<Target>M:Microsoft.Identity.Abstractions.IAuthorizationHeaderProvider.CreateAuthorizationHeaderAsync(System.Collections.Generic.IEnumerable{System.String},Microsoft.Identity.Abstractions.AuthorizationHeaderProviderOptions,System.Security.Claims.ClaimsPrincipal,System.Threading.CancellationToken)</Target>
189-
<Left>lib/netstandard2.1/Microsoft.Identity.Abstractions.dll</Left>
190-
<Right>lib/netstandard2.1/Microsoft.Identity.Abstractions.dll</Right>
191-
<IsBaselineSuppression>true</IsBaselineSuppression>
192-
</Suppression>
193172
</Suppressions>

0 commit comments

Comments
 (0)