EnvironmentAbstractions.BannedApiAnalyzer
1.0.0
See the version list below for details.
dotnet add package EnvironmentAbstractions.BannedApiAnalyzer --version 1.0.0
NuGet\Install-Package EnvironmentAbstractions.BannedApiAnalyzer -Version 1.0.0
<PackageReference Include="EnvironmentAbstractions.BannedApiAnalyzer" Version="1.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
paket add EnvironmentAbstractions.BannedApiAnalyzer --version 1.0.0
#r "nuget: EnvironmentAbstractions.BannedApiAnalyzer, 1.0.0"
// Install EnvironmentAbstractions.BannedApiAnalyzer as a Cake Addin
#addin nuget:?package=EnvironmentAbstractions.BannedApiAnalyzer&version=1.0.0
// Install EnvironmentAbstractions.BannedApiAnalyzer as a Cake Tool
#tool nuget:?package=EnvironmentAbstractions.BannedApiAnalyzer&version=1.0.0
EnvironmentAbstractions.BannedApiAnalyzer
The EnvironmentAbstractions.BannedApiAnalyzer
package uses the
Microsoft.CodeAnalysis.BannedApiAnalyzers
package to prevent usages of System.Environment
to access environment variables.
Adding a <PackageReference />
to the package in your project is all you need:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="EnvironmentAbstractions.BannedApiAnalyzer" Version="1.0.0" />
</ItemGroup>
</Project>
Then when anyone attempts to call the built-in methods for read environment variables, they'll receive a build warning indicating that they should use IEnvironmentVariableProvider
instead:
public static void Main(string[] args)
{
Console.WriteLine("Hello, {0}!", System.Environment.GetEnvironmentVariable("USERNAME"));
}
warning RS0030: The symbol 'Environment.GetEnvironmentVariable(string)' is banned in this project: Use IEnvironmentVariableProvider.GetEnvironmentVariable(string) instead.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- EnvironmentAbstractions (>= 1.0.0)
- Microsoft.CodeAnalysis.BannedApiAnalyzers (>= 3.3.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on EnvironmentAbstractions.BannedApiAnalyzer:
Repository | Stars |
---|---|
microsoft/slngen
Visual Studio solution generator
|
Version | Downloads | Last updated |
---|---|---|
2.0.6 | 798 | 12/8/2022 |
2.0.4-preview | 84 | 12/6/2022 |
2.0.3-preview | 63 | 12/6/2022 |
2.0.2-preview | 63 | 12/6/2022 |
1.0.0 | 308 | 9/27/2022 |