Skip to content

Feature: more detailed compilation errors when both explicit and implicit casting operators are specific #1257

Feature: more detailed compilation errors when both explicit and implicit casting operators are specific

Feature: more detailed compilation errors when both explicit and implicit casting operators are specific #1257

Triggered via pull request December 3, 2024 08:00
Status Failure
Total duration 16m 59s
Artifacts

build.yaml

on: pull_request
Fit to window
Zoom out
Zoom in

Annotations

4 errors and 1 warning
SnapshotTests.StaticAbstracts.StaticAbstractTests.Emits_equality_operators_to_primitives_if_specified_in_global_config: tests/SnapshotTests/StaticAbstracts/StaticAbstractTests.cs#L129
Expected collection to be empty because the following source code should compile on Net8_0: using System; using Vogen; [assembly: VogenDefaults( primitiveEqualityGeneration: PrimitiveEqualityGeneration.GenerateOperatorsAndMethods, conversions: Conversions.None, staticAbstractsGeneration: StaticAbstractsGeneration.FactoryMethods | StaticAbstractsGeneration.EqualsOperators | StaticAbstractsGeneration.ImplicitCastFromPrimitive | StaticAbstractsGeneration.ImplicitCastToPrimitive)] [ValueObject<Guid>] public partial class MyVo { } , but found {(10,22): error VOG036: 'MyVo' should have either an explicit or implicit cast for casting to or from the wrapper or primitive, but not both. Check that the global config isn't specifying a conflicting casting operator. Check 'toPrimitiveCasting', 'fromPrimitiveCasting', and 'staticAbstractsGeneration'. 'staticAbstractGeneration' defaults to explicit casting, so if you change the default, you need to change it here too. See issue 720 (https://github.com/SteveDunn/Vogen/issues/720) for more information.}.
SnapshotTests.StaticAbstracts.StaticAbstractTests.Omits_equality_operators_to_primitives_if_specified_in_global_config: tests/SnapshotTests/StaticAbstracts/StaticAbstractTests.cs#L108
Expected collection to be empty because the following source code should compile on Net8_0: using System; using Vogen; [assembly: VogenDefaults( primitiveEqualityGeneration: PrimitiveEqualityGeneration.Omit, conversions: Conversions.None, staticAbstractsGeneration: StaticAbstractsGeneration.FactoryMethods | StaticAbstractsGeneration.EqualsOperators | StaticAbstractsGeneration.ImplicitCastFromPrimitive | StaticAbstractsGeneration.ImplicitCastToPrimitive)] [ValueObject<Guid>] public partial class MyVo { } , but found {(10,22): error VOG036: 'MyVo' should have either an explicit or implicit cast for casting to or from the wrapper or primitive, but not both. Check that the global config isn't specifying a conflicting casting operator. Check 'toPrimitiveCasting', 'fromPrimitiveCasting', and 'staticAbstractsGeneration'. 'staticAbstractGeneration' defaults to explicit casting, so if you change the default, you need to change it here too. See issue 720 (https://github.com/SteveDunn/Vogen/issues/720) for more information.}.
SnapshotTests.BugFixes.Bug720_Inconsistent_casting_mixed_with_IVogen_generation.Works_when_the_static_abstracts_and_implementation_have_same_casting
VerifyException : Directory: D:\a\Vogen\Vogen\tests\SnapshotTests\BugFixes\snapshots\snap-vAspNetCore8.0 NotEqual: - Received: Bug720_Inconsistent_casting_mixed_with_IVogen_generation.Works_when_the_static_abstracts_and_implementation_have_same_casting.received.txt Verified: Bug720_Inconsistent_casting_mixed_with_IVogen_generation.Works_when_the_static_abstracts_and_implementation_have_same_casting.verified.txt FileContent: NotEqual: Received: Bug720_Inconsistent_casting_mixed_with_IVogen_generation.Works_when_the_static_abstracts_and_implementation_have_same_casting.received.txt [ // ------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a source generator named Vogen (https://github.com/SteveDunn/Vogen) // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> // ------------------------------------------------------------------------------ // Suppress warnings about [Obsolete] member usage in generated code. #pragma warning disable CS0618 // Suppress warnings for 'Override methods on comparable types'. #pragma warning disable CA1036 // Suppress Error MA0097 : A class that implements IComparable<T> or IComparable should override comparison operators #pragma warning disable MA0097 // Suppress warning for 'The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source.' // The generator copies signatures from the BCL, e.g. for `TryParse`, and some of those have nullable annotations. #pragma warning disable CS8669, CS8632 // Suppress warnings about CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member' #pragma warning disable CS1591 using System.Reflection; public class VogenSchemaFilterIngenerator : global::Swashbuckle.AspNetCore.SwaggerGen.ISchemaFilter { private const BindingFlags _flags = BindingFlags.Public | BindingFlags.Instance; public void Apply(global::Microsoft.OpenApi.Models.OpenApiSchema schema, global::Swashbuckle.AspNetCore.SwaggerGen.SchemaFilterContext context) { if (context.Type.GetCustomAttribute<Vogen.ValueObjectAttribute>()is not { } attribute) return; var type = attribute.GetType(); if (!type.IsGenericType || type.GenericTypeArguments.Length != 1) { return; } var schemaValueObject = context.SchemaGenerator.GenerateSchema(type.GenericTypeArguments[0], context.SchemaRepository, context.MemberInfo, context.ParameterInfo); TryCopyPublicProperties(schemaValueObject, schema); } private static void TryCopyPublicProperties<T>(T oldObject, T newObject) where T : class { if (ReferenceEquals(oldObject, newObject)) { return; } var type = typeof(T); var propertyList = type.GetProperties(_flags); if (propertyList.Length <= 0) { return; } foreach (var newObjProp in propertyList) { var oldProp = type.GetProperty(newObjProp.Name, _flags)!; if (!oldProp.CanRead || !newObjProp.CanWrite) { continue; } var value = oldProp.GetValue(oldObject); newObjProp.SetValue(newObject, value); } } } // ------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a source generator named Vogen (https://github.com/SteveDunn/Vogen) // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> // ------------------------------------------------------------------------------ // Suppress warnings about [Obsolete] member usage in generated code. #pragma warning disable CS0618 // Suppress warnings for 'Override methods on comparable types'. #pragma warning disable CA1036
run-snapshots
Process completed with exit code 1.
ubuntu-latest
ubuntu-latest pipelines will use ubuntu-24.04 soon. For more details, see https://github.com/actions/runner-images/issues/10636