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 @@ -303,6 +303,8 @@ dotnet_diagnostic.MA0048.severity = none
dotnet_diagnostic.MA0051.severity = none
dotnet_diagnostic.MA0053.severity = warning

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

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

# XML Documentation
Expand Down
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.verified.cs text eol=lf working-tree-encoding=UTF-8
* text=auto
14 changes: 3 additions & 11 deletions .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 All @@ -41,7 +41,7 @@ jobs:
- name: Build
run: dotnet build -c Release --no-restore
- name: Test
run: dotnet test -c Release --no-build -- --coverage --coverage-output-format cobertura --coverage-output coverage.cobertura.xml --coverage-settings ./coverage-settings.xml
run: dotnet test -c Release --no-build -- --coverage --coverage-output-format cobertura --coverage-settings ./coverage-settings.xml

- name: Package
run: dotnet pack -c Release --no-build --property:PackageOutputPath=../../nupkgs
Expand All @@ -51,12 +51,4 @@ jobs:
- name: Coveralls
uses: coverallsapp/github-action@v2
with:
files: >
tests/Immediate.Injections.FunctionalTests/bin/Release/net8.0/TestResults/coverage.cobertura.xml
tests/Immediate.Injections.FunctionalTests/bin/Release/net9.0/TestResults/coverage.cobertura.xml
tests/Immediate.Injections.FunctionalTests/bin/Release/net10.0/TestResults/coverage.cobertura.xml
tests/Immediate.Injections.FunctionalTests/bin/Release/net11.0/TestResults/coverage.cobertura.xml
tests/Immediate.Injections.Tests/bin/Release/net8.0/TestResults/coverage.cobertura.xml
tests/Immediate.Injections.Tests/bin/Release/net9.0/TestResults/coverage.cobertura.xml
tests/Immediate.Injections.Tests/bin/Release/net10.0/TestResults/coverage.cobertura.xml
tests/Immediate.Injections.Tests/bin/Release/net11.0/TestResults/coverage.cobertura.xml
files: 'TestResults/*.cobertura.xml'
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,13 +23,16 @@
<!--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.Runtime.CompilerServices.CallerArgumentExpressionAttribute</Polyfill>
<Polyfill>$(Polyfill)|T:System.Runtime.CompilerServices.CompilerFeatureRequiredAttribute</Polyfill>
<Polyfill>$(Polyfill)|T:System.Runtime.CompilerServices.IsExternalInit</Polyfill>
<Polyfill>$(Polyfill)|T:System.Runtime.CompilerServices.RequiredMemberAttribute</Polyfill>
<Polyfill>$(Polyfill)|T:System.Runtime.CompilerServices.SkipLocalsInitAttribute</Polyfill>
<Polyfill>$(Polyfill)|T:System.Diagnostics.CodeAnalysis</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
67 changes: 49 additions & 18 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,56 +5,87 @@

<ItemGroup>
<PackageVersion Include="AssemblyMetadata.Generators" Version="2.2.0" />
<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="Immediate.Handlers" Version="3.10.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="5.6.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing" Version="1.1.4" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.8.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.Common" 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="Microsoft.Testing.Extensions.CodeCoverage" Version="18.9.0" />
<PackageVersion Include="Scriban" Version="7.2.5" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="10.1.7" />
<PackageVersion Include="System.Threading.Tasks.Extensions" Version="4.6.3" />
<PackageVersion Include="Verify.SourceGenerators" Version="2.5.0" />
<PackageVersion Include="Verify.XunitV3" Version="31.19.1" />
<PackageVersion Include="Verify.XunitV3" Version="31.22.0" />
<PackageVersion Include="xunit.v3.mtp-v2" Version="3.2.2" />
</ItemGroup>

<!-- II.Shared dependencies -->
<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.Extensions.DependencyInjection" Version="11.0.0-preview.5.26302.115" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="11.0.0-preview.5.26302.115" />
<PackageVersion Include="Microsoft.Extensions.Diagnostics.Testing" Version="10.7.0" />
</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.Extensions.DependencyInjection" Version="10.0.9" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.9" />
<PackageVersion Include="Microsoft.Extensions.Diagnostics.Testing" Version="10.6.0" />
</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.Extensions.DependencyInjection" Version="9.0.17" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.17" />
<PackageVersion Include="Microsoft.Extensions.Diagnostics.Testing" Version="9.10.0" />
</ItemGroup>

