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
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@ dotnet_diagnostic.MA0051.severity = none
dotnet_diagnostic.MA0053.severity = warning
dotnet_diagnostic.MA0190.severity = none

dotnet_diagnostic.RS1041.severity = none # RS1041: Compiler extensions should be implemented in assemblies targeting netstandard2.0

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

# XML Documentation
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v7

- name: Setup .NET
uses: actions/setup-dotnet@v5
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v7

- name: Setup .NET
uses: actions/setup-dotnet@v5
Expand Down
3 changes: 3 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<!--https://github.com/meziantou/Meziantou.Polyfill?tab=readme-ov-file#supported-polyfills-->
<Polyfill></Polyfill>
<Polyfill>$(Polyfill)|T:System.Index</Polyfill>
<Polyfill>$(Polyfill)|T:System.HashCode</Polyfill>
<Polyfill>$(Polyfill)|T:System.Range</Polyfill>
<Polyfill>$(Polyfill)|T:System.Diagnostics.CodeAnalysis</Polyfill>
<Polyfill>$(Polyfill)|T:System.Runtime.CompilerServices.CallerArgumentExpressionAttribute</Polyfill>
Expand All @@ -31,6 +32,8 @@
<Polyfill>$(Polyfill)|T:System.Runtime.CompilerServices.RequiredMemberAttribute</Polyfill>
<Polyfill>$(Polyfill)|T:System.Runtime.CompilerServices.SkipLocalsInitAttribute</Polyfill>
<Polyfill>$(Polyfill)|T:System.Threading.Lock</Polyfill>
<Polyfill>$(Polyfill)|M:System.ArgumentNullException.ThrowIfNull</Polyfill>
<Polyfill>$(Polyfill)|M:System.String.Replace(System.String,System.String,System.StringComparison)</Polyfill>
<MeziantouPolyfill_IncludedPolyfills>$(Polyfill)</MeziantouPolyfill_IncludedPolyfills>
</PropertyGroup>

Expand Down
58 changes: 46 additions & 12 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,18 @@
<PackageVersion Include="Immediate.Handlers" Version="3.8.1" />
<PackageVersion Include="Microsoft.Bcl.HashCode" Version="6.0.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="5.3.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.4" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.8.0" />
<!-- Locked until https://github.com/microsoft/codecoverage/issues/221 resolved -->
<PackageVersion Include="Microsoft.Testing.Extensions.CodeCoverage" Version="[18.4.1]" />
<PackageVersion Include="Scriban" Version="7.2.4" />
<PackageVersion Include="Scriban" Version="7.2.5" />
<PackageVersion Include="Verify.SourceGenerators" Version="2.5.0" />
<PackageVersion Include="Verify.XunitV3" Version="31.19.1" />
<PackageVersion Include="Verify.XunitV3" Version="31.20.0" />
<PackageVersion Include="xunit.v3.mtp-v2" Version="3.2.2" />
</ItemGroup>

<!-- IV.Shared dependencies -->
<ItemGroup Condition="$(TargetFramework) == 'net8.0'">
<PackageVersion Include="Basic.Reference.Assemblies.Net80" Version="1.8.8" />
<PackageVersion Include="Basic.Reference.Assemblies.Net80" Version="1.8.9" />
<PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Caching.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="8.0.1" />
Expand All @@ -34,7 +32,7 @@
</ItemGroup>

<ItemGroup Condition="$(TargetFramework) == 'net9.0'">
<PackageVersion Include="Basic.Reference.Assemblies.Net90" Version="1.8.8" />
<PackageVersion Include="Basic.Reference.Assemblies.Net90" Version="1.8.9" />
<PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Caching.Abstractions" Version="$(Net9PackageVersion)" />
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="$(Net9PackageVersion)" />
Expand All @@ -43,7 +41,7 @@
</ItemGroup>

