From 84c70324a95d587c93c045ea4f4ca7e383d75e38 Mon Sep 17 00:00:00 2001 From: ancplua Date: Fri, 6 Feb 2026 13:08:10 +0100 Subject: [PATCH 1/2] chore: clean up test suite and update dependencies Remove Verify.SourceGenerators dependency (lacks net10.0 TFM, caused IDE resolution failures on every restart). Remove 7 redundant tests that were strictly weaker than existing snapshot coverage. Extract shared attributes boilerplate from 72 snapshot files into a single dedicated test, reducing per-snapshot noise by ~108 lines each (-7,823 lines total). Test cleanup: - Remove 3 assertion-only diagnostic tests from ParameterBindingTests (EOE006/EOE010/EOE014 already covered by DiagnosticTests snapshots) - Remove 3 trivial .NotBeEmpty() tests from GeneratorCachingTests - Remove redundant middleware chain test from MiddlewareEmissionTests - Add Generator_Emits_Shared_Attributes_File as single source of truth Dependency updates: - ANcpLua.Roslyn.Utilities 1.28.0 -> 1.30.2 - ANcpLua.NET.Sdk 2.0.0 -> 2.0.4 - Suppress RS1038 in generator project 446 tests pass, 0 failures. Co-Authored-By: Claude Opus 4.6 --- Directory.Build.props | 2 +- Directory.Packages.props | 3 +- global.json | 6 +- .../ErrorOrX.Generators.csproj | 2 +- .../ErrorOrX.Generators.Tests.csproj | 1 - .../GeneratorCachingTests.cs | 69 +---------- .../GeneratorTestBase.cs | 5 + .../MiddlewareEmissionTests.cs | 32 ----- .../ModuleInitializer.cs | 9 +- .../ParameterBindingTests.cs | 77 ------------ ...n_With_Status_Suffix_Is_Valid.verified.txt | 107 ----------------- ...pToApiVersion_Reports_Warning.verified.txt | 107 ----------------- ...ared_Versions_Reports_Warning.verified.txt | 107 ----------------- ...ot_Referenced_Reports_Warning.verified.txt | 107 ----------------- ...ersioned_Project_Reports_Info.verified.txt | 107 ----------------- ...nostic_When_ApiVersionNeutral.verified.txt | 107 ----------------- ...c_When_No_Versioned_Endpoints.verified.txt | 107 ----------------- ...n_Format_Semver_Reports_Error.verified.txt | 110 +----------------- ...Format_V_Prefix_Reports_Error.verified.txt | 110 +----------------- ...apToApiVersion_No_Diagnostics.verified.txt | 107 ----------------- ...ats_Do_Not_Report_Diagnostics.verified.txt | 107 ----------------- ..._Class_Applies_To_All_Methods.verified.txt | 107 ----------------- ...ass_Emits_IsApiVersionNeutral.verified.txt | 107 ----------------- ...ethod_Overrides_Class_Version.verified.txt | 107 ----------------- ..._Single_Parameter_Constructor.verified.txt | 107 ----------------- ...Emits_HasDeprecatedApiVersion.verified.txt | 107 ----------------- ..._Method_Emits_MapToApiVersion.verified.txt | 107 ----------------- ...s_On_Class_Emits_All_Versions.verified.txt | 107 ----------------- ..._On_Method_Emits_All_Mappings.verified.txt | 107 ----------------- ...es_Generates_No_Version_Calls.verified.txt | 107 ----------------- ..._On_Class_Emits_HasApiVersion.verified.txt | 107 ----------------- ..._Error_Factory_Does_Not_Crash.verified.txt | 107 ----------------- ...riables_With_Different_Errors.verified.txt | 107 ----------------- ...te_Parameter_Names_First_Wins.verified.txt | 107 ----------------- ...oup_With_Valid_Endpoint_Works.verified.txt | 107 ----------------- ...ocal_Variables_In_Route_Group.verified.txt | 107 ----------------- ...003_Route_Parameter_Not_Bound.verified.txt | 110 +----------------- ...ter_With_Constraint_Not_Bound.verified.txt | 110 +----------------- ...s.EOE005_Empty_Parameter_Name.verified.txt | 110 +----------------- ...OE005_Unclosed_Brace_In_Route.verified.txt | 110 +----------------- ....EOE005_Unmatched_Close_Brace.verified.txt | 110 +----------------- ...Sources_FromBody_And_FromForm.verified.txt | 110 +----------------- ...y_Sources_Stream_And_FromBody.verified.txt | 110 +----------------- ...E007_Type_Not_In_Json_Context.verified.txt | 107 ----------------- ...nvalid_FromRoute_Type_Complex.verified.txt | 110 +----------------- ...nvalid_FromQuery_Type_Complex.verified.txt | 110 +----------------- ...d_AsParameters_Type_Primitive.verified.txt | 107 ----------------- ...3_AsParameters_No_Constructor.verified.txt | 110 +----------------- ...valid_FromHeader_Type_Complex.verified.txt | 110 +----------------- ....EOE015_Anonymous_Return_Type.verified.txt | 107 ----------------- ...ts.EOE016_Nested_AsParameters.verified.txt | 107 ----------------- ....EOE017_Nullable_AsParameters.verified.txt | 110 +----------------- ...ts.EOE018_Private_Return_Type.verified.txt | 110 +----------------- ...EOE019_Generic_Type_Parameter.verified.txt | 110 +----------------- ...Constraint_With_Int_Parameter.verified.txt | 107 ----------------- ...straint_With_String_Parameter.verified.txt | 107 ----------------- ...ype_On_Delete_Without_Binding.verified.txt | 110 +----------------- ...x_Type_On_Get_Without_Binding.verified.txt | 110 +----------------- ....EOE022_Too_Many_Result_Types.verified.txt | 107 ----------------- ....EOE023_Unknown_Error_Factory.verified.txt | 107 ----------------- ...h_ProducesError_No_Diagnostic.verified.txt | 107 ----------------- ...4_Undocumented_Interface_Call.verified.txt | 110 +----------------- ...E025_Missing_CamelCase_Policy.verified.txt | 107 ----------------- ...amelCase_Policy_No_Diagnostic.verified.txt | 107 ----------------- ...3_Method_Name_Lowercase_Start.verified.txt | 107 ----------------- ...EOE033_Method_Name_Snake_Case.verified.txt | 107 ----------------- ...3_Method_Name_With_Underscore.verified.txt | 107 ----------------- ...ultiple_Validation_Attributes.verified.txt | 107 ----------------- ...dation_Attribute_On_Parameter.verified.txt | 107 ----------------- ...ProblemDetails_In_JsonContext.verified.txt | 107 ----------------- ...c_When_ProblemDetails_Present.verified.txt | 107 ----------------- ...omplex_Type_With_AsParameters.verified.txt | 107 ----------------- ...ex_Type_With_FromBody_On_Post.verified.txt | 107 ----------------- ...s.Valid_Route_Parameter_Bound.verified.txt | 107 ----------------- ...s.Valid_Service_Type_Inferred.verified.txt | 107 ----------------- ...uplicate_Route_Across_Classes.verified.txt | 107 ----------------- ...ith_Different_Parameter_Names.verified.txt | 107 ----------------- ..._Emits_Shared_Attributes_File.verified.txt | 107 +++++++++++++++++ ..._Params_Bind_Route_Parameters.verified.txt | 107 ----------------- ...utes_Are_Normalized_Correctly.verified.txt | 107 ----------------- ...onstraints_Are_Not_Duplicates.verified.txt | 107 ----------------- ...Supports_Multiple_Constraints.verified.txt | 107 ----------------- 82 files changed, 144 insertions(+), 7823 deletions(-) create mode 100644 tests/ErrorOrX.Generators.Tests/Snapshots/GeneratorCachingTests.Generator_Emits_Shared_Attributes_File.verified.txt diff --git a/Directory.Build.props b/Directory.Build.props index e5fafd4..2d134ac 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -6,7 +6,7 @@ - 1.28.0 + 1.30.2 diff --git a/Directory.Packages.props b/Directory.Packages.props index 42a140a..84f0cd3 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -7,7 +7,7 @@ - + @@ -20,7 +20,6 @@ - diff --git a/global.json b/global.json index 1ec25b0..c0d6c37 100644 --- a/global.json +++ b/global.json @@ -5,9 +5,9 @@ "allowPrerelease": true }, "msbuild-sdks": { - "ANcpLua.NET.Sdk": "2.0.0", - "ANcpLua.NET.Sdk.Web": "2.0.0", - "ANcpLua.NET.Sdk.Test": "2.0.0" + "ANcpLua.NET.Sdk": "2.0.4", + "ANcpLua.NET.Sdk.Web": "2.0.4", + "ANcpLua.NET.Sdk.Test": "2.0.4" }, "test": { "runner": "Microsoft.Testing.Platform" diff --git a/src/ErrorOrX.Generators/ErrorOrX.Generators.csproj b/src/ErrorOrX.Generators/ErrorOrX.Generators.csproj index bfcf89a..4bc49c9 100644 --- a/src/ErrorOrX.Generators/ErrorOrX.Generators.csproj +++ b/src/ErrorOrX.Generators/ErrorOrX.Generators.csproj @@ -12,7 +12,7 @@ true true true - $(NoWarn);NU5128 + $(NoWarn);NU5128;RS1038 true true false diff --git a/tests/ErrorOrX.Generators.Tests/ErrorOrX.Generators.Tests.csproj b/tests/ErrorOrX.Generators.Tests/ErrorOrX.Generators.Tests.csproj index 016fb88..777ec14 100644 --- a/tests/ErrorOrX.Generators.Tests/ErrorOrX.Generators.Tests.csproj +++ b/tests/ErrorOrX.Generators.Tests/ErrorOrX.Generators.Tests.csproj @@ -9,7 +9,6 @@ - diff --git a/tests/ErrorOrX.Generators.Tests/GeneratorCachingTests.cs b/tests/ErrorOrX.Generators.Tests/GeneratorCachingTests.cs index 3da1d3f..e0f2d8b 100644 --- a/tests/ErrorOrX.Generators.Tests/GeneratorCachingTests.cs +++ b/tests/ErrorOrX.Generators.Tests/GeneratorCachingTests.cs @@ -6,81 +6,24 @@ namespace ErrorOrX.Generators.Tests; public class GeneratorCachingTests : GeneratorTestBase { [Fact] - public async Task Generator_Produces_Output_For_Simple_Endpoint() + public async Task Generator_Emits_Shared_Attributes_File() { const string Source = """ using ErrorOr; - - namespace CachingTest; + namespace AttributeTest; public static class TestEndpoints { - [Get("/cached")] - public static ErrorOr Get() => "cached"; - } - """; - - using var result = await RunAsync(Source); - - result.Files.Should().NotBeEmpty(); - } - - [Fact] - public async Task Generator_Produces_Output_For_Multiple_Endpoints() - { - const string Source = """ - using ErrorOr; - - - namespace CachingTest; - - public static class MultipleEndpoints - { - [Get("/one")] - public static ErrorOr GetOne() => "one"; - - [Post("/two")] - public static ErrorOr PostTwo() => 42; - - [Delete("/three/{id}")] - public static ErrorOr DeleteThree(int id) => true; - } - """; - - using var result = await RunAsync(Source); - - result.Files.Should().NotBeEmpty(); - } - - [Fact] - public async Task Generator_Handles_Complex_Parameters() - { - const string Source = """ - using ErrorOr; - - using Microsoft.AspNetCore.Mvc; - - namespace CachingTest; - - public record CreateRequest(string Name, int Value); - public record Response(int Id, string Name); - - public static class ComplexEndpoints - { - [Post("/items")] - public static ErrorOr Create([FromBody] CreateRequest request) - => new Response(1, request.Name); - - [Get("/items/{id}")] - public static ErrorOr GetById(int id) - => new Response(id, "item"); + [Get("/test")] + public static ErrorOr Get() => "test"; } """; using var result = await RunAsync(Source); - result.Files.Should().NotBeEmpty(); + var attributes = result.Files.First(static f => f.HintName == "ErrorOrEndpointAttributes.Mappings.g.cs"); + await Verify(new { attributes.HintName, Source = attributes.Content }).UseDirectory("Snapshots"); } [Fact] diff --git a/tests/ErrorOrX.Generators.Tests/GeneratorTestBase.cs b/tests/ErrorOrX.Generators.Tests/GeneratorTestBase.cs index 20a986a..bfda2fb 100644 --- a/tests/ErrorOrX.Generators.Tests/GeneratorTestBase.cs +++ b/tests/ErrorOrX.Generators.Tests/GeneratorTestBase.cs @@ -80,8 +80,11 @@ protected static async Task RunWithoutVersioningAsync(string so return await Test.Run(source, TestContext.Current.CancellationToken); } + private const string AttributesHintName = "ErrorOrEndpointAttributes.Mappings.g.cs"; + /// /// Runs the generator and verifies output using Verify snapshots. + /// Excludes the shared attributes file (tested once in GeneratorCachingTests). /// protected static async Task VerifyAsync(string source) { @@ -90,6 +93,7 @@ protected static async Task VerifyAsync(string source) await Verify(new { GeneratedSources = result.Files + .Where(static f => f.HintName != AttributesHintName) .Select(static f => new { f.HintName, Source = f.Content }) .OrderBy(static s => s.HintName), Diagnostics = result.Diagnostics @@ -109,6 +113,7 @@ protected static async Task VerifyWithoutVersioningAsync(string source) await Verify(new { GeneratedSources = result.Files + .Where(static f => f.HintName != AttributesHintName) .Select(static f => new { f.HintName, Source = f.Content }) .OrderBy(static s => s.HintName), Diagnostics = result.Diagnostics diff --git a/tests/ErrorOrX.Generators.Tests/MiddlewareEmissionTests.cs b/tests/ErrorOrX.Generators.Tests/MiddlewareEmissionTests.cs index 30f8eeb..7f8817d 100644 --- a/tests/ErrorOrX.Generators.Tests/MiddlewareEmissionTests.cs +++ b/tests/ErrorOrX.Generators.Tests/MiddlewareEmissionTests.cs @@ -448,38 +448,6 @@ public static class Api generated.Should().Contain(".CacheOutput(\"ApiCache\")"); } - [Fact] - public async Task Authorize_And_RateLimiting_Chain_Correctly() - { - const string Source = """ - using ErrorOr; - using Microsoft.AspNetCore.Authorization; - using Microsoft.AspNetCore.RateLimiting; - - public static class Api - { - [Get("/secured")] - [Authorize] - [EnableRateLimiting("api")] - public static ErrorOr Secured() => "secured"; - } - """; - - using var result = await RunAsync(Source); - - result.Diagnostics.Should().BeEmpty(); - var generated = result.Files.First(static f => f.HintName == "ErrorOrEndpointMappings.cs").Content; - // Both should be chained in fluent style - var mappingLine = generated.Split('\n') - .FirstOrDefault(static l => - l.Contains("MapGet", StringComparison.Ordinal) && l.Contains("/secured", StringComparison.Ordinal)); - mappingLine.Should().NotBeNull(); - - // Verify both middleware calls are present in the endpoint builder chain - generated.Should().Contain(".RequireAuthorization()"); - generated.Should().Contain(".RequireRateLimiting(\"api\")"); - } - #endregion #region Endpoint Naming and Tags diff --git a/tests/ErrorOrX.Generators.Tests/ModuleInitializer.cs b/tests/ErrorOrX.Generators.Tests/ModuleInitializer.cs index 9e2cc92..ef8b3a5 100644 --- a/tests/ErrorOrX.Generators.Tests/ModuleInitializer.cs +++ b/tests/ErrorOrX.Generators.Tests/ModuleInitializer.cs @@ -1,5 +1,4 @@ using System.Runtime.CompilerServices; -using VerifyTests; namespace ErrorOrX.Generators.Tests; @@ -9,17 +8,11 @@ namespace ErrorOrX.Generators.Tests; file static class ModuleInitializer { [ModuleInitializer] - public static void Initialize() - { - // Initialize Verify.SourceGenerators - handles GeneratorDriverRunResult serialization - // This properly handles ImmutableArray and other Roslyn types - VerifySourceGenerators.Initialize(); - + public static void Initialize() => // Configure Verify to properly serialize EquatableArray as arrays // This prevents the ImmutableArray default instance error during serialization VerifierSettings.AddExtraSettings(static settings => settings.Converters.Add(new EquatableArrayJsonConverter())); - } } /// diff --git a/tests/ErrorOrX.Generators.Tests/ParameterBindingTests.cs b/tests/ErrorOrX.Generators.Tests/ParameterBindingTests.cs index 8e39746..4b3a5df 100644 --- a/tests/ErrorOrX.Generators.Tests/ParameterBindingTests.cs +++ b/tests/ErrorOrX.Generators.Tests/ParameterBindingTests.cs @@ -658,81 +658,4 @@ public static class Api #endregion - #region Validation Diagnostics - - [Fact] - public async Task Multiple_Body_Sources_Emits_EOE006() - { - const string Source = """ - using ErrorOr; - using Microsoft.AspNetCore.Mvc; - using System.Text.Json.Serialization; - using Microsoft.AspNetCore.Http; - - public record Request1(string A); - public record Request2(string B); - - public static class Api - { - [Post("/test")] - public static ErrorOr Handler([FromBody] Request1 r1, [FromBody] Request2 r2) - => r1.A + r2.B; - } - - [JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)] - [JsonSerializable(typeof(Request1))] - [JsonSerializable(typeof(Request2))] - [JsonSerializable(typeof(ProblemDetails))] - [JsonSerializable(typeof(HttpValidationProblemDetails))] - internal partial class TestJsonContext : JsonSerializerContext { } - """; - - using var result = await RunAsync(Source); - - result.Diagnostics.Should().ContainSingle(static d => d.Id == "EOE006"); - } - - [Fact] - public async Task Invalid_FromRoute_Type_Emits_EOE010() - { - const string Source = """ - using ErrorOr; - using Microsoft.AspNetCore.Mvc; - - public record ComplexType(string A, string B); - - public static class Api - { - [Get("/items/{id}")] - public static ErrorOr Handler([FromRoute] ComplexType id) => "test"; - } - """; - - using var result = await RunAsync(Source); - - result.Diagnostics.Should().ContainSingle(static d => d.Id == "EOE010"); - } - - [Fact] - public async Task Invalid_FromHeader_Type_Emits_EOE014() - { - const string Source = """ - using ErrorOr; - using Microsoft.AspNetCore.Mvc; - - public record ComplexType(string A, string B); - - public static class Api - { - [Get("/test")] - public static ErrorOr Handler([FromHeader] ComplexType header) => "test"; - } - """; - - using var result = await RunAsync(Source); - - result.Diagnostics.Should().ContainSingle(static d => d.Id == "EOE014"); - } - - #endregion } diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.ApiVersion_With_Status_Suffix_Is_Valid.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.ApiVersion_With_Status_Suffix_Is_Valid.verified.txt index 6f5fa65..f62de2c 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.ApiVersion_With_Status_Suffix_Is_Valid.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.ApiVersion_With_Status_Suffix_Is_Valid.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.EOE027_ApiVersionNeutral_With_MapToApiVersion_Reports_Warning.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.EOE027_ApiVersionNeutral_With_MapToApiVersion_Reports_Warning.verified.txt index 0bd45cc..787e86f 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.EOE027_ApiVersionNeutral_With_MapToApiVersion_Reports_Warning.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.EOE027_ApiVersionNeutral_With_MapToApiVersion_Reports_Warning.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.EOE028_MapToApiVersion_Not_In_Declared_Versions_Reports_Warning.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.EOE028_MapToApiVersion_Not_In_Declared_Versions_Reports_Warning.verified.txt index 85b3511..b2af058 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.EOE028_MapToApiVersion_Not_In_Declared_Versions_Reports_Warning.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.EOE028_MapToApiVersion_Not_In_Declared_Versions_Reports_Warning.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.EOE029_ApiVersioning_Package_Not_Referenced_Reports_Warning.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.EOE029_ApiVersioning_Package_Not_Referenced_Reports_Warning.verified.txt index 8296c95..41013e6 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.EOE029_ApiVersioning_Package_Not_Referenced_Reports_Warning.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.EOE029_ApiVersioning_Package_Not_Referenced_Reports_Warning.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.EOE030_Endpoint_Missing_Versioning_In_Versioned_Project_Reports_Info.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.EOE030_Endpoint_Missing_Versioning_In_Versioned_Project_Reports_Info.verified.txt index 206bb8c..ba44fe6 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.EOE030_Endpoint_Missing_Versioning_In_Versioned_Project_Reports_Info.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.EOE030_Endpoint_Missing_Versioning_In_Versioned_Project_Reports_Info.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.EOE030_No_Diagnostic_When_ApiVersionNeutral.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.EOE030_No_Diagnostic_When_ApiVersionNeutral.verified.txt index b035767..0cb1831 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.EOE030_No_Diagnostic_When_ApiVersionNeutral.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.EOE030_No_Diagnostic_When_ApiVersionNeutral.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.EOE030_No_Diagnostic_When_No_Versioned_Endpoints.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.EOE030_No_Diagnostic_When_No_Versioned_Endpoints.verified.txt index 5ce9d53..b950b39 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.EOE030_No_Diagnostic_When_No_Versioned_Endpoints.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.EOE030_No_Diagnostic_When_No_Versioned_Endpoints.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.EOE031_Invalid_ApiVersion_Format_Semver_Reports_Error.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.EOE031_Invalid_ApiVersion_Format_Semver_Reports_Error.verified.txt index 1c4c639..81a1bed 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.EOE031_Invalid_ApiVersion_Format_Semver_Reports_Error.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.EOE031_Invalid_ApiVersion_Format_Semver_Reports_Error.verified.txt @@ -1,113 +1,5 @@ { - GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - } - ], + GeneratedSources: [], Diagnostics: [ { Id: EOE031, diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.EOE031_Invalid_ApiVersion_Format_V_Prefix_Reports_Error.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.EOE031_Invalid_ApiVersion_Format_V_Prefix_Reports_Error.verified.txt index a84dccb..13796d3 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.EOE031_Invalid_ApiVersion_Format_V_Prefix_Reports_Error.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.EOE031_Invalid_ApiVersion_Format_V_Prefix_Reports_Error.verified.txt @@ -1,113 +1,5 @@ { - GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - } - ], + GeneratedSources: [], Diagnostics: [ { Id: EOE031, diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.Multiple_Valid_MapToApiVersion_No_Diagnostics.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.Multiple_Valid_MapToApiVersion_No_Diagnostics.verified.txt index 0d57ac0..870385b 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.Multiple_Valid_MapToApiVersion_No_Diagnostics.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.Multiple_Valid_MapToApiVersion_No_Diagnostics.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.Valid_ApiVersion_Formats_Do_Not_Report_Diagnostics.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.Valid_ApiVersion_Formats_Do_Not_Report_Diagnostics.verified.txt index c9f706c..e086eed 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.Valid_ApiVersion_Formats_Do_Not_Report_Diagnostics.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningDiagnosticTests.Valid_ApiVersion_Formats_Do_Not_Report_Diagnostics.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.ApiVersionNeutral_On_Class_Applies_To_All_Methods.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.ApiVersionNeutral_On_Class_Applies_To_All_Methods.verified.txt index e2abf4d..4e08582 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.ApiVersionNeutral_On_Class_Applies_To_All_Methods.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.ApiVersionNeutral_On_Class_Applies_To_All_Methods.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.ApiVersionNeutral_On_Class_Emits_IsApiVersionNeutral.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.ApiVersionNeutral_On_Class_Emits_IsApiVersionNeutral.verified.txt index e946cf9..640f0d4 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.ApiVersionNeutral_On_Class_Emits_IsApiVersionNeutral.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.ApiVersionNeutral_On_Class_Emits_IsApiVersionNeutral.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.ApiVersionNeutral_On_Method_Overrides_Class_Version.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.ApiVersionNeutral_On_Method_Overrides_Class_Version.verified.txt index 23e3b78..3dab41f 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.ApiVersionNeutral_On_Method_Overrides_Class_Version.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.ApiVersionNeutral_On_Method_Overrides_Class_Version.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.ApiVersion_Major_Only_Emits_Single_Parameter_Constructor.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.ApiVersion_Major_Only_Emits_Single_Parameter_Constructor.verified.txt index 9d726a4..50f777d 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.ApiVersion_Major_Only_Emits_Single_Parameter_Constructor.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.ApiVersion_Major_Only_Emits_Single_Parameter_Constructor.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.Deprecated_ApiVersion_Emits_HasDeprecatedApiVersion.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.Deprecated_ApiVersion_Emits_HasDeprecatedApiVersion.verified.txt index 8feaac6..5b0d189 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.Deprecated_ApiVersion_Emits_HasDeprecatedApiVersion.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.Deprecated_ApiVersion_Emits_HasDeprecatedApiVersion.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.MapToApiVersion_On_Method_Emits_MapToApiVersion.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.MapToApiVersion_On_Method_Emits_MapToApiVersion.verified.txt index 64b56d0..73d095d 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.MapToApiVersion_On_Method_Emits_MapToApiVersion.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.MapToApiVersion_On_Method_Emits_MapToApiVersion.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.Multiple_ApiVersions_On_Class_Emits_All_Versions.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.Multiple_ApiVersions_On_Class_Emits_All_Versions.verified.txt index 0e84491..da2cafc 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.Multiple_ApiVersions_On_Class_Emits_All_Versions.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.Multiple_ApiVersions_On_Class_Emits_All_Versions.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.Multiple_MapToApiVersion_On_Method_Emits_All_Mappings.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.Multiple_MapToApiVersion_On_Method_Emits_All_Mappings.verified.txt index 13941a2..ab5ac7e 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.Multiple_MapToApiVersion_On_Method_Emits_All_Mappings.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.Multiple_MapToApiVersion_On_Method_Emits_All_Mappings.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.No_Versioning_Attributes_Generates_No_Version_Calls.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.No_Versioning_Attributes_Generates_No_Version_Calls.verified.txt index 2cbb155..0134c47 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.No_Versioning_Attributes_Generates_No_Version_Calls.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.No_Versioning_Attributes_Generates_No_Version_Calls.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.Single_ApiVersion_On_Class_Emits_HasApiVersion.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.Single_ApiVersion_On_Class_Emits_HasApiVersion.verified.txt index a370eee..28071a8 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.Single_ApiVersion_On_Class_Emits_HasApiVersion.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/ApiVersioningTests.Single_ApiVersion_On_Class_Emits_HasApiVersion.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/BugRegressionTests.BUG001_Local_Variable_Error_Factory_Does_Not_Crash.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/BugRegressionTests.BUG001_Local_Variable_Error_Factory_Does_Not_Crash.verified.txt index 68a5b60..db8cc93 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/BugRegressionTests.BUG001_Local_Variable_Error_Factory_Does_Not_Crash.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/BugRegressionTests.BUG001_Local_Variable_Error_Factory_Does_Not_Crash.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/BugRegressionTests.BUG001_Multiple_Local_Variables_With_Different_Errors.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/BugRegressionTests.BUG001_Multiple_Local_Variables_With_Different_Errors.verified.txt index 5ec6fbe..d28a179 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/BugRegressionTests.BUG001_Multiple_Local_Variables_With_Different_Errors.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/BugRegressionTests.BUG001_Multiple_Local_Variables_With_Different_Errors.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/BugRegressionTests.BUG004_Duplicate_Route_Parameter_Names_First_Wins.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/BugRegressionTests.BUG004_Duplicate_Route_Parameter_Names_First_Wins.verified.txt index 93dfb73..37fcf7b 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/BugRegressionTests.BUG004_Duplicate_Route_Parameter_Names_First_Wins.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/BugRegressionTests.BUG004_Duplicate_Route_Parameter_Names_First_Wins.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/BugRegressionTests.BUG005_Route_Group_With_Valid_Endpoint_Works.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/BugRegressionTests.BUG005_Route_Group_With_Valid_Endpoint_Works.verified.txt index 4e92611..d858629 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/BugRegressionTests.BUG005_Route_Group_With_Valid_Endpoint_Works.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/BugRegressionTests.BUG005_Route_Group_With_Valid_Endpoint_Works.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/BugRegressionTests.Combined_Local_Variables_In_Route_Group.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/BugRegressionTests.Combined_Local_Variables_In_Route_Group.verified.txt index 5650e0d..f93a981 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/BugRegressionTests.Combined_Local_Variables_In_Route_Group.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/BugRegressionTests.Combined_Local_Variables_In_Route_Group.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE003_Route_Parameter_Not_Bound.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE003_Route_Parameter_Not_Bound.verified.txt index b519670..be34b98 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE003_Route_Parameter_Not_Bound.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE003_Route_Parameter_Not_Bound.verified.txt @@ -1,113 +1,5 @@ { - GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - } - ], + GeneratedSources: [], Diagnostics: [ { Id: EOE003, diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE003_Route_Parameter_With_Constraint_Not_Bound.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE003_Route_Parameter_With_Constraint_Not_Bound.verified.txt index 3b32480..9c11ef5 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE003_Route_Parameter_With_Constraint_Not_Bound.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE003_Route_Parameter_With_Constraint_Not_Bound.verified.txt @@ -1,113 +1,5 @@ { - GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - } - ], + GeneratedSources: [], Diagnostics: [ { Id: EOE003, diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE005_Empty_Parameter_Name.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE005_Empty_Parameter_Name.verified.txt index d781641..de740af 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE005_Empty_Parameter_Name.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE005_Empty_Parameter_Name.verified.txt @@ -1,113 +1,5 @@ { - GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - } - ], + GeneratedSources: [], Diagnostics: [ { Id: EOE005, diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE005_Unclosed_Brace_In_Route.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE005_Unclosed_Brace_In_Route.verified.txt index 22292c2..9872d5b 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE005_Unclosed_Brace_In_Route.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE005_Unclosed_Brace_In_Route.verified.txt @@ -1,113 +1,5 @@ { - GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - } - ], + GeneratedSources: [], Diagnostics: [ { Id: EOE005, diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE005_Unmatched_Close_Brace.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE005_Unmatched_Close_Brace.verified.txt index 8c5dddb..c1cab80 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE005_Unmatched_Close_Brace.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE005_Unmatched_Close_Brace.verified.txt @@ -1,113 +1,5 @@ { - GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - } - ], + GeneratedSources: [], Diagnostics: [ { Id: EOE005, diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE006_Multiple_Body_Sources_FromBody_And_FromForm.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE006_Multiple_Body_Sources_FromBody_And_FromForm.verified.txt index e6ddfaa..060a198 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE006_Multiple_Body_Sources_FromBody_And_FromForm.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE006_Multiple_Body_Sources_FromBody_And_FromForm.verified.txt @@ -1,113 +1,5 @@ { - GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - } - ], + GeneratedSources: [], Diagnostics: [ { Id: EOE006, diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE006_Multiple_Body_Sources_Stream_And_FromBody.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE006_Multiple_Body_Sources_Stream_And_FromBody.verified.txt index 5ccffb1..ff4af37 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE006_Multiple_Body_Sources_Stream_And_FromBody.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE006_Multiple_Body_Sources_Stream_And_FromBody.verified.txt @@ -1,113 +1,5 @@ { - GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - } - ], + GeneratedSources: [], Diagnostics: [ { Id: EOE006, diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE007_Type_Not_In_Json_Context.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE007_Type_Not_In_Json_Context.verified.txt index dcd37db..2a4a7a8 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE007_Type_Not_In_Json_Context.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE007_Type_Not_In_Json_Context.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE010_Invalid_FromRoute_Type_Complex.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE010_Invalid_FromRoute_Type_Complex.verified.txt index fd16c55..64cf034 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE010_Invalid_FromRoute_Type_Complex.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE010_Invalid_FromRoute_Type_Complex.verified.txt @@ -1,113 +1,5 @@ { - GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - } - ], + GeneratedSources: [], Diagnostics: [ { Id: EOE010, diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE011_Invalid_FromQuery_Type_Complex.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE011_Invalid_FromQuery_Type_Complex.verified.txt index a9cfce0..23c5a36 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE011_Invalid_FromQuery_Type_Complex.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE011_Invalid_FromQuery_Type_Complex.verified.txt @@ -1,113 +1,5 @@ { - GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - } - ], + GeneratedSources: [], Diagnostics: [ { Id: EOE011, diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE012_Invalid_AsParameters_Type_Primitive.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE012_Invalid_AsParameters_Type_Primitive.verified.txt index 6d6d6c8..0a7e862 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE012_Invalid_AsParameters_Type_Primitive.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE012_Invalid_AsParameters_Type_Primitive.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE013_AsParameters_No_Constructor.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE013_AsParameters_No_Constructor.verified.txt index 4e3ec3d..748c471 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE013_AsParameters_No_Constructor.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE013_AsParameters_No_Constructor.verified.txt @@ -1,113 +1,5 @@ { - GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - } - ], + GeneratedSources: [], Diagnostics: [ { Id: EOE013, diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE014_Invalid_FromHeader_Type_Complex.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE014_Invalid_FromHeader_Type_Complex.verified.txt index 5919f5a..50862a6 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE014_Invalid_FromHeader_Type_Complex.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE014_Invalid_FromHeader_Type_Complex.verified.txt @@ -1,113 +1,5 @@ { - GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - } - ], + GeneratedSources: [], Diagnostics: [ { Id: EOE014, diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE015_Anonymous_Return_Type.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE015_Anonymous_Return_Type.verified.txt index c392b5d..d0410ee 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE015_Anonymous_Return_Type.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE015_Anonymous_Return_Type.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE016_Nested_AsParameters.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE016_Nested_AsParameters.verified.txt index 7a73c38..a68588b 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE016_Nested_AsParameters.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE016_Nested_AsParameters.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE017_Nullable_AsParameters.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE017_Nullable_AsParameters.verified.txt index 987ffd4..4d3df4f 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE017_Nullable_AsParameters.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE017_Nullable_AsParameters.verified.txt @@ -1,113 +1,5 @@ { - GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - } - ], + GeneratedSources: [], Diagnostics: [ { Id: EOE017, diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE018_Private_Return_Type.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE018_Private_Return_Type.verified.txt index ac21ee9..a6b9a5a 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE018_Private_Return_Type.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE018_Private_Return_Type.verified.txt @@ -1,113 +1,5 @@ { - GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - } - ], + GeneratedSources: [], Diagnostics: [ { Id: EOE018, diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE019_Generic_Type_Parameter.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE019_Generic_Type_Parameter.verified.txt index 1644a09..da29c3c 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE019_Generic_Type_Parameter.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE019_Generic_Type_Parameter.verified.txt @@ -1,113 +1,5 @@ { - GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - } - ], + GeneratedSources: [], Diagnostics: [ { Id: EOE019, diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE020_Guid_Constraint_With_Int_Parameter.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE020_Guid_Constraint_With_Int_Parameter.verified.txt index 716392f..d7c3d69 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE020_Guid_Constraint_With_Int_Parameter.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE020_Guid_Constraint_With_Int_Parameter.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE020_Int_Constraint_With_String_Parameter.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE020_Int_Constraint_With_String_Parameter.verified.txt index 5b6ee59..07f1e0c 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE020_Int_Constraint_With_String_Parameter.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE020_Int_Constraint_With_String_Parameter.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE021_Complex_Type_On_Delete_Without_Binding.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE021_Complex_Type_On_Delete_Without_Binding.verified.txt index aea448f..3c21a06 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE021_Complex_Type_On_Delete_Without_Binding.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE021_Complex_Type_On_Delete_Without_Binding.verified.txt @@ -1,113 +1,5 @@ { - GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - } - ], + GeneratedSources: [], Diagnostics: [ { Id: EOE021, diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE021_Complex_Type_On_Get_Without_Binding.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE021_Complex_Type_On_Get_Without_Binding.verified.txt index 1ef621e..0bd58f0 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE021_Complex_Type_On_Get_Without_Binding.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE021_Complex_Type_On_Get_Without_Binding.verified.txt @@ -1,113 +1,5 @@ { - GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - } - ], + GeneratedSources: [], Diagnostics: [ { Id: EOE021, diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE022_Too_Many_Result_Types.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE022_Too_Many_Result_Types.verified.txt index c383b25..1a66247 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE022_Too_Many_Result_Types.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE022_Too_Many_Result_Types.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE023_Unknown_Error_Factory.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE023_Unknown_Error_Factory.verified.txt index a252c4a..df434a0 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE023_Unknown_Error_Factory.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE023_Unknown_Error_Factory.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE024_Interface_Call_With_ProducesError_No_Diagnostic.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE024_Interface_Call_With_ProducesError_No_Diagnostic.verified.txt index 162d6c7..649e67b 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE024_Interface_Call_With_ProducesError_No_Diagnostic.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE024_Interface_Call_With_ProducesError_No_Diagnostic.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE024_Undocumented_Interface_Call.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE024_Undocumented_Interface_Call.verified.txt index 49cc65b..735eba7 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE024_Undocumented_Interface_Call.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE024_Undocumented_Interface_Call.verified.txt @@ -1,113 +1,5 @@ { - GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - } - ], + GeneratedSources: [], Diagnostics: [ { Id: EOE024, diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE025_Missing_CamelCase_Policy.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE025_Missing_CamelCase_Policy.verified.txt index 6104530..fd25b80 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE025_Missing_CamelCase_Policy.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE025_Missing_CamelCase_Policy.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE025_With_CamelCase_Policy_No_Diagnostic.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE025_With_CamelCase_Policy_No_Diagnostic.verified.txt index 604deaa..b1fb766 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE025_With_CamelCase_Policy_No_Diagnostic.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE025_With_CamelCase_Policy_No_Diagnostic.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE033_Method_Name_Lowercase_Start.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE033_Method_Name_Lowercase_Start.verified.txt index e5c823e..38d8ab6 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE033_Method_Name_Lowercase_Start.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE033_Method_Name_Lowercase_Start.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE033_Method_Name_Snake_Case.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE033_Method_Name_Snake_Case.verified.txt index caed288..a6acbeb 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE033_Method_Name_Snake_Case.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE033_Method_Name_Snake_Case.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE033_Method_Name_With_Underscore.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE033_Method_Name_With_Underscore.verified.txt index a7e8fca..1894ac3 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE033_Method_Name_With_Underscore.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE033_Method_Name_With_Underscore.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE039_Multiple_Validation_Attributes.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE039_Multiple_Validation_Attributes.verified.txt index 4ff8935..a141554 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE039_Multiple_Validation_Attributes.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE039_Multiple_Validation_Attributes.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE039_Validation_Attribute_On_Parameter.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE039_Validation_Attribute_On_Parameter.verified.txt index 586faff..1564b45 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE039_Validation_Attribute_On_Parameter.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE039_Validation_Attribute_On_Parameter.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE041_Missing_ProblemDetails_In_JsonContext.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE041_Missing_ProblemDetails_In_JsonContext.verified.txt index 604deaa..b1fb766 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE041_Missing_ProblemDetails_In_JsonContext.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE041_Missing_ProblemDetails_In_JsonContext.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE041_No_Diagnostic_When_ProblemDetails_Present.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE041_No_Diagnostic_When_ProblemDetails_Present.verified.txt index 639ac3c..f1538ea 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE041_No_Diagnostic_When_ProblemDetails_Present.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.EOE041_No_Diagnostic_When_ProblemDetails_Present.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.Valid_Complex_Type_With_AsParameters.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.Valid_Complex_Type_With_AsParameters.verified.txt index 4b2fa91..490a69d 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.Valid_Complex_Type_With_AsParameters.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.Valid_Complex_Type_With_AsParameters.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.Valid_Complex_Type_With_FromBody_On_Post.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.Valid_Complex_Type_With_FromBody_On_Post.verified.txt index 586faff..1564b45 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.Valid_Complex_Type_With_FromBody_On_Post.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.Valid_Complex_Type_With_FromBody_On_Post.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.Valid_Route_Parameter_Bound.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.Valid_Route_Parameter_Bound.verified.txt index 7bc0e91..4fa45b7 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.Valid_Route_Parameter_Bound.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.Valid_Route_Parameter_Bound.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.Valid_Service_Type_Inferred.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.Valid_Service_Type_Inferred.verified.txt index dd14609..084aece 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.Valid_Service_Type_Inferred.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DiagnosticTests.Valid_Service_Type_Inferred.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DuplicateRouteTests.Reports_Duplicate_Route_Across_Classes.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DuplicateRouteTests.Reports_Duplicate_Route_Across_Classes.verified.txt index 240958b..8cbde51 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DuplicateRouteTests.Reports_Duplicate_Route_Across_Classes.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DuplicateRouteTests.Reports_Duplicate_Route_Across_Classes.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/DuplicateRouteTests.Reports_Duplicate_Route_With_Different_Parameter_Names.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/DuplicateRouteTests.Reports_Duplicate_Route_With_Different_Parameter_Names.verified.txt index f602b34..6383006 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/DuplicateRouteTests.Reports_Duplicate_Route_With_Different_Parameter_Names.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/DuplicateRouteTests.Reports_Duplicate_Route_With_Different_Parameter_Names.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/GeneratorCachingTests.Generator_Emits_Shared_Attributes_File.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/GeneratorCachingTests.Generator_Emits_Shared_Attributes_File.verified.txt new file mode 100644 index 0000000..af06bea --- /dev/null +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/GeneratorCachingTests.Generator_Emits_Shared_Attributes_File.verified.txt @@ -0,0 +1,107 @@ +{ + HintName: ErrorOrEndpointAttributes.Mappings.g.cs, + Source: +// +#nullable enable + +namespace ErrorOr +{ + /// + /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. + /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. + /// + [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] + public sealed class ErrorOrEndpointAttribute : global::System.Attribute + { + public ErrorOrEndpointAttribute(string httpMethod, string route) + { + HttpMethod = httpMethod; + Route = route; + } + public string HttpMethod { get; } + public string Route { get; } + } + + [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] + public sealed class GetAttribute : global::System.Attribute + { + public GetAttribute(string route) => Route = route; + public string Route { get; } + } + + [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] + public sealed class PostAttribute : global::System.Attribute + { + public PostAttribute(string route) => Route = route; + public string Route { get; } + } + + [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] + public sealed class PutAttribute : global::System.Attribute + { + public PutAttribute(string route) => Route = route; + public string Route { get; } + } + + [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] + public sealed class DeleteAttribute : global::System.Attribute + { + public DeleteAttribute(string route) => Route = route; + public string Route { get; } + } + + [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] + public sealed class PatchAttribute : global::System.Attribute + { + public PatchAttribute(string route) => Route = route; + public string Route { get; } + } + + [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] + public sealed class ProducesErrorAttribute : global::System.Attribute + { + public ProducesErrorAttribute(int statusCode, string errorType) + { + StatusCode = statusCode; + ErrorType = errorType; + } + public int StatusCode { get; } + public string ErrorType { get; } + } + + [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] + public sealed class AcceptedResponseAttribute : global::System.Attribute { } + + [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] + public sealed class ReturnsErrorAttribute : global::System.Attribute + { + public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) + { + ErrorType = errorType; + ErrorCode = errorCode; + } + public ReturnsErrorAttribute(int statusCode, string errorCode) + { + StatusCode = statusCode; + ErrorCode = errorCode; + ErrorType = null; + } + public global::ErrorOr.ErrorType? ErrorType { get; } + public int? StatusCode { get; } + public string ErrorCode { get; } + } + + /// + /// Marks a class as a route group for versioned API endpoints. + /// All endpoints in the class will be mapped under the specified path prefix + /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. + /// + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + public sealed class RouteGroupAttribute : global::System.Attribute + { + public RouteGroupAttribute(string path) => Path = path; + public string Path { get; } + public string? ApiName { get; set; } + } +} +} \ No newline at end of file diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/RouteConstraintTests.AsParameters_Constructor_Params_Bind_Route_Parameters.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/RouteConstraintTests.AsParameters_Constructor_Params_Bind_Route_Parameters.verified.txt index dc25f64..d427201 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/RouteConstraintTests.AsParameters_Constructor_Params_Bind_Route_Parameters.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/RouteConstraintTests.AsParameters_Constructor_Params_Bind_Route_Parameters.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/RouteConstraintTests.CatchAll_Routes_Are_Normalized_Correctly.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/RouteConstraintTests.CatchAll_Routes_Are_Normalized_Correctly.verified.txt index e6b5e83..ee591ec 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/RouteConstraintTests.CatchAll_Routes_Are_Normalized_Correctly.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/RouteConstraintTests.CatchAll_Routes_Are_Normalized_Correctly.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/RouteConstraintTests.Routes_With_Different_Constraints_Are_Not_Duplicates.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/RouteConstraintTests.Routes_With_Different_Constraints_Are_Not_Duplicates.verified.txt index de8be02..011bfe1 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/RouteConstraintTests.Routes_With_Different_Constraints_Are_Not_Duplicates.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/RouteConstraintTests.Routes_With_Different_Constraints_Are_Not_Duplicates.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: diff --git a/tests/ErrorOrX.Generators.Tests/Snapshots/RouteConstraintTests.Supports_Multiple_Constraints.verified.txt b/tests/ErrorOrX.Generators.Tests/Snapshots/RouteConstraintTests.Supports_Multiple_Constraints.verified.txt index 70d6d7d..e5697d7 100644 --- a/tests/ErrorOrX.Generators.Tests/Snapshots/RouteConstraintTests.Supports_Multiple_Constraints.verified.txt +++ b/tests/ErrorOrX.Generators.Tests/Snapshots/RouteConstraintTests.Supports_Multiple_Constraints.verified.txt @@ -1,112 +1,5 @@ { GeneratedSources: [ - { - HintName: ErrorOrEndpointAttributes.Mappings.g.cs, - Source: -// -#nullable enable - -namespace ErrorOr -{ - /// - /// Marks a static method as an ErrorOr endpoint with explicit HTTP method and route. - /// Prefer using [Get], [Post], [Put], [Delete], or [Patch] for standard HTTP methods. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class ErrorOrEndpointAttribute : global::System.Attribute - { - public ErrorOrEndpointAttribute(string httpMethod, string route) - { - HttpMethod = httpMethod; - Route = route; - } - public string HttpMethod { get; } - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class GetAttribute : global::System.Attribute - { - public GetAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PostAttribute : global::System.Attribute - { - public PostAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PutAttribute : global::System.Attribute - { - public PutAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class DeleteAttribute : global::System.Attribute - { - public DeleteAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class PatchAttribute : global::System.Attribute - { - public PatchAttribute(string route) => Route = route; - public string Route { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ProducesErrorAttribute : global::System.Attribute - { - public ProducesErrorAttribute(int statusCode, string errorType) - { - StatusCode = statusCode; - ErrorType = errorType; - } - public int StatusCode { get; } - public string ErrorType { get; } - } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false)] - public sealed class AcceptedResponseAttribute : global::System.Attribute { } - - [global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)] - public sealed class ReturnsErrorAttribute : global::System.Attribute - { - public ReturnsErrorAttribute(global::ErrorOr.ErrorType errorType, string errorCode) - { - ErrorType = errorType; - ErrorCode = errorCode; - } - public ReturnsErrorAttribute(int statusCode, string errorCode) - { - StatusCode = statusCode; - ErrorCode = errorCode; - ErrorType = null; - } - public global::ErrorOr.ErrorType? ErrorType { get; } - public int? StatusCode { get; } - public string ErrorCode { get; } - } - - /// - /// Marks a class as a route group for versioned API endpoints. - /// All endpoints in the class will be mapped under the specified path prefix - /// using the eShop-style NewVersionedApi() pattern when combined with [ApiVersion]. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - public sealed class RouteGroupAttribute : global::System.Attribute - { - public RouteGroupAttribute(string path) => Path = path; - public string Path { get; } - public string? ApiName { get; set; } - } -} - }, { HintName: ErrorOrEndpointMappings.cs, Source: From c8c4e9ba12bb4e07d16d882d4d31874ac679226a Mon Sep 17 00:00:00 2001 From: ancplua Date: Sat, 7 Feb 2026 22:32:11 +0100 Subject: [PATCH 2/2] chore(release): prepare v3.4.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix unreachable switch arm in Extractor.cs (ReturnsError enum vs int disambiguation now uses TypeKind.Enum check instead of pattern matching) - Add ErrorOrX.Integration.Tests to solution file - Remove phantom EOE055 from CHANGELOG (EOE032 covers it) - Bump version to 3.4.0 - Fix README analyzer count (38 → 41) - Fix CLAUDE.md dependency versions - Generator code cleanup from previous commits Build: 0 warnings, 455 tests pass (446 + 9 integration) Co-Authored-By: Claude Opus 4.6 --- .editorconfig | 18 +++- CHANGELOG.md | 22 ++++- CLAUDE.md | 2 +- ErrorOrX.slnx | 1 + README.md | 2 +- .../Demos/EOE001_InvalidReturnType.cs | 2 + .../Analyzers/AotSafetyAnalyzer.cs | 9 -- .../Analyzers/ErrorOrEndpointAnalyzer.cs | 36 +++---- .../Core/ErrorOrEndpointGenerator.Analyzer.cs | 2 +- .../Core/ErrorOrEndpointGenerator.Emitter.cs | 4 +- .../ErrorOrEndpointGenerator.Extractor.cs | 96 +++++++------------ ...rorOrEndpointGenerator.ParameterBinding.cs | 10 +- .../Emitters/GroupEmitter.cs | 2 +- .../ErrorOrX.Generators.csproj | 13 +++ .../Models/ParameterSource.cs | 71 ++++---------- .../OpenApiTransformerGenerator.cs | 2 +- src/ErrorOrX.Generators/Polyfills.cs | 2 - .../TypeResolution/WellKnownTypes.cs | 11 --- version.props | 2 +- 19 files changed, 130 insertions(+), 177 deletions(-) diff --git a/.editorconfig b/.editorconfig index 608cf57..fa05c3e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -65,4 +65,20 @@ resharper_redundant_nullable_warning_suppression_highlighting = none [**/src/**/*.cs] # CA1859 requires concrete types for performance; Rider's suggestion to widen conflicts -resharper_parameter_type_can_be_enumerable_local_highlighting = none \ No newline at end of file +resharper_parameter_type_can_be_enumerable_local_highlighting = none + +# ============================================================================ +# Generator-Specific Suppressions +# ============================================================================ + +# Polyfills.cs: Types MUST live in System.* namespaces for netstandard2.0 +# compatibility (e.g., System.Runtime.CompilerServices.IsExternalInit). +# The namespace intentionally does not match the folder structure. +[**/ErrorOrX.Generators/Polyfills.cs] +dotnet_diagnostic.IDE0130.severity = none + +# Extractor.cs: AL0029 flags foreach-over-GetAttributes() loops, suggesting +# HasAttribute() instead. These loops legitimately need to extract constructor +# arguments and named arguments from AttributeData, not just check existence. +[**/ErrorOrX.Generators/Core/ErrorOrEndpointGenerator.Extractor.cs] +dotnet_diagnostic.AL0029.severity = none \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 414c7f9..776c63d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,25 @@ All notable changes to this project are documented in this file. ## [Unreleased] +## [3.4.0] - 2026-02-07 + +### Changed + +- **Test suite cleanup**: Removed redundant assertion-based tests (-7,823 lines), consolidated shared boilerplate into + dedicated snapshot tests. 446 tests remain with identical coverage. + +- **Updated dependencies**: ANcpLua.Roslyn.Utilities 1.28.0 → 1.30.2, cleaned up .editorconfig with generator-specific + suppression rationale. + +- **Generator code cleanup**: Removed unused `ParameterSource` properties, simplified constructor signatures, added + documentation comments for suppressed warnings in .csproj. + +### Fixed + +- **Integration tests missing from solution**: Added `ErrorOrX.Integration.Tests` to `ErrorOrX.slnx`. + +- **Documentation accuracy**: Fixed README analyzer count (38 → 41), corrected CLAUDE.md dependency versions. + ## [3.3.0] - 2026-02-04 ### Removed @@ -47,9 +66,6 @@ All notable changes to this project are documented in this file. ### Added -- **EOE055 Diagnostic**: Warning when multiple method parameters bind to the same route parameter name. Helps catch - configuration errors early instead of silent "first wins" behavior. - - **BugRegressionTests**: New test class with regression tests for BUG-001 through BUG-005 to prevent future regressions. - **DiagnosticTests**: Comprehensive test class covering 26 diagnostic scenarios including EOE003 (route parameter not bound), diff --git a/CLAUDE.md b/CLAUDE.md index 11c0b76..7eaef5a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -215,7 +215,7 @@ tests/ | Package | Version | Purpose | |----------------------------------|---------|---------------------------------| -| ANcpLua.Roslyn.Utilities | 1.28.0 | Incremental generator utilities | +| ANcpLua.Roslyn.Utilities | 1.30.2 | Incremental generator utilities | | ANcpLua.Roslyn.Utilities.Testing | 1.28.0 | Generator testing framework | | ANcpLua.Analyzers | 1.13.0 | Code quality analyzers | | Microsoft.CodeAnalysis.CSharp | 5.0.0 | Roslyn APIs | diff --git a/ErrorOrX.slnx b/ErrorOrX.slnx index b9a38ec..3e75b17 100644 --- a/ErrorOrX.slnx +++ b/ErrorOrX.slnx @@ -26,5 +26,6 @@ + diff --git a/README.md b/README.md index fe280c7..cc96230 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Native AOT support. - **Middleware Support** - Translates ASP.NET Core attributes to Minimal API fluent calls (authorization, rate limiting, caching) - **API Versioning** - Integrates with Asp.Versioning.Http for versioned endpoint groups -- **38 Analyzers** - Real-time IDE feedback for route conflicts, binding errors, AOT compatibility +- **41 Analyzers** - Real-time IDE feedback for route conflicts, binding errors, AOT compatibility ## What the Generator Produces diff --git a/samples/DiagnosticsDemos/Demos/EOE001_InvalidReturnType.cs b/samples/DiagnosticsDemos/Demos/EOE001_InvalidReturnType.cs index ca87fb3..2f8c744 100644 --- a/samples/DiagnosticsDemos/Demos/EOE001_InvalidReturnType.cs +++ b/samples/DiagnosticsDemos/Demos/EOE001_InvalidReturnType.cs @@ -32,6 +32,8 @@ public static class EOE001_InvalidReturnType public static ErrorOr GetValidSync() { return "valid response"; + + } // ------------------------------------------------------------------------- diff --git a/src/ErrorOrX.Generators/Analyzers/AotSafetyAnalyzer.cs b/src/ErrorOrX.Generators/Analyzers/AotSafetyAnalyzer.cs index 678f253..fce94b3 100644 --- a/src/ErrorOrX.Generators/Analyzers/AotSafetyAnalyzer.cs +++ b/src/ErrorOrX.Generators/Analyzers/AotSafetyAnalyzer.cs @@ -243,15 +243,6 @@ private static string GetTypeArgument(IMethodSymbol method, InvocationExpression return "T"; } - private static string? GetFirstStringArgument(InvocationExpressionSyntax invocation) - { - if (invocation.ArgumentList.Arguments.Count is 0) - return null; - - var firstArg = invocation.ArgumentList.Arguments[0].Expression; - return firstArg is LiteralExpressionSyntax { Token.Value: string value } ? value : firstArg.ToString(); - } - private static string? GetReceiverTypeName(InvocationExpressionSyntax invocation, SemanticModel semanticModel) { if (invocation.Expression is not MemberAccessExpressionSyntax memberAccess) diff --git a/src/ErrorOrX.Generators/Analyzers/ErrorOrEndpointAnalyzer.cs b/src/ErrorOrX.Generators/Analyzers/ErrorOrEndpointAnalyzer.cs index 52c2684..4ca6546 100644 --- a/src/ErrorOrX.Generators/Analyzers/ErrorOrEndpointAnalyzer.cs +++ b/src/ErrorOrX.Generators/Analyzers/ErrorOrEndpointAnalyzer.cs @@ -196,22 +196,22 @@ private static void CheckForValidationAttributes( foreach (var param in method.Parameters) { foreach (var attr in param.GetAttributes()) - { - if (attr.AttributeClass is null) - continue; - - // Check if the attribute inherits from ValidationAttribute - if (InheritsFrom(attr.AttributeClass, validationAttributeType)) { - context.ReportDiagnostic(Diagnostic.Create( - Descriptors.ValidationUsesReflection, - param.Locations.FirstOrDefault() ?? method.Locations.FirstOrDefault(), - param.Name, - method.Name)); - break; // Only report once per parameter + if (attr.AttributeClass is null) + continue; + + // Check if the attribute inherits from ValidationAttribute + if (InheritsFrom(attr.AttributeClass, validationAttributeType)) + { + context.ReportDiagnostic(Diagnostic.Create( + Descriptors.ValidationUsesReflection, + param.Locations.FirstOrDefault() ?? method.Locations.FirstOrDefault(), + param.Name, + method.Name)); + break; // Only report once per parameter + } } } - } } /// @@ -419,11 +419,11 @@ private static bool IsFormCollection(ISymbol type) break; // Generic endpoint attribute - extract HTTP method from first constructor arg case "ErrorOrEndpointAttribute" or "ErrorOrEndpoint": - { - if (attr.ConstructorArguments is [{ Value: string m }, ..]) - httpMethod = m.ToUpperInvariant(); - break; - } + { + if (attr.ConstructorArguments is [{ Value: string m }, ..]) + httpMethod = m.ToUpperInvariant(); + break; + } } if (httpMethod is null) diff --git a/src/ErrorOrX.Generators/Core/ErrorOrEndpointGenerator.Analyzer.cs b/src/ErrorOrX.Generators/Core/ErrorOrEndpointGenerator.Analyzer.cs index 5c2d0fa..27c299b 100644 --- a/src/ErrorOrX.Generators/Core/ErrorOrEndpointGenerator.Analyzer.cs +++ b/src/ErrorOrX.Generators/Core/ErrorOrEndpointGenerator.Analyzer.cs @@ -85,7 +85,7 @@ private static void AnalyzeJsonContextCoverage( foreach (var ctx in userContexts) { foreach (var typeFqn in ctx.SerializableTypes) - registeredTypes.Add(typeFqn); + registeredTypes.Add(typeFqn); } // Combine all needed types diff --git a/src/ErrorOrX.Generators/Core/ErrorOrEndpointGenerator.Emitter.cs b/src/ErrorOrX.Generators/Core/ErrorOrEndpointGenerator.Emitter.cs index 53de268..5d5b1a8 100644 --- a/src/ErrorOrX.Generators/Core/ErrorOrEndpointGenerator.Emitter.cs +++ b/src/ErrorOrX.Generators/Core/ErrorOrEndpointGenerator.Emitter.cs @@ -112,7 +112,7 @@ private static void EmitMappings(SourceProductionContext spc, ImmutableArray) case INamedTypeSymbol namedInner when namedInner.TypeArguments.Any(static t => t is ITypeParameterSymbol): - { - var firstTypeParam = namedInner.TypeArguments.First(static t => t is ITypeParameterSymbol); - return new ErrorOrReturnTypeInfo(null, false, false, null, SuccessKind.Payload, null, false, false, - null, null, true, firstTypeParam.Name); - } + { + var firstTypeParam = namedInner.TypeArguments.First(static t => t is ITypeParameterSymbol); + return new ErrorOrReturnTypeInfo(null, false, false, null, SuccessKind.Payload, null, false, false, + null, null, true, firstTypeParam.Name); + } } var kind = SuccessKind.Payload; @@ -227,8 +227,6 @@ private static EquatableArray ExtractProducesErrorAttributes( { var results = new List(); - // AL0029: Need to extract constructor arguments, not just check existence -#pragma warning disable AL0029 foreach (var attr in method.GetAttributes()) { if (context.ProducesErrorAttribute is not null && @@ -238,7 +236,6 @@ private static EquatableArray ExtractProducesErrorAttributes( results.Add(new ProducesErrorInfo(statusCode)); } } -#pragma warning restore AL0029 return results.Count > 0 ? new EquatableArray([.. results]) @@ -435,8 +432,6 @@ private static bool TryExtractReturnsErrorAttributes( var foundAny = false; - // AL0029: Need to extract constructor arguments, not just check existence -#pragma warning disable AL0029 foreach (var attr in method.GetAttributes()) { if (attr.AttributeClass?.IsEqualTo(context.ReturnsErrorAttribute) != true) continue; @@ -445,33 +440,28 @@ private static bool TryExtractReturnsErrorAttributes( if (args.Length < 2) continue; - // Check which constructor was used: - // 1. ReturnsErrorAttribute(ErrorType errorType, string errorCode) - // 2. ReturnsErrorAttribute(int statusCode, string errorCode) + // Distinguish constructors by the first argument's type: + // 1. ReturnsErrorAttribute(ErrorType errorType, string errorCode) — args[0].Type is enum + // 2. ReturnsErrorAttribute(int statusCode, string errorCode) — args[0].Type is int + if (args[0].Value is not int intValue || args[1].Value is not string errorCode) + continue; - switch (args[0].Value) + if (args[0].Type is INamedTypeSymbol { TypeKind: TypeKind.Enum }) { - case int when args[1].Value is string customErrorCode: - { - // Custom error with status code - if (seenCustomCodes.Add(customErrorCode)) - customErrors.Add(new CustomErrorInfo(customErrorCode)); - - foundAny = true; - break; - } - case int enumValue when args[1].Value is string: - { - // Standard ErrorType - map enum int value to string name - var errorTypeName = MapEnumValueToName(enumValue); - if (errorTypeName is not null) - errorTypeNames.Add(errorTypeName); - foundAny = true; - break; - } + // Standard ErrorType — map enum int value to string name + var errorTypeName = MapEnumValueToName(intValue); + if (errorTypeName is not null) + errorTypeNames.Add(errorTypeName); + foundAny = true; + } + else + { + // Custom error with explicit HTTP status code + if (seenCustomCodes.Add(errorCode)) + customErrors.Add(new CustomErrorInfo(errorCode)); + foundAny = true; } } -#pragma warning restore AL0029 return foundAny; } @@ -838,8 +828,6 @@ private static void ExtractVersioningFromSymbol( ICollection supportedVersions, ref bool isVersionNeutral) { - // AL0029: Need to extract constructor arguments and check multiple attribute types -#pragma warning disable AL0029 foreach (var attr in symbol.GetAttributes()) { if (attr.AttributeClass is not { } attrClass) @@ -862,7 +850,6 @@ private static void ExtractVersioningFromSymbol( supportedVersions.Add(versionInfo.Value); } } -#pragma warning restore AL0029 } private static void ExtractMappedVersions( @@ -870,8 +857,6 @@ private static void ExtractMappedVersions( ErrorOrContext context, ICollection mappedVersions) { - // AL0029: Need to extract constructor arguments from attribute data -#pragma warning disable AL0029 foreach (var attr in method.GetAttributes()) { if (attr.AttributeClass is not { } attrClass) @@ -886,7 +871,6 @@ private static void ExtractMappedVersions( mappedVersions.Add(versionInfo.Value); } } -#pragma warning restore AL0029 } /// @@ -921,11 +905,11 @@ private static void ExtractMappedVersions( return new ApiVersionInfo(major, minor, null, isDeprecated); // ApiVersion(double version) - e.g., 1.0 case [{ Value: double doubleVersion }]: - { - var majorPart = (int)doubleVersion; - var minorPart = (int)((doubleVersion - majorPart) * 10); - return new ApiVersionInfo(majorPart, minorPart > 0 ? minorPart : null, null, isDeprecated); - } + { + var majorPart = (int)doubleVersion; + var minorPart = (int)((doubleVersion - majorPart) * 10); + return new ApiVersionInfo(majorPart, minorPart > 0 ? minorPart : null, null, isDeprecated); + } default: return null; } @@ -972,8 +956,6 @@ private static ImmutableArray ExtractRawClassVersionStrings(ISymbol meth var versions = ImmutableArray.CreateBuilder(); - // AL0029: Need to extract constructor arguments -#pragma warning disable AL0029 foreach (var attr in containingType.GetAttributes()) { if (attr.AttributeClass is not { } attrClass) @@ -986,7 +968,6 @@ private static ImmutableArray ExtractRawClassVersionStrings(ISymbol meth versions.Add(versionString); } } -#pragma warning restore AL0029 return versions.ToImmutable(); } @@ -1002,8 +983,6 @@ private static ImmutableArray ExtractRawMethodVersionStrings(ISymbol met var versions = ImmutableArray.CreateBuilder(); - // AL0029: Need to extract constructor arguments -#pragma warning disable AL0029 foreach (var attr in method.GetAttributes()) { if (attr.AttributeClass is not { } attrClass) @@ -1016,7 +995,6 @@ private static ImmutableArray ExtractRawMethodVersionStrings(ISymbol met versions.Add(versionString); } } -#pragma warning restore AL0029 return versions.ToImmutable(); } @@ -1035,8 +1013,6 @@ private static RouteGroupInfo ExtractRouteGroupInfo(ISymbol method, ErrorOrConte if (context.RouteGroupAttribute is null) return default; - // AL0029: Need to extract constructor arguments and named arguments -#pragma warning disable AL0029 var attrs = containingType.GetAttributes(); foreach (var attr in attrs) { @@ -1068,7 +1044,6 @@ private static RouteGroupInfo ExtractRouteGroupInfo(ISymbol method, ErrorOrConte return new RouteGroupInfo(groupPath, apiName); } -#pragma warning restore AL0029 return default; } @@ -1080,8 +1055,6 @@ private static EquatableArray ExtractMetadata(ISymbol method) { var metadata = ImmutableArray.CreateBuilder(); - // AL0029: Need to extract constructor arguments and process multiple attribute types -#pragma warning disable AL0029 foreach (var attr in method.GetAttributes()) { if (attr.AttributeClass is not { } attrClass) @@ -1091,12 +1064,12 @@ private static EquatableArray ExtractMetadata(ISymbol method) { // [Obsolete] → deprecated metadata case "ObsoleteAttribute": - { - metadata.Add(new MetadataEntry(MetadataKeys.Deprecated, "true")); - if (attr.ConstructorArguments is [{ Value: string msg }, ..]) - metadata.Add(new MetadataEntry(MetadataKeys.DeprecatedMessage, msg)); - continue; - } + { + metadata.Add(new MetadataEntry(MetadataKeys.Deprecated, "true")); + if (attr.ConstructorArguments is [{ Value: string msg }, ..]) + metadata.Add(new MetadataEntry(MetadataKeys.DeprecatedMessage, msg)); + continue; + } // [EndpointMetadata(key, value)] case "EndpointMetadataAttribute" when attr.ConstructorArguments is [{ Value: string key }, { Value: string value }]: @@ -1104,7 +1077,6 @@ private static EquatableArray ExtractMetadata(ISymbol method) break; } } -#pragma warning restore AL0029 return metadata.Count > 0 ? new EquatableArray(metadata.ToImmutable()) diff --git a/src/ErrorOrX.Generators/Core/ErrorOrEndpointGenerator.ParameterBinding.cs b/src/ErrorOrX.Generators/Core/ErrorOrEndpointGenerator.ParameterBinding.cs index 59b8956..4e9d874 100644 --- a/src/ErrorOrX.Generators/Core/ErrorOrEndpointGenerator.ParameterBinding.cs +++ b/src/ErrorOrX.Generators/Core/ErrorOrEndpointGenerator.ParameterBinding.cs @@ -59,7 +59,6 @@ private static ParameterMeta CreateParameterMeta( ErrorOrContext context, ImmutableArray.Builder diagnostics) { - _ = diagnostics; // Reserved for future diagnostics var type = parameter.Type; var typeFqn = type.GetFullyQualifiedName(); @@ -204,7 +203,7 @@ private static ParameterClassificationResult ClassifyParameter( } if (meta.HasFromForm) - return ClassifyFromFormParameter(in meta, method, diagnostics, context); + return ClassifyFromFormParameter(in meta, context); if (meta.HasFromServices) return ParameterSuccess(in meta, ParameterSource.Service); if (meta.HasFromKeyedServices) @@ -326,7 +325,6 @@ private static ParameterClassificationResult ClassifyFromRouteParameter( ISymbol method, ImmutableArray.Builder diagnostics) { - _ = routeParameters; // Reserved for future validation of route parameter existence var hasTryParse = meta.CustomBinding is CustomBindingMethod.TryParse or CustomBindingMethod.TryParseWithFormat; // EOE010: [FromRoute] requires primitive or TryParse @@ -436,13 +434,9 @@ private static ParameterClassificationResult ClassifyFromHeaderParameter( return ParameterClassificationResult.Error; } - // ReSharper disable once UnusedParameter.Local - matches common classifier delegate signature private static ParameterClassificationResult ClassifyFromFormParameter( in ParameterMeta meta, - IMethodSymbol _, - ImmutableArray.Builder __, ErrorOrContext context) - // ReSharper restore UnusedParameter.Local { if (meta.IsFormFile) return ParameterSuccess(in meta, ParameterSource.FormFile, formName: meta.FormName); @@ -862,7 +856,6 @@ private static (bool IsNullable, bool IsNonNullableValueType) GetParameterNullab : (false, true); } - // ReSharper disable once SuggestBaseTypeForParameter - IParameterSymbol is semantically correct private static string? ExtractKeyFromKeyedServiceAttribute(IParameterSymbol parameter) { var matcher = new AttributeNameMatcher(WellKnownTypes.FromKeyedServicesAttribute); @@ -875,7 +868,6 @@ private static (bool IsNullable, bool IsNonNullableValueType) GetParameterNullab return val switch { string s => $"\"{s}\"", _ => val?.ToString() }; } - // ReSharper disable once SuggestBaseTypeForParameter - IParameterSymbol is semantically correct private static bool HasParameterAttribute(IParameterSymbol parameter, INamedTypeSymbol? attributeSymbol, string attributeName) { diff --git a/src/ErrorOrX.Generators/Emitters/GroupEmitter.cs b/src/ErrorOrX.Generators/Emitters/GroupEmitter.cs index fee773e..11492d5 100644 --- a/src/ErrorOrX.Generators/Emitters/GroupEmitter.cs +++ b/src/ErrorOrX.Generators/Emitters/GroupEmitter.cs @@ -70,7 +70,7 @@ private static string EmitGroupDeclaration(StringBuilder code, RouteGroupAggrega code.AppendLine(";"); } else - // Simple group without versioning + // Simple group without versioning { code.AppendLine($" var {groupVarName} = app.MapGroup(\"{group.GroupPath}\");"); } diff --git a/src/ErrorOrX.Generators/ErrorOrX.Generators.csproj b/src/ErrorOrX.Generators/ErrorOrX.Generators.csproj index 4bc49c9..e3a966e 100644 --- a/src/ErrorOrX.Generators/ErrorOrX.Generators.csproj +++ b/src/ErrorOrX.Generators/ErrorOrX.Generators.csproj @@ -12,6 +12,19 @@ true true true + $(NoWarn);NU5128;RS1038 true true diff --git a/src/ErrorOrX.Generators/Models/ParameterSource.cs b/src/ErrorOrX.Generators/Models/ParameterSource.cs index 59440d1..887a6aa 100644 --- a/src/ErrorOrX.Generators/Models/ParameterSource.cs +++ b/src/ErrorOrX.Generators/Models/ParameterSource.cs @@ -7,60 +7,23 @@ namespace ErrorOr.Generators; internal sealed class ParameterSource : IEquatable { // Request-based sources - public static readonly ParameterSource Route = new("Route", - true, false, false); - - public static readonly ParameterSource Body = new("Body", - true, true, false); - - public static readonly ParameterSource Query = new("Query", - true, false, false); - - public static readonly ParameterSource Header = new("Header", - true, false, false); - - public static readonly ParameterSource Form = new("Form", - true, false, false); - - public static readonly ParameterSource FormFile = new("FormFile", - true, false, false); - - public static readonly ParameterSource FormFiles = new("FormFiles", - true, false, false); - - public static readonly ParameterSource FormCollection = new("FormCollection", - true, false, false); - - public static readonly ParameterSource Stream = new("Stream", - true, false, false); - - public static readonly ParameterSource PipeReader = new("PipeReader", - true, false, false); - - // DI-based sources - public static readonly ParameterSource Service = new("Service", - false, false, false); - - public static readonly ParameterSource KeyedService = new("KeyedService", - false, false, false); - - // Special types (auto-bound by ASP.NET Core) - public static readonly ParameterSource HttpContext = new("HttpContext", - false, false, true); - - public static readonly ParameterSource CancellationToken = new("CancellationToken", - false, false, true); - - // Composite binding - public static readonly ParameterSource AsParameters = new("AsParameters", - true, false, false, true); - - private ParameterSource( - string id, - bool _, // isFromRequest - reserved for future use - bool __, // requiresJsonContext - reserved for future use - bool ___, // isSpecialType - reserved for future use - bool ____ = false) // isComposite - reserved for future use + public static readonly ParameterSource Route = new("Route"); + public static readonly ParameterSource Body = new("Body"); + public static readonly ParameterSource Query = new("Query"); + public static readonly ParameterSource Header = new("Header"); + public static readonly ParameterSource Form = new("Form"); + public static readonly ParameterSource FormFile = new("FormFile"); + public static readonly ParameterSource FormFiles = new("FormFiles"); + public static readonly ParameterSource FormCollection = new("FormCollection"); + public static readonly ParameterSource Stream = new("Stream"); + public static readonly ParameterSource PipeReader = new("PipeReader"); + public static readonly ParameterSource Service = new("Service"); + public static readonly ParameterSource KeyedService = new("KeyedService"); + public static readonly ParameterSource HttpContext = new("HttpContext"); + public static readonly ParameterSource CancellationToken = new("CancellationToken"); + public static readonly ParameterSource AsParameters = new("AsParameters"); + + private ParameterSource(string id) { Id = id; } diff --git a/src/ErrorOrX.Generators/OpenApiTransformerGenerator.cs b/src/ErrorOrX.Generators/OpenApiTransformerGenerator.cs index 6c40873..40c2e6a 100644 --- a/src/ErrorOrX.Generators/OpenApiTransformerGenerator.cs +++ b/src/ErrorOrX.Generators/OpenApiTransformerGenerator.cs @@ -213,7 +213,7 @@ private static (string? summary, string? description) ParseXmlDoc(string? xml) searchPos = contentEnd + 8; } - return [..parameters]; + return [.. parameters]; } private static string GetReflectionFullName(INamedTypeSymbol symbol) diff --git a/src/ErrorOrX.Generators/Polyfills.cs b/src/ErrorOrX.Generators/Polyfills.cs index 3ceabaa..4804495 100644 --- a/src/ErrorOrX.Generators/Polyfills.cs +++ b/src/ErrorOrX.Generators/Polyfills.cs @@ -1,8 +1,6 @@ // Minimal polyfills for netstandard2.0 - replaces PolySharp to avoid type conflicts // when test projects reference this assembly with ReferenceOutputAssembly="true" -#pragma warning disable IDE0130 // Namespace does not match folder structure - namespace System.Diagnostics.CodeAnalysis { /// diff --git a/src/ErrorOrX.Generators/TypeResolution/WellKnownTypes.cs b/src/ErrorOrX.Generators/TypeResolution/WellKnownTypes.cs index e4c98f0..45cb0cc 100644 --- a/src/ErrorOrX.Generators/TypeResolution/WellKnownTypes.cs +++ b/src/ErrorOrX.Generators/TypeResolution/WellKnownTypes.cs @@ -1,5 +1,3 @@ -// ReSharper disable InconsistentNaming - namespace ErrorOr.Generators; /// @@ -23,7 +21,6 @@ internal static class WellKnownTypes public const string ReturnsErrorAttribute = "ErrorOr.ReturnsErrorAttribute"; public const string ErrorOrT = "ErrorOr.ErrorOr`1"; - public const string ErrorType = "ErrorOr.ErrorType"; public const string Error = "ErrorOr.Error"; public const string Success = "ErrorOr.Success"; @@ -37,25 +34,19 @@ internal static class WellKnownTypes public const string FromQueryAttribute = "Microsoft.AspNetCore.Mvc.FromQueryAttribute"; public const string FromRouteAttribute = "Microsoft.AspNetCore.Mvc.FromRouteAttribute"; public const string FromServicesAttribute = "Microsoft.AspNetCore.Mvc.FromServicesAttribute"; - public const string ProblemDetails = "Microsoft.AspNetCore.Mvc.ProblemDetails"; public const string AsParametersAttribute = "Microsoft.AspNetCore.Http.AsParametersAttribute"; public const string HttpContext = "Microsoft.AspNetCore.Http.HttpContext"; - public const string HttpValidationProblemDetails = "Microsoft.AspNetCore.Http.HttpValidationProblemDetails"; public const string FormCollection = "Microsoft.AspNetCore.Http.IFormCollection"; public const string FormFile = "Microsoft.AspNetCore.Http.IFormFile"; public const string FormFileCollection = "Microsoft.AspNetCore.Http.IFormFileCollection"; public const string BindableFromHttpContext = "Microsoft.AspNetCore.Http.IBindableFromHttpContext`1"; - public const string TypedResults = "Microsoft.AspNetCore.Http.TypedResults"; public const string FromKeyedServicesAttribute = "Microsoft.Extensions.DependencyInjection.FromKeyedServicesAttribute"; public const string ValidationAttribute = "System.ComponentModel.DataAnnotations.ValidationAttribute"; public const string IValidatableObject = "System.ComponentModel.DataAnnotations.IValidatableObject"; - public const string Validator = "System.ComponentModel.DataAnnotations.Validator"; - public const string ValidationContext = "System.ComponentModel.DataAnnotations.ValidationContext"; - public const string ValidationResult = "System.ComponentModel.DataAnnotations.ValidationResult"; public const string CancellationToken = "System.Threading.CancellationToken"; public const string JsonSerializableAttribute = "System.Text.Json.Serialization.JsonSerializableAttribute"; @@ -109,7 +100,6 @@ internal static class WellKnownTypes public const string ApiVersion = "Asp.Versioning.ApiVersion"; public const string RouteGroupAttribute = "ErrorOr.RouteGroupAttribute"; - public const string AllowEmptyBodyAttribute = "ErrorOr.AllowEmptyBodyAttribute"; public const string EndpointMetadataAttribute = "ErrorOr.EndpointMetadataAttribute"; /// @@ -140,7 +130,6 @@ public static bool IsBodyless(string method) /// These intentionally shadow outer-class constants which use metadata names. /// Outer: for Roslyn symbol lookup | Fqn: for emitted source code. /// - // ReSharper disable MemberHidesStaticFromOuterClass - Intentional: metadata vs codegen naming public static class Fqn { // Frequently used Fqn constants emitted in generated code diff --git a/version.props b/version.props index 33ffe81..d2a4189 100644 --- a/version.props +++ b/version.props @@ -2,7 +2,7 @@ - 3.3.0 + 3.4.0