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
8 changes: 1 addition & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,14 @@ jobs:
dotnet-version: |
8.0.x
9.0.x

- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-quality: 'preview'
dotnet-version: |
10.0.x

- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build -c Release --no-restore
- name: Test
run: dotnet test -c Release --no-build
run: dotnet test -c Release --no-build -- --coverage --coverage-output-format cobertura --coverage-output coverage.cobertura.xml
Comment thread
viceroypenguin marked this conversation as resolved.

- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/codecov-action@v5
Expand Down
21 changes: 11 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ on:
tags:
- '**'

permissions:
contents: write

jobs:
release:
permissions:
id-token: write # enable GitHub OIDC token issuance for this job
contents: write # enable github releases

runs-on: ubuntu-latest

Expand All @@ -23,12 +23,6 @@ jobs:
dotnet-version: |
8.0.x
9.0.x

- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-quality: 'preview'
dotnet-version: |
10.0.x

- name: Restore dependencies
Expand All @@ -38,8 +32,15 @@ jobs:

- name: Package
run: dotnet pack -c Release --no-build --property:PackageOutputPath=../../nupkgs

- name: NuGet login (OIDC → temp API key)
uses: NuGet/login@v1
id: login
with:
user: viceroypenguin

- name: Push to Nuget
run: dotnet nuget push "./nupkgs/*.nupkg" --source "https://api.nuget.org/v3/index.json" --api-key ${{ secrets.NUGETPUBLISHKEY }}
run: dotnet nuget push "./nupkgs/*.nupkg" --source "https://api.nuget.org/v3/index.json" --api-key ${{ steps.login.outputs.NUGET_API_KEY }}

- name: Create Release
uses: ncipollo/release-action@v1
Expand Down
5 changes: 2 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

<IsPackable>false</IsPackable>
<WarnOnPackingNonPackableProject>false</WarnOnPackingNonPackableProject>

<EmbedUntrackedSources>true</EmbedUntrackedSources>
</PropertyGroup>

<PropertyGroup Label="Enabled Polyfills">
Expand All @@ -33,8 +35,5 @@
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<CollectCoverage>true</CollectCoverage>
<CoverletOutputFormat>opencover</CoverletOutputFormat>
</PropertyGroup>
</Project>
43 changes: 23 additions & 20 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,53 @@
</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="1.2.39" />
<PackageVersion Include="Immediate.Handlers" Version="3.0.0" />
<PackageVersion Include="DotNet.ReproducibleBuilds" Version="2.0.2" />
<PackageVersion Include="Immediate.Handlers" Version="3.3.0" />
<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.2" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing" Version="1.1.2" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeRefactoring.Testing" Version="1.1.2" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing" Version="1.1.3" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing" Version="1.1.3" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeRefactoring.Testing" Version="1.1.3" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.8.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.8.0" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="MinVer" Version="6.1.0" />
<PackageVersion Include="Microsoft.Testing.Extensions.CodeCoverage" Version="18.4.1" />
<PackageVersion Include="MinVer" Version="7.0.0" />
<PackageVersion Include="Scriban" Version="6.5.2" />
<PackageVersion Include="System.Threading.Tasks.Extensions" Version="4.6.3" />
<PackageVersion Include="Verify.SourceGenerators" Version="2.5.0" />
<PackageVersion Include="Verify.XunitV3" Version="31.9.3" />
<PackageVersion Include="xunit.v3.mtp-v2" Version="3.2.1" />
<PackageVersion Include="xunit.v3.mtp-v2" Version="3.2.2" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
<PackageVersion Include="Basic.Reference.Assemblies.Net80" Version="1.8.4" />
<PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Localization" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Localization.Abstractions" Version="8.0.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net9.0' ">
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Localization" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Localization.Abstractions" Version="9.0.0" />
<PackageVersion Include="Basic.Reference.Assemblies.Net90" Version="1.8.4" />
<PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="9.0.11" />
<PackageVersion Include="Microsoft.Extensions.Localization" Version="9.0.11" />
<PackageVersion Include="Microsoft.Extensions.Localization.Abstractions" Version="9.0.11" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net10.0' ">
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.0" />
<PackageVersion Include="Microsoft.Extensions.Localization" Version="10.0.0" />
<PackageVersion Include="Microsoft.Extensions.Localization.Abstractions" Version="10.0.0" />
<PackageVersion Include="Basic.Reference.Assemblies.Net100" Version="1.8.4" />
<PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="10.0.103" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.3" />
<PackageVersion Include="Microsoft.Extensions.Localization" Version="10.0.3" />
<PackageVersion Include="Microsoft.Extensions.Localization.Abstractions" Version="10.0.3" />
</ItemGroup>