<ItemGroup Condition="$(TargetFramework) == 'net10.0'">
<PackageVersion Include="Basic.Reference.Assemblies.Net100" Version="1.8.8" />
<PackageVersion Include="Basic.Reference.Assemblies.Net100" Version="1.8.9" />
<PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="10.0.300" />
<PackageVersion Include="Microsoft.Extensions.Caching.Abstractions" Version="$(Net10PackageVersion)" />
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="$(Net10PackageVersion)" />
Expand All @@ -52,18 +50,54 @@
</ItemGroup>

<ItemGroup Condition="$(TargetFramework) == 'net11.0'">
<PackageVersion Include="Basic.Reference.Assemblies.Net110" Version="1.8.8" />
<PackageVersion Include="Basic.Reference.Assemblies.Net110" Version="1.8.9" />
<PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="11.0.100-preview.5.26302.115" />
<PackageVersion Include="Microsoft.Extensions.Caching.Abstractions" Version="$(Net11PackageVersion)" />
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="$(Net11PackageVersion)" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="$(Net11PackageVersion)" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="$(Net11PackageVersion)" />
</ItemGroup>

<!-- IV.Generators dependencies -->
<ItemGroup Condition=" '$(TargetFramework)' == 'net11.0' ">
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="5.3.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="5.3.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="5.3.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="5.3.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net10.0' ">
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="5.0.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="5.0.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="5.0.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="5.0.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net9.0' ">
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="4.12.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.12.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.12.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="4.11.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.11.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.11.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.11.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="4.8.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.8.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.8.0" />
</ItemGroup>

<ItemGroup>
<GlobalPackageReference Include="DotNet.ReproducibleBuilds" Version="2.0.2" PrivateAssets="All" />
<GlobalPackageReference Include="Meziantou.Analyzer" Version="3.0.102" PrivateAssets="All" />
<GlobalPackageReference Include="Meziantou.Polyfill" Version="1.0.150" PrivateAssets="All" />
<GlobalPackageReference Include="DotNet.ReproducibleBuilds" Version="2.0.5" PrivateAssets="All" />
<GlobalPackageReference Include="Meziantou.Analyzer" Version="3.0.122" PrivateAssets="All" />
<GlobalPackageReference Include="Meziantou.Polyfill" Version="1.0.157" PrivateAssets="All" />
<GlobalPackageReference Include="MinVer" Version="7.0.0" PrivateAssets="All" />
</ItemGroup>
</Project>
41 changes: 27 additions & 14 deletions coverage-settings.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<Configuration>
<CodeCoverage>
<CodeCoverage>

<!-- Match attributes on any code element: -->
<Attributes>
<Exclude>
<!-- Don't forget "Attribute" at the end of the name -->
<Attribute>^System\.Diagnostics\.DebuggerHiddenAttribute$</Attribute>
<Attribute>^System\.Diagnostics\.DebuggerNonUserCodeAttribute$</Attribute>
<Attribute>^System\.CodeDom\.Compiler\.GeneratedCodeAttribute$</Attribute>
<Attribute>^System\.Diagnostics\.CodeAnalysis\.ExcludeFromCodeCoverageAttribute$</Attribute>
</Exclude>
</Attributes>
<!-- Match assembly file paths: -->
<ModulePaths>
<Exclude>
<ModulePath>.*Immediate.Handlers.Generators.dll$</ModulePath>
</Exclude>
</ModulePaths>

<EnableStaticManagedInstrumentation>True</EnableStaticManagedInstrumentation>
<EnableDynamicManagedInstrumentation>True</EnableDynamicManagedInstrumentation>
<!-- Match attributes on any code element: -->
<Attributes>
<Exclude>
<!-- Don't forget "Attribute" at the end of the name -->
<Attribute>^System\.Diagnostics\.DebuggerHiddenAttribute$</Attribute>
<Attribute>^System\.Diagnostics\.DebuggerNonUserCodeAttribute$</Attribute>
<Attribute>^System\.CodeDom\.Compiler\.GeneratedCodeAttribute$</Attribute>
<Attribute>^System\.Diagnostics\.CodeAnalysis\.ExcludeFromCodeCoverageAttribute$</Attribute>
</Exclude>
</Attributes>

</CodeCoverage>
<Sources>
<Exclude>
<Source>.*/scriban/.*</Source>
</Exclude>
</Sources>