<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.Extensions.DependencyInjection" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.2" />
<PackageVersion Include="Microsoft.Extensions.Diagnostics.Testing" Version="8.10.0" />
</ItemGroup>

<!-- II.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>
32 changes: 19 additions & 13 deletions coverage-settings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Configuration>
<CodeCoverage>
<CodeCoverage>

<!-- Match assembly file paths: -->
<ModulePaths>
Expand All @@ -9,19 +9,25 @@
</Exclude>
</ModulePaths>

<!-- 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 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>

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

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

</CodeCoverage>
</CodeCoverage>
</Configuration>
4 changes: 1 addition & 3 deletions src/Common/SyntaxExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
namespace Immediate.Injections;

internal static class SyntaxExtensions
{
}
internal static class SyntaxExtensions;
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ public sealed class RegisterServicesMethodAnalyzer : 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
3 changes: 1 addition & 2 deletions src/Immediate.Injections.Analyzers/RegisterTypeAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,7 @@ public sealed class RegisterTypeAnalyzer : 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>
<NoWarn>$(NoWarn);CA1716</NoWarn>
Expand All @@ -18,17 +18,29 @@

<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" />
</ItemGroup>

<!-- 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>
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net10.0'))">
<GetTargetPathDependsOn>$(GetTargetPathDependsOn);GetDependencyTargetPaths</GetTargetPathDependsOn>
</PropertyGroup>

<Target Name="GetDependencyTargetPaths">
<Target Name="GetDependencyTargetPaths" Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net10.0'))">
<ItemGroup>
<TargetPathWithTargetPlatformMoniker Include="$(PkgScriban)/lib/netstandard2.0/Scriban.dll" IncludeRuntimeDependency="false" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
using System.Diagnostics;
using System.Reflection;
using Microsoft.CodeAnalysis;
using Scriban;
Expand Down Expand Up @@ -139,6 +140,8 @@ private static Template GetTemplate(string name)
$"Immediate.Injections.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 @@ -160,8 +160,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();
}
}
41 changes: 33 additions & 8 deletions src/Immediate.Injections/Immediate.Injections.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,14 @@
<RepositoryUrl>https://github.com/ImmediatePlatform/Immediate.Injections</RepositoryUrl>
</PropertyGroup>


<!--
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.Injections.Analyzers/bin/$(Configuration)/netstandard2.0/Immediate.Injections.Analyzers.dll" Pack="true" PackagePath="analyzers/dotnet/roslyn4.8/cs" Visible="true" />
<None Include="../Immediate.Injections.Generators/bin/$(Configuration)/netstandard2.0/Immediate.Injections.Generators.dll" Pack="true" PackagePath="analyzers/dotnet/roslyn4.8/cs" Visible="true" />

<TfmSpecificPackageFile
Include="$(PkgScriban)/lib/netstandard2.0/Scriban.dll"
Pack="true"
PackagePath="analyzers/dotnet/roslyn4.8/cs"
Condition=" '$(TargetFramework)' == 'net8.0' " />

<!-- IH.Shared -->
<TfmSpecificPackageFile
Include="../Immediate.Injections.Shared/bin/$(Configuration)/$(TargetFramework)/Immediate.Injections.Shared.dll"
Pack="true"
Expand All @@ -45,6 +39,37 @@
PackagePath="lib/$(TargetFramework)" />
</ItemGroup>

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

<TfmSpecificPackageFile
Include="../Immediate.Injections.Generators/bin/$(Configuration)/netstandard2.0/Immediate.Injections.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.Injections.Analyzers/bin/$(Configuration)/net10.0/Immediate.Injections.Analyzers.dll"
Pack="true"
PackagePath="analyzers/dotnet/roslyn5.0/cs" />

<TfmSpecificPackageFile
Include="../Immediate.Injections.Generators/bin/$(Configuration)/net10.0/Immediate.Injections.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="Microsoft.Extensions.DependencyInjection.Abstractions" />
<PackageReference Include="Scriban" PrivateAssets="all" GeneratePathProperty="true" />
Expand Down
Loading