Fix #725: Introduce line breaks in GenerateNotNullWhenTrueAttribute and GenerateMaybeNullWhenFalse #1262
Annotations
3 errors
Run Snapshots
VerifyException : Directory: D:\a\Vogen\Vogen\tests\SnapshotTests\BugFixes\snapshots\snap-v9.0
NotEqual:
- Received: Bug717_Stj_does_not_escape_dashed_namespace.Test.received.txt
Verified: Bug717_Stj_does_not_escape_dashed_namespace.Test.verified.txt
FileContent:
NotEqual:
Received: Bug717_Stj_does_not_escape_dashed_namespace.Test.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
namespace MY_PROJECT;
public class VogenTypesFactory : global::System.Text.Json.Serialization.JsonConverterFactory
{
public VogenTypesFactory()
{
}
private static readonly global::System.Collections.Generic.Dictionary<global::System.Type, global::System.Lazy<global::System.Text.Json.Serialization.JsonConverter>> _lookup = new global::System.Collections.Generic.Dictionary<global::System.Type, global::System.Lazy<global::System.Text.Json.Serialization.JsonConverter>>
{
{
typeof(global::My_Namespace.Vo),
new global::System.Lazy<global::System.Text.Json.Serialization.JsonConverter>(() => new global::My_Namespace.Vo.VoSystemTextJsonConverter())
}
};
public override bool CanConvert(global::System.Type typeToConvert) => _lookup.ContainsKey(typeToConvert);
public override global::System.Text.Json.Serialization.JsonConverter CreateConverter(global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options) => _lookup[typeToConvert].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
// 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
namespace My_Namespace
{
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
[global::System.CodeDom.Compiler.GeneratedCo
|
Run Snapshots
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.
|
Loading