Skip to content
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
27 changes: 23 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,12 @@ dotnet_analyzer_diagnostic.category-Style.severity = warning

# XML Documentation
dotnet_diagnostic.CS0105.severity = error # CS0105: Using directive is unnecessary.
dotnet_diagnostic.CS1573.severity = error # CS1573: Missing XML comment for parameter
dotnet_diagnostic.CS1591.severity = error # CS1591: Missing XML comment for publicly visible type or member
dotnet_diagnostic.CS1712.severity = error # CS1712: Type parameter has no matching typeparam tag in the XML comment (but other type parameters do)
dotnet_diagnostic.CS1573.severity = none # CS1573: Missing XML comment for parameter
dotnet_diagnostic.CS1591.severity = none # CS1591: Missing XML comment for publicly visible type or member
dotnet_diagnostic.CS1712.severity = none # CS1712: Type parameter has no matching typeparam tag in the XML comment (but other type parameters do)

# Async
dotnet_diagnostic.CS1998.severity = error # CS1998: Async method lacks 'await' operators and will run synchronously
dotnet_diagnostic.CS1998.severity = none # CS1998: Async method lacks 'await' operators and will run synchronously
dotnet_diagnostic.CS4014.severity = error # CS4014: Because this call is not awaited, execution of the current method continues before the call is completed
dotnet_diagnostic.CA2007.severity = none # CA2007: Consider calling ConfigureAwait on the awaited task

Expand All @@ -298,3 +298,22 @@ dotnet_diagnostic.CA5394.severity = none # CA5394: Random is an i
dotnet_diagnostic.CA2000.severity = error # CA2000: Dispose objects before losing scope

dotnet_diagnostic.CA1515.severity = none # CA1515: Consider making public types internal

# Meziantou.Analyzers
MA0053.public_class_should_be_sealed = true
MA0053.exceptions_should_be_sealed = true

dotnet_diagnostic.MA0004.severity = none
dotnet_diagnostic.MA0048.severity = none
dotnet_diagnostic.MA0051.severity = none
dotnet_diagnostic.MA0053.severity = warning

