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: 1 addition & 1 deletion src/Immediate.Apis.Generators/EquatableReadOnlyList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Immediate.Apis.Generators;
public static class EquatableReadOnlyList
{
public static EquatableReadOnlyList<T> ToEquatableReadOnlyList<T>(this IEnumerable<T> enumerable)
=> new(enumerable.ToArray());
=> new(enumerable is IReadOnlyList<T> l ? l : [.. enumerable]);
}

/// <summary>
Expand Down
22 changes: 12 additions & 10 deletions src/Immediate.Apis.Generators/ImmediateApisGenerator.Transform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,27 @@ CancellationToken token
var authorize = authorizeAttribute != null;
var authorizePolicy = string.Empty;

if (authorizeAttribute != null)
switch (authorizeAttribute)
{
if (authorizeAttribute.ConstructorArguments.Length > 0)
{
case { ConstructorArguments.Length: > 0 }:
authorizePolicy = (string)authorizeAttribute.ConstructorArguments[0].Value!;
}
else if (authorizeAttribute.NamedArguments.Length > 0)
break;

case { NamedArguments.Length: > 0 }:
{
foreach (var argument in authorizeAttribute.NamedArguments)
{
if (argument.Key is not "Policy")
return null;

if (argument.Value.Value is not string ap)
if (argument is not { Key: "Policy", Value.Value: string ap })
return null;

authorizePolicy = ap;
}

break;
}

default:
break;
}

token.ThrowIfCancellationRequested();
Expand All @@ -70,7 +72,7 @@ CancellationToken token

token.ThrowIfCancellationRequested();

var classAsMethodName = symbol.ToString().Replace(".", "_");
var classAsMethodName = symbol.ToString().Replace('.', '_');

token.ThrowIfCancellationRequested();

Expand Down