Skip to content

Commit

Permalink
Add banned apis analyzer (#22414)
Browse files Browse the repository at this point in the history
  • Loading branch information
pakrym authored Jul 2, 2021
1 parent 996f3ae commit c673045
Show file tree
Hide file tree
Showing 23 changed files with 33 additions and 7 deletions.
1 change: 1 addition & 0 deletions eng/BannedSymbols.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
M:System.Uri.ToString();Prefer Uri.AbsoluteUri to Uri.ToString()
1 change: 1 addition & 0 deletions eng/Directory.Build.Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
<EnableClientSdkAnalyzers Condition="'$(IsShippingClientLibrary)' == 'true'">true</EnableClientSdkAnalyzers>
<EnableFxCopAnalyzers Condition="'$(IsShippingClientLibrary)' == 'true'">true</EnableFxCopAnalyzers>
<EnableStyleCopAnalyzers Condition="'$(EnableStyleCopAnalyzers)' == '' and '$(IsClientLibrary)' == 'true'">true</EnableStyleCopAnalyzers>
<EnableBannedApiAnalyzers Condition="'$(IsShippingClientLibrary)' == 'true'">true</EnableBannedApiAnalyzers>
<GenerateAPIListing Condition="'$(IsShippingClientLibrary)' == 'true'">true</GenerateAPIListing>
<UpdateSourceOnBuild Condition="'$(UpdateSourceOnBuild)' == ''">$(AZURE_DEV_UPDATESOURCESONBUILD)</UpdateSourceOnBuild>
<PowerShellExe Condition="'$(PowerShellExe)' == ''">pwsh</PowerShellExe>
Expand Down
16 changes: 11 additions & 5 deletions eng/Directory.Build.Common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@

<PackageReference Condition="'$(EnableClientSdkAnalyzers)' == 'true'" Include="Azure.ClientSdk.Analyzers" PrivateAssets="All" />

<PackageReference Condition="'$(EnableFxCopAnalyzers)' == 'true'" Include="Microsoft.CodeAnalysis.FxCopAnalyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Condition="'$(EnableFxCopAnalyzers)' == 'true'" Include="Microsoft.CodeAnalysis.FxCopAnalyzers" PrivateAssets="All" />

<PackageReference Condition="'$(EnableBannedApiAnalyzers)' == 'true'" Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" PrivateAssets="All" />

</ItemGroup>

<!-- Add Package Icon to DataPlane Packages -->
Expand All @@ -105,7 +105,7 @@
</ItemGroup>

<!-- Add StyleCop Analyzers -->
<ItemGroup Condition="'$(EnableStyleCopAnalyzers)' == 'true'" >
<ItemGroup Condition="'$(EnableStyleCopAnalyzers)' == 'true'" >
<PackageReference Include="StyleCop.Analyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand All @@ -115,6 +115,12 @@
</AdditionalFiles>
</ItemGroup>

<ItemGroup Condition="'$(IsClientLibrary)' == 'true'">
<AdditionalFiles Include="$(RepoEngPath)\BannedSymbols.txt">
<Visible>false</Visible>
</AdditionalFiles>
</ItemGroup>

<!-- Enable SourceLink -->
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" />
Expand Down
1 change: 1 addition & 0 deletions eng/Packages.Data.props
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
<PackageReference Update="Azure.ClientSdk.Analyzers" Version="0.1.1-dev.20210322.2" PrivateAssets="All" />
<PackageReference Update="coverlet.collector" Version="1.3.0" PrivateAssets="All" />
<PackageReference Update="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.1" PrivateAssets="All" />
<PackageReference Update="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="3.3.2" PrivateAssets="All" />
<PackageReference Update="Microsoft.DotNet.ApiCompat" Version="5.0.0-beta.20467.1" PrivateAssets="All" />
<PackageReference Update="Microsoft.DotNet.GenAPI" Version="5.0.0-beta.19552.1" PrivateAssets="All" />
<PackageReference Update="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
Expand Down
1 change: 1 addition & 0 deletions sdk/core/Azure.Core/src/Azure.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<TargetFrameworks>$(RequiredTargetFrameworks);net461;netcoreapp2.1;net5.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<EnableClientSdkAnalyzers>true</EnableClientSdkAnalyzers>
<EnableBannedApiAnalyzers>false</EnableBannedApiAnalyzers>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions sdk/identity/Azure.Identity/src/Azure.Identity.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
<NoWarn>$(NoWarn);3021</NoWarn>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<EnableBannedApiAnalyzers>false</EnableBannedApiAnalyzers>
</PropertyGroup>
<ItemGroup>
<!-- TODO: uncomment when Azure.Core ships
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<PropertyGroup>
<AssemblyTitle>Azure IoT Hub Service Client SDK</AssemblyTitle>
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
<EnableBannedApiAnalyzers>false</EnableBannedApiAnalyzers>
</PropertyGroup>

<!-- Nuget properties -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
<NoWarn>$(NoWarn);3021</NoWarn>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<EnableBannedApiAnalyzers>false</EnableBannedApiAnalyzers>

<!-- Disable warning for missing xml doc comments until we can add all the missing ones -->
<NoWarn>$(NoWarn);1591</NoWarn>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
<NoWarn>$(NoWarn);3021</NoWarn>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<EnableBannedApiAnalyzers>false</EnableBannedApiAnalyzers>

</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
<NoWarn>$(NoWarn);3021</NoWarn>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<EnableBannedApiAnalyzers>false</EnableBannedApiAnalyzers>
</PropertyGroup>

<Import Project="..\..\Azure.Security.KeyVault.Shared\src\Azure.Security.KeyVault.Shared.projitems" Label="Shared" />
Expand Down
1 change: 1 addition & 0 deletions sdk/keyvault/samples/sharelink/ShareLink.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
</NoWarn>
<IncludeAzureCoreSharedCode>true</IncludeAzureCoreSharedCode>
<IncludeGeneratorSharedCode>true</IncludeGeneratorSharedCode>
<EnableBannedApiAnalyzers>false</EnableBannedApiAnalyzers>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<PackageTags>Azure MixedReality</PackageTags>
<Authors>Microsoft</Authors>
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
<EnableBannedApiAnalyzers>false</EnableBannedApiAnalyzers>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Core" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</Description>
<PackageTags>Azure Cognitive Search;Azure Search Documents;Azure Search;Search;Cognitive;Search Engine;Azure</PackageTags>
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>

<EnableBannedApiAnalyzers>false</EnableBannedApiAnalyzers>
<!-- These are still firing but not valid -->
<NoWarn>$(NoWarn);AZC0007;AZC0004;AZC0001</NoWarn>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<ApiCompatVersion>7.2.0</ApiCompatVersion>
<PackageTags>Azure;Service Bus;ServiceBus;.NET;AMQP;$(PackageCommonTags)</PackageTags>
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
<EnableBannedApiAnalyzers>false</EnableBannedApiAnalyzers>
<NoWarn>
<!-- TODO: Investigate and remove suppressions https://github.com/Azure/azure-sdk-for-net/issues/17154 -->
$(NoWarn);CA2213
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
in addition to the breaking changes https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/storage/Azure.Storage.Blobs.ChangeFeed/BreakingChanges.txt
</Description>
<GenerateAPIListing>true</GenerateAPIListing>
<EnableBannedApiAnalyzers>false</EnableBannedApiAnalyzers>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Text.Json" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
Microsoft Azure Storage REST API Reference - https://docs.microsoft.com/en-us/rest/api/storageservices/
REST API Reference for Blob Service - https://docs.microsoft.com/en-us/rest/api/storageservices/blob-service-rest-api
</Description>
<EnableBannedApiAnalyzers>false</EnableBannedApiAnalyzers>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Text.Json" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
Microsoft Azure Storage REST API Reference - https://docs.microsoft.com/en-us/rest/api/storageservices/
</Description>
<RootNamespace>Azure.Storage</RootNamespace>
<EnableBannedApiAnalyzers>false</EnableBannedApiAnalyzers>
</PropertyGroup>
<PropertyGroup>
<!-- TODO: Remove this after HttpAuthorization moves to Core https://github.com/Azure/azure-sdk-for-net/issues/21875 -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
REST API Reference for Data Lake - https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/filesystem
</Description>
<GenerateAPIListing>true</GenerateAPIListing>
<EnableBannedApiAnalyzers>false</EnableBannedApiAnalyzers>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Text.Json" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
Microsoft Azure Storage REST API Reference - https://docs.microsoft.com/en-us/rest/api/storageservices/
REST API Reference for File Service - https://docs.microsoft.com/en-us/rest/api/storageservices/file-service-rest-api
</Description>
<EnableBannedApiAnalyzers>false</EnableBannedApiAnalyzers>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Text.Json" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
Microsoft Azure Storage REST API Reference - https://docs.microsoft.com/en-us/rest/api/storageservices/
REST API Reference for Queue Service - https://docs.microsoft.com/en-us/rest/api/storageservices/queue-service-rest-api
</Description>
<EnableBannedApiAnalyzers>false</EnableBannedApiAnalyzers>
<!-- https://github.com/Azure/azure-sdk-for-net/issues/19222 -->
<NoWarn>$(NoWarn);IDT002;IDT003</NoWarn>
</PropertyGroup>
Expand Down
1 change: 1 addition & 0 deletions sdk/tables/Azure.Data.Tables/src/Azure.Data.Tables.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<DefineConstants>TableSDK;$(DefineConstants)</DefineConstants>
<PackageTags>Microsoft Azure Tables;Microsoft;Azure;Tables;Table;$(PackageCommonTags)</PackageTags>
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
<EnableBannedApiAnalyzers>false</EnableBannedApiAnalyzers>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion sdk/template/Azure.Template/src/MiniSecretClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class MiniSecretClient
public MiniSecretClient(Uri endpoint, TokenCredential credential, MiniSecretClientOptions options): this(
new ClientDiagnostics(options),
HttpPipelineBuilder.Build(options, new BearerTokenAuthenticationPolicy(credential, "https://vault.azure.net/.default")),
endpoint.ToString(),
endpoint.AbsoluteUri,
options.Version)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<Version>1.0.0-beta.2</Version>
<NoWarn>$(NoWarn);AZC0001;CS1591;SA1636;CA1056</NoWarn>
<IsExtensionClientLibrary>true</IsExtensionClientLibrary>
<EnableBannedApiAnalyzers>false</EnableBannedApiAnalyzers>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit c673045

Please sign in to comment.