<EnableStaticManagedInstrumentation>True</EnableStaticManagedInstrumentation>
<EnableDynamicManagedInstrumentation>True</EnableDynamicManagedInstrumentation>

</CodeCoverage>
</Configuration>
3 changes: 1 addition & 2 deletions src/Immediate.Cache.Analyzers/CacheForUsageAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ public sealed class CacheForUsageAnalyzer : DiagnosticAnalyzer

public override void Initialize(AnalysisContext context)
{
if (context == null)
throw new ArgumentNullException(nameof(context));
ArgumentNullException.ThrowIfNull(context);

context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);
context.EnableConcurrentExecution();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net10.0</TargetFrameworks>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<IsRoslynComponent>true</IsRoslynComponent>
</PropertyGroup>
Expand All @@ -11,7 +11,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Bcl.HashCode" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" PrivateAssets="All" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
</ItemGroup>
Expand Down
30 changes: 21 additions & 9 deletions src/Immediate.Cache.Generators/Immediate.Cache.Generators.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net10.0</TargetFrameworks>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<IsRoslynComponent>true</IsRoslynComponent>
<NoWarn>$(NoWarn);CA1716</NoWarn>
Expand All @@ -18,20 +18,32 @@

<ItemGroup>
<PackageReference Include="AssemblyMetadata.Generators" PrivateAssets="All" />
<PackageReference Include="Microsoft.Bcl.HashCode" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" PrivateAssets="all" />
<PackageReference Include="Scriban" PrivateAssets="all" GeneratePathProperty="true" />
</ItemGroup>

<PropertyGroup>
<GetTargetPathDependsOn>$(GetTargetPathDependsOn);GetDependencyTargetPaths</GetTargetPathDependsOn>
<!-- Scriban (code in netstandard2.0; lib in net10+) -->
<ItemGroup Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net10.0'))">
<PackageReference Include="Scriban" PrivateAssets="all" IncludeAssets="Build" />
</ItemGroup>

<PropertyGroup Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net10.0'))">
<PackageScribanIncludeSource>true</PackageScribanIncludeSource>
<DefineConstants>$(DefineConstants);SCRIBAN_NO_ASYNC</DefineConstants>
</PropertyGroup>

<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net10.0'))">
<PackageReference Include="Scriban" PrivateAssets="all" GeneratePathProperty="true" />
</ItemGroup>

<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net10.0'))">
<GetTargetPathDependsOn>$(GetTargetPathDependsOn);GetDependencyTargetPaths</GetTargetPathDependsOn>
</PropertyGroup>

<Target Name="GetDependencyTargetPaths">
<ItemGroup>
<TargetPathWithTargetPlatformMoniker Include="$(PkgScriban)/lib/netstandard2.0/Scriban.dll" IncludeRuntimeDependency="false" />
</ItemGroup>
<Target Name="GetDependencyTargetPaths" Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net10.0'))">
<ItemGroup>
<TargetPathWithTargetPlatformMoniker Include="$(PkgScriban)/lib/netstandard2.0/Scriban.dll" IncludeRuntimeDependency="false" />
</ItemGroup>
</Target>

</Project>
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Diagnostics;
using System.Reflection;
using Microsoft.CodeAnalysis;
using Scriban;
Expand Down Expand Up @@ -70,6 +71,8 @@ private static Template GetTemplate(string name)
$"Immediate.Cache.Generators.Templates.{name}.sbntxt"
);

Debug.Assert(stream is { });

using var reader = new StreamReader(stream);
return Template.Parse(reader.ReadToEnd());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public sealed partial class ImmediateCacheGenerator
if (context.Attributes is not [{ AttributeClass.TypeArguments: [INamedTypeSymbol { IsStatic: false } handlerSymbol] }])
return null;

var @namespace = targetSymbol.ContainingNamespace.ToString().NullIf("<global namespace>");
var @namespace = targetSymbol.ContainingNamespace.ToDisplayString().NullIf("<global namespace>");
var name = targetSymbol.Name;

