Skip to content

Commit

Permalink
Merge pull request #5 from xt0rted/code-analysis
Browse files Browse the repository at this point in the history
Code analysis
  • Loading branch information
xt0rted committed Mar 26, 2022
2 parents 1dbd178 + fb3971d commit 1f38037
Show file tree
Hide file tree
Showing 11 changed files with 971 additions and 55 deletions.
19 changes: 19 additions & 0 deletions Directory.Build.props
Expand Up @@ -17,4 +17,23 @@
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="IDisposableAnalyzers" Version="4.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Roslynator.Analyzers" Version="4.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Roslynator.CodeAnalysis.Analyzers" Version="4.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Roslynator.Formatting.Analyzers" Version="4.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>
9 changes: 9 additions & 0 deletions Directory.Build.targets
@@ -0,0 +1,9 @@
<Project>

<Target Name="AddGlobalCodeAnalysisRules" BeforeTargets="CoreCompile">
<ItemGroup>
<EditorConfigFiles Include="$(MSBuildThisFileDirectory)analysis\*.editorconfig" />
</ItemGroup>
</Target>

</Project>
78 changes: 78 additions & 0 deletions analysis/idisposable.editorconfig
@@ -0,0 +1,78 @@
is_global = true

# Rules

# IDISP001: Dispose created
dotnet_diagnostic.IDISP001.severity = error

# IDISP002: Dispose member
dotnet_diagnostic.IDISP002.severity = error

# IDISP003: Dispose previous before re-assigning
dotnet_diagnostic.IDISP003.severity = error

# IDISP004: Don't ignore created IDisposable
dotnet_diagnostic.IDISP004.severity = error

# IDISP005: Return type should indicate that the value should be disposed
dotnet_diagnostic.IDISP005.severity = error

# IDISP006: Implement IDisposable
dotnet_diagnostic.IDISP006.severity = error

# IDISP007: Don't dispose injected
dotnet_diagnostic.IDISP007.severity = error

# IDISP008: Don't assign member with injected and created disposables
dotnet_diagnostic.IDISP008.severity = error

# IDISP009: Add IDisposable interface
dotnet_diagnostic.IDISP009.severity = error

# IDISP010: Call base.Dispose(disposing)
dotnet_diagnostic.IDISP010.severity = error

# IDISP011: Don't return disposed instance
dotnet_diagnostic.IDISP011.severity = error

# IDISP012: Property should not return created disposable
dotnet_diagnostic.IDISP012.severity = error

# IDISP013: Await in using
dotnet_diagnostic.IDISP013.severity = error

# IDISP014: Use a single instance of HttpClient
dotnet_diagnostic.IDISP014.severity = error

# IDISP015: Member should not return created and cached instance
dotnet_diagnostic.IDISP015.severity = error

# IDISP016: Don't use disposed instance
dotnet_diagnostic.IDISP016.severity = error

# IDISP017: Prefer using
dotnet_diagnostic.IDISP017.severity = error

# IDISP018: Call SuppressFinalize
dotnet_diagnostic.IDISP018.severity = error

# IDISP019: Call SuppressFinalize
dotnet_diagnostic.IDISP019.severity = error

# IDISP020: Call SuppressFinalize(this)
dotnet_diagnostic.IDISP020.severity = error

# IDISP021: Call this.Dispose(true)
dotnet_diagnostic.IDISP021.severity = error

# IDISP022: Call this.Dispose(false)
dotnet_diagnostic.IDISP022.severity = error

# IDISP023: Don't use reference types in finalizer context
dotnet_diagnostic.IDISP023.severity = error

# IDISP024: Don't call GC.SuppressFinalize(this) when the type is sealed and has no finalizer
dotnet_diagnostic.IDISP024.severity = error

# IDISP025: Class with no virtual dispose method should be sealed
dotnet_diagnostic.IDISP025.severity = error

0 comments on commit 1f38037

Please sign in to comment.