<ItemGroup>
<GlobalPackageReference Include="Meziantou.Analyzer" Version="2.0.267" />
<GlobalPackageReference Include="Meziantou.Polyfill" Version="1.0.83" />
<GlobalPackageReference Include="Meziantou.Analyzer" Version="3.0.15" PrivateAssets="All" />
<GlobalPackageReference Include="Meziantou.Polyfill" Version="1.0.101" PrivateAssets="All" />
<GlobalPackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.103" PrivateAssets="All" />
</ItemGroup>
</Project>
6 changes: 3 additions & 3 deletions src/Common/ITypeSymbolExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ typeSymbol is INamedTypeSymbol
{
Name: "System",
ContainingNamespace.IsGlobalNamespace: true,
}
}
}
},
},
},
};

public static IReadOnlyList<(string? Target, IObjectCreationOperation Attribute)> GetTargetedAttributes(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public sealed class AssemblyBehaviorAnalyzer : DiagnosticAnalyzer
);

public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } =
ImmutableArray.Create<DiagnosticDescriptor>(
ImmutableArray.Create(
[
AssemblyBehaviorsShouldUseValidation,
]);
Expand Down Expand Up @@ -79,7 +79,7 @@ private static void AnalyzeOperation(OperationAnalysisContext context)
},
},
},
ChildOperations.Count: 2
ChildOperations.Count: 2,
}
|| array.ChildOperations.ElementAt(1) is not IArrayInitializerOperation aio)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ public sealed class InvalidAttributeTargetSuppressor : DiagnosticSuppressor
public override ImmutableArray<SuppressionDescriptor> SupportedSuppressions =>
ImmutableArray.Create([
new SuppressionDescriptor(
id: $"InvalidAttributeTargetSuppression",
id: "InvalidAttributeTargetSuppression",
suppressedDiagnosticId: "CS0658",
justification: $"Suppress invalid attribute target when used for validation."
justification: "Suppress invalid attribute target when used for validation."
),
]);

Expand All @@ -32,7 +32,7 @@ public override void ReportSuppressions(SuppressionAnalysisContext context)
.FindNode(diagnostic.Location.SourceSpan) is not AttributeTargetSpecifierSyntax
{
Identifier.ValueText: "element",
Parent.Parent: SyntaxNode declarationSyntax
Parent.Parent: SyntaxNode declarationSyntax,
})
{
continue;
Expand All @@ -43,13 +43,13 @@ public override void ReportSuppressions(SuppressionAnalysisContext context)
IPropertySymbol
{
ContainingType: INamedTypeSymbol ct1,
Type: ITypeSymbol pt1
Type: ITypeSymbol pt1,
} => (true, ct1, pt1),

IParameterSymbol
{
ContainingType: INamedTypeSymbol ct1,
Type: ITypeSymbol pt1
Type: ITypeSymbol pt1,
} => (true, ct1, pt1),

_ => (false, null, null),
Expand Down
6 changes: 3 additions & 3 deletions src/Immediate.Validations.Analyzers/ValidateClassAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ CancellationToken token

if (argument.Value is not IArrayCreationOperation
{
Initializer.ElementValues: { } elements
Initializer.ElementValues: { } elements,
})
{
return;
Expand All @@ -357,7 +357,7 @@ CancellationToken token

if (initializer is not ISimpleAssignmentOperation
{
Target: IPropertyReferenceOperation { Property: { } property }
Target: IPropertyReferenceOperation { Property: { } property },
})
{
return;
Expand Down Expand Up @@ -493,7 +493,7 @@ List<ISymbol> members
.FirstOrDefault(
ims => ims is IMethodSymbol
{
Parameters: []
Parameters: [],
}
);

Expand Down
2 changes: 1 addition & 1 deletion src/Immediate.Validations.Generators/Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static Template GetTemplate(string name)
.GetExecutingAssembly()
.GetManifestResourceStream(
$"Immediate.Validations.Generators.Templates.{name}.sbntxt"
)!;
);

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 @@ -411,7 +411,7 @@ IObjectCreationOperation attribute
IsGenericMethod = validateMethod.IsGenericMethod,
IsNullable = targetParameterType is { IsReferenceType: true, NullableAnnotation: NullableAnnotation.Annotated }
or { OriginalDefinition.SpecialType: SpecialType.System_Nullable_T },
Arguments = parameters.ToEquatableReadOnlyList()!,
Arguments = parameters.ToEquatableReadOnlyList(),
Message = attribute.GetMessage(),
};
}
Expand Down Expand Up @@ -455,7 +455,7 @@ ITypeSymbol targetPropertyType