[src/Immediate.Cache.Shared/**.cs]

# XML Documentation
dotnet_diagnostic.CS1573.severity = error # CS1573: Missing XML comment for parameter
dotnet_diagnostic.CS1591.severity = error # CS1591: Missing XML comment for publicly visible type or member
dotnet_diagnostic.CS1712.severity = error # CS1712: Type parameter has no matching typeparam tag in the XML comment (but other type parameters do)

# Async
dotnet_diagnostic.CA2007.severity = error # CA2007: Consider calling ConfigureAwait on the awaited task
8 changes: 8 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@
</PropertyGroup>

<ItemGroup>
<PackageVersion Include="Basic.Reference.Assemblies.Net80" Version="1.6.0" />
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
<PackageVersion Include="coverlet.msbuild" Version="6.0.4" />
<PackageVersion Include="DotNet.ReproducibleBuilds" Version="2.0.2" />
<PackageVersion Include="Microsoft.Bcl.HashCode" Version="6.0.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="4.14.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="4.8.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing" Version="1.1.3" />
<PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.8.0" />
<PackageVersion Include="Immediate.Handlers" Version="3.2.0" />
<PackageVersion Include="MinVer" Version="7.0.0" />
<PackageVersion Include="xunit.v3.mtp-v2" Version="3.2.2" />
Expand Down
2 changes: 2 additions & 0 deletions Immediate.Cache.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
<File Path=".github/workflows/release.yml" />
</Folder>
<Folder Name="/Source/">
<Project Path="src/Immediate.Cache.Analyzers/Immediate.Cache.Analyzers.csproj" />
<Project Path="src/Immediate.Cache.Shared/Immediate.Cache.Shared.csproj" />
<Project Path="src/Immediate.Cache/Immediate.Cache.csproj" />
</Folder>
<Folder Name="/Tests/">
<Project Path="tests/Immediate.Cache.FunctionalTests/Immediate.Cache.FunctionalTests.csproj" />
<Project Path="tests/Immediate.Cache.Tests/Immediate.Cache.Tests.csproj" />
</Folder>
</Solution>
23 changes: 23 additions & 0 deletions src/Immediate.Cache.Analyzers/Immediate.Cache.Analyzers.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<IsRoslynComponent>true</IsRoslynComponent>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DotNet.ReproducibleBuilds" PrivateAssets="All" />
<PackageReference Include="Microsoft.Bcl.HashCode" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" PrivateAssets="All" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
<PackageReference Include="MinVer" PrivateAssets="all" />
</ItemGroup>

<PropertyGroup Label="MinVer">
<MinVerAutoIncrement>minor</MinVerAutoIncrement>
<MinVerDefaultPreReleaseIdentifiers>preview.0</MinVerDefaultPreReleaseIdentifiers>
<MinVerTagPrefix>v</MinVerTagPrefix>
</PropertyGroup>

</Project>
79 changes: 79 additions & 0 deletions src/Immediate.Cache.Analyzers/OwnedDisposableScopeSuppressor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
using System.Collections.Immutable;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;

namespace Immediate.Cache.Analyzers;

[DiagnosticAnalyzer(LanguageNames.CSharp)]
public sealed class OwnedDisposableScopeSuppressor : DiagnosticSuppressor
{
public override ImmutableArray<SuppressionDescriptor> SupportedSuppressions =>
ImmutableArray.Create([
new SuppressionDescriptor(
id: "OwnedDisposableScopeSuppression",
suppressedDiagnosticId: "CA2000",
justification: "Suppress disposable not being disposed when used from `Owned<T>.GetScope(out T)`."
),
]);
public override void ReportSuppressions(SuppressionAnalysisContext context)
{
var token = context.CancellationToken;

foreach (var diagnostic in context.ReportedDiagnostics)
{
token.ThrowIfCancellationRequested();

var syntaxTree = diagnostic.Location.SourceTree;

if (syntaxTree
?.GetRoot(token)
.FindNode(diagnostic.Location.SourceSpan) is not ArgumentSyntax
{
Parent.Parent: InvocationExpressionSyntax
{
Expression: MemberAccessExpressionSyntax
{
Name: IdentifierNameSyntax
{
Identifier.Text: "GetScope",
},

Expression: { } expression,
},
},
})
{
continue;
}

var typeInfo = context.GetSemanticModel(syntaxTree).GetTypeInfo(expression, token);
var symbol = typeInfo.Type ?? typeInfo.ConvertedType;

if (symbol is not INamedTypeSymbol
{
Arity: 1,
Name: "Owned",
ContainingNamespace:
{
Name: "Cache",
ContainingNamespace:
{
Name: "Immediate",
ContainingNamespace.IsGlobalNamespace: true,
},
},
})
{
continue;
}

context.ReportSuppression(
Suppression.Create(
SupportedSuppressions[0],
diagnostic
)
);
}
}
}
4 changes: 3 additions & 1 deletion src/Immediate.Cache/Immediate.Cache.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Description>A collection of classes that simplify caching responses from Immediate.Handlers handlers.</Description>

<Authors>Immediate.Cache Developers</Authors>
<Copyright>© 2024 Immediate.Cache Developers</Copyright>
<Copyright>© 2024-2026 Immediate.Cache Developers</Copyright>

<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageReadmeFile>readme.md</PackageReadmeFile>
Expand All @@ -29,11 +29,13 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="../Immediate.Cache.Analyzers/Immediate.Cache.Analyzers.csproj" ReferenceOutputAssembly="false" />
<ProjectReference Include="../Immediate.Cache.Shared/Immediate.Cache.Shared.csproj" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<None Include="../../readme.md" Pack="true" PackagePath="/" />
<None Include="../Immediate.Cache.Analyzers/bin/$(Configuration)/netstandard2.0/Immediate.Cache.Analyzers.dll" Pack="true" PackagePath="analyzers/dotnet/roslyn4.8/cs" Visible="true" />

<TfmSpecificPackageFile
Include="../Immediate.Cache.Shared/bin/$(Configuration)/$(TargetFramework)/Immediate.Cache.Shared.dll"
Expand Down
9 changes: 0 additions & 9 deletions tests/Immediate.Cache.FunctionalTests/.editorconfig

This file was deleted.

37 changes: 37 additions & 0 deletions tests/Immediate.Cache.Tests/Immediate.Cache.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0</TargetFrameworks>
<OutputType>Exe</OutputType>
<_SkipUpgradeNetAnalyzersNuGetWarning>true</_SkipUpgradeNetAnalyzersNuGetWarning>
</PropertyGroup>

<ItemGroup Label="Usings">
<Using Include="Xunit" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Basic.Reference.Assemblies.Net80" />
<PackageReference Include="coverlet.collector" PrivateAssets="All" />
<PackageReference Include="coverlet.msbuild" PrivateAssets="All" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" VersionOverride="4.9.2" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" VersionOverride="4.9.2" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" VersionOverride="4.9.2" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
<PackageReference Include="xunit.v3.mtp-v2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="../../src/Immediate.Cache.Shared/Immediate.Cache.Shared.csproj" />
<ProjectReference Include="../../src/Immediate.Cache.Analyzers/Immediate.Cache.Analyzers.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" PrivateAssets="all" GeneratePathProperty="true" />
<Reference Include="$(PkgMicrosoft_CodeAnalysis_NetAnalyzers)\analyzers\dotnet\cs\Microsoft.CodeAnalysis.NetAnalyzers.dll" />
<Reference Include="$(PkgMicrosoft_CodeAnalysis_NetAnalyzers)\analyzers\dotnet\cs\Microsoft.CodeAnalysis.CSharp.NetAnalyzers.dll" />
</ItemGroup>

</Project>
Loading
Loading