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
4 changes: 2 additions & 2 deletions Version.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

<!-- Dependency versions -->
<PropertyGroup>
<ANcpLuaAnalyzersVersion>1.29.1</ANcpLuaAnalyzersVersion>
<ANcpLuaAnalyzersVersion>1.29.2</ANcpLuaAnalyzersVersion>
<MeziantouAnalyzerVersion>3.0.84</MeziantouAnalyzerVersion>
<ANcpLuaRoslynUtilitiesVersion>2.2.9</ANcpLuaRoslynUtilitiesVersion>
<ANcpLuaRoslynUtilitiesVersion>2.2.12</ANcpLuaRoslynUtilitiesVersion>
<MicrosoftCodeAnalysisAnalyzersVersion>5.3.0</MicrosoftCodeAnalysisAnalyzersVersion>
<MicrosoftCodeAnalysisCSharpVersion>5.3.0</MicrosoftCodeAnalysisCSharpVersion>
<MicrosoftCodeAnalysisBannedApiAnalyzersVersion>3.3.4</MicrosoftCodeAnalysisBannedApiAnalyzersVersion>
Expand Down
4 changes: 2 additions & 2 deletions src/ErrorOrX.Generators/Analyzers/ErrorOrEndpointAnalyzer.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using ANcpLua.Roslyn.Utilities;
using ErrorOr.Generators;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
Expand Down Expand Up @@ -388,8 +389,7 @@ private static bool IsErrorOr(ITypeSymbol type)

// Extract pattern from constructor arguments
var patternIndex = attrName.Contains("ErrorOrEndpoint") ? 1 : 0;
if (attr.ConstructorArguments.Length > patternIndex &&
attr.ConstructorArguments[patternIndex].Value is string p)
if (attr.GetConstructorArgument<string>(patternIndex) is { } p)
{
pattern = p;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using ANcpLua.Roslyn.Utilities.Models;
using ANcpLua.Roslyn.Utilities;
using ErrorOr.Analyzers;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
Expand Down Expand Up @@ -477,8 +478,7 @@ private static (HttpVerb? Verb, string Pattern, string? CustomMethod) ExtractHtt

// Extract pattern - index differs for ErrorOrEndpoint (has httpMethod arg first)
var patternIndex = isErrorOrEndpoint ? 1 : 0;
var pattern = attr.ConstructorArguments.Length > patternIndex &&
attr.ConstructorArguments[patternIndex].Value is string p
var pattern = attr.GetConstructorArgument<string>(patternIndex) is { } p
? p
: "/";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Text.RegularExpressions;
using ANcpLua.Roslyn.Utilities;
using ANcpLua.Roslyn.Utilities.Matching;
using ANcpLua.Roslyn.Utilities.Models;
using ErrorOr.Analyzers;
Expand Down Expand Up @@ -860,9 +861,9 @@ private static (bool IsNullable, bool IsNonNullableValueType) GetParameterNullab
var matcher = new AttributeNameMatcher(WellKnownTypes.FromKeyedServicesAttribute);
var attr = parameter.GetAttributes().FirstOrDefault(a => matcher.IsMatch(a.AttributeClass));

if (attr is null || attr.ConstructorArguments.Length is 0) return null;
if (attr is null) return null;

var val = attr.ConstructorArguments[0].Value;
var val = attr.GetConstructorArgument<object>(0);
return val switch { string s => $"\"{s}\"", null => null, _ => val.ToString() };
}

Expand Down Expand Up @@ -892,8 +893,7 @@ private static bool HasParameterAttribute(ISymbol parameter, ErrorOrContext cont
}
}

if (attr.ConstructorArguments.Length > 0 &&
attr.ConstructorArguments[0].Value is string ctorArg &&
if (attr.GetConstructorArgument<string>(0) is { } ctorArg &&
!string.IsNullOrWhiteSpace(ctorArg))
{
return ctorArg;
Expand Down
9 changes: 8 additions & 1 deletion src/ErrorOrX.Generators/ErrorOrX.Generators.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,15 @@
ANcpLua.Roslyn.Utilities.Sources (AsyncBatchingWorkQueue, IncrementalValuesProviderExtensions).
These are deliberate try/catch patterns in resilient infrastructure code.
.editorconfig cannot suppress diagnostics in NuGet cache paths.

AL0140: The generator emitter code intentionally relies on local type inference for
Roslyn syntax construction where explicit types add noise rather than safety.

RS1035: ANcpLua.Roslyn.Utilities.Sources contains environment-variable checks in
source-package infrastructure; suppress here until the upstream package removes that
analyzer-host API usage.
-->
<NoWarn>$(NoWarn);NU5128;RS1038;ERP022</NoWarn>
<NoWarn>$(NoWarn);NU5128;RS1038;ERP022;AL0140;RS1035</NoWarn>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>false</IncludeSymbols>
Expand Down
10 changes: 4 additions & 6 deletions src/ErrorOrX.Generators/OpenApiTransformerGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using ANcpLua.Roslyn.Utilities;

Check warning on line 1 in src/ErrorOrX.Generators/OpenApiTransformerGenerator.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/ErrorOrX.Generators/OpenApiTransformerGenerator.cs#L1

File src/ErrorOrX.Generators/OpenApiTransformerGenerator.cs has 651 non-comment lines of code
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
Expand Down Expand Up @@ -110,8 +111,7 @@

private static string GetPattern(AttributeData attr)
{
if (attr.ConstructorArguments.Length > 0 &&
attr.ConstructorArguments[0].Value is string p &&
if (attr.GetConstructorArgument<string>(0) is { } p &&
!string.IsNullOrWhiteSpace(p))
{
return p;
Expand All @@ -122,10 +122,8 @@

private static (string? httpMethod, string? pattern) GetBaseAttributeInfo(AttributeData attr)
{
if (attr.ConstructorArguments.Length < 2) return (null, null);

var method = attr.ConstructorArguments[0].Value as string;
var pattern = attr.ConstructorArguments[1].Value as string;
var method = attr.GetConstructorArgument<string>(0);
var pattern = attr.GetConstructorArgument<string>(1);

return string.IsNullOrWhiteSpace(method)
? (null, null)
Expand Down
Loading