if (argument.Value is not IArrayCreationOperation
{
Initializer.ElementValues: { } elements
Initializer.ElementValues: { } elements,
})
{
return null;
Expand Down Expand Up @@ -511,7 +511,7 @@ ITypeSymbol targetPropertyType

if (initializer is not ISimpleAssignmentOperation
{
Target: IPropertyReferenceOperation { Property: { } property }
Target: IPropertyReferenceOperation { Property: { } property },
})
{
return null;
Expand Down Expand Up @@ -623,7 +623,7 @@ ExpressionSyntax argumentExpressionSyntax
.FirstOrDefault(
ims => ims is IMethodSymbol
{
Parameters: []
Parameters: [],
}
);

Expand Down
2 changes: 1 addition & 1 deletion src/Immediate.Validations.Shared/ExpressionEvaluator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ internal static class ExpressionEvaluator
? s_identityCheckedMethod.MakeGenericMethod(targetType)
: s_identityUncheckedMethod.MakeGenericMethod(targetType);

return method.Invoke(null, [value!])!;
return method.Invoke(null, [value]);
}

private static T IdentityChecked<T>(dynamic value) => checked((T)value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" PrivateAssets="All" />
<PackageReference Include="coverlet.msbuild" PrivateAssets="All" />
<PackageReference Include="Immediate.Handlers" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
<PackageReference Include="Microsoft.Extensions.Localization" />
<PackageReference Include="Microsoft.Testing.Extensions.CodeCoverage" />
<PackageReference Include="xunit.v3.mtp-v2" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@ public static CSharpAnalyzerTest<TAnalyzer, DefaultVerifier> CreateAnalyzerTest<
TestState =
{
Sources = { inputSource },
ReferenceAssemblies = new ReferenceAssemblies(
"net8.0",
new PackageIdentity(
"Microsoft.NETCore.App.Ref",
"8.0.0"),
Path.Combine("ref", "net8.0")),
ReferenceAssemblies = Utility.ReferenceAssemblies,
},
};

Expand Down Expand Up @@ -113,13 +108,7 @@ public static CSharpSuppressorTest<TSuppressor, DefaultVerifier> CreateSuppresso
var test = new CSharpSuppressorTest<TSuppressor, DefaultVerifier>
{
TestCode = inputSource,
ReferenceAssemblies = new ReferenceAssemblies(
"net8.0",
new PackageIdentity(
"Microsoft.NETCore.App.Ref",
"8.0.0"),
Path.Combine("ref", "net8.0")
),
ReferenceAssemblies = Utility.ReferenceAssemblies,
CompilerDiagnostics = CompilerDiagnostics.Warnings,
DisabledDiagnostics =
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ private static void AdditionalValidations(ValidationResult errors, Data target)
[Fact]
public async Task NoRefactorOnNonValidatedClass() =>
await CodeRefactoringTestHelper.CreateCodeRefactoringTest<AddAdditionalValidationsCodeRefactoringProvider>(
$$"""
"""
namespace Immediate.Validations.Shared;

public sealed record {|Refactoring:Data|}
{
}
""",
$$"""
"""
namespace Immediate.Validations.Shared;

public sealed record Data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ public sealed class AddValidateMethodCodefixProviderTests
[Fact]
public async Task AddValidateMethod() =>
await CodeFixTestHelper.CreateCodeFixTest<ValidatorClassAnalyzer, AddValidateMethodCodefixProvider>(
$$"""
"""
namespace Immediate.Validations.Shared;

public sealed class {|IV0001:TestAttribute|} : ValidatorAttribute
{
public const string DefaultMessage = "";
}
""",
$$"""
"""
namespace Immediate.Validations.Shared;

public sealed class TestAttribute : ValidatorAttribute
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,7 @@ public static CSharpCodeFixTest<TAnalyzer, TCodeFix, DefaultVerifier> CreateCode
{
Sources = { inputSource },
AnalyzerConfigFiles = { { ("/.editorconfig", EditorConfig) } },
ReferenceAssemblies = new ReferenceAssemblies(
"net8.0",
new PackageIdentity(
"Microsoft.NETCore.App.Ref",
"8.0.0"),
Path.Combine("ref", "net8.0")),
ReferenceAssemblies = Utility.ReferenceAssemblies,
},
FixedState = { MarkupHandling = MarkupMode.IgnoreFixable, Sources = { fixedSource } },
};
Expand Down
Loading