if (!handlerSymbol.GetValidHandleMethod(out var requestType, out var responseType))
Expand Down
4 changes: 2 additions & 2 deletions src/Immediate.Cache.Generators/ImmediateCacheGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public static string GetAssemblyIdentifier(this Compilation compilation)
}

return (compilation.AssemblyName ?? string.Empty)
.Replace(".", string.Empty)
.Replace(" ", string.Empty)
.Replace(".", string.Empty, StringComparison.Ordinal)
.Replace(" ", string.Empty, StringComparison.Ordinal)
.Trim();
}
}
56 changes: 43 additions & 13 deletions src/Immediate.Cache/Immediate.Cache.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
<PackageReference Include="Immediate.Handlers" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
<PackageReference Include="Scriban" PrivateAssets="all" GeneratePathProperty="true" />
</ItemGroup>

<ItemGroup>
Expand All @@ -33,26 +32,57 @@
<ProjectReference Include="../Immediate.Cache.Shared/Immediate.Cache.Shared.csproj" PrivateAssets="All" />
</ItemGroup>

<!--
This ensures the library will be packaged as a source generator when we use `dotnet pack`
-->
<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" />
<None Include="../Immediate.Cache.Generators/bin/$(Configuration)/netstandard2.0/Immediate.Cache.Generators.dll" Pack="true" PackagePath="analyzers/dotnet/roslyn4.8/cs" Visible="true" />

<!-- IH.Shared -->
<TfmSpecificPackageFile
Include="../Immediate.Cache.Shared/bin/$(Configuration)/$(TargetFramework)/Immediate.Cache.Shared.dll"
Pack="true"
PackagePath="lib/$(TargetFramework)" />

<TfmSpecificPackageFile
Include="../Immediate.Cache.Shared/bin/$(Configuration)/$(TargetFramework)/Immediate.Cache.Shared.xml"
Pack="true"
PackagePath="lib/$(TargetFramework)" />
</ItemGroup>

<!-- roslyn 4.8 for net8/net9 -->
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<TfmSpecificPackageFile
Include="$(PkgScriban)/lib/netstandard2.0/Scriban.dll"
Pack="true"
PackagePath="analyzers/dotnet/roslyn4.8/cs"
Condition=" '$(TargetFramework)' == 'net8.0' " />
Include="../Immediate.Cache.Analyzers/bin/$(Configuration)/netstandard2.0/Immediate.Cache.Analyzers.dll"
Pack="true"
PackagePath="analyzers/dotnet/roslyn4.8/cs" />

<TfmSpecificPackageFile
Include="../Immediate.Cache.Shared/bin/$(Configuration)/$(TargetFramework)/Immediate.Cache.Shared.dll"
Pack="true"
PackagePath="lib/$(TargetFramework)" />
Include="../Immediate.Cache.Generators/bin/$(Configuration)/netstandard2.0/Immediate.Cache.Generators.dll"
Pack="true"
PackagePath="analyzers/dotnet/roslyn4.8/cs" />
</ItemGroup>

<!-- roslyn 5.0 for net10/net11 -->
<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
<TfmSpecificPackageFile
Include="../Immediate.Cache.Shared/bin/$(Configuration)/$(TargetFramework)/Immediate.Cache.Shared.xml"
Pack="true"
PackagePath="lib/$(TargetFramework)" />
Include="../Immediate.Cache.Analyzers/bin/$(Configuration)/net10.0/Immediate.Cache.Analyzers.dll"
Pack="true"
PackagePath="analyzers/dotnet/roslyn5.0/cs" />

<TfmSpecificPackageFile
Include="../Immediate.Cache.Generators/bin/$(Configuration)/net10.0/Immediate.Cache.Generators.dll"
Pack="true"
PackagePath="analyzers/dotnet/roslyn5.0/cs" />

<TfmSpecificPackageFile
Include="$(PkgScriban)/lib/net8.0/Scriban.dll"
Pack="true"
PackagePath="analyzers/dotnet/roslyn5.0/cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Scriban" PrivateAssets="all" GeneratePathProperty="true" />
</ItemGroup>

</Project>
Loading