Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/Vogen/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ public static string GeneratePolyTypeAttributeIfAvailable(VogenKnownSymbols know
return string.Empty;
}

return @" [global::PolyType.TypeShapeAttribute(Marshaler = typeof(PolyTypeMarshaler), Kind = global::PolyType.TypeShapeKind.None)]";
return @" [global::PolyType.TypeShapeAttribute(Marshaler = typeof(PolyTypeMarshaler))]";
}

/// <summary>
Expand All @@ -484,12 +484,14 @@ public static string GeneratePolyTypeMarshalerIfAvailable(VogenKnownSymbols know
var underlyingType = item.UnderlyingTypeFullName;

return $@"
#nullable disable
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
public class PolyTypeMarshaler : global::PolyType.IMarshaler<{typeName}, {underlyingType}>
public sealed class PolyTypeMarshaler : global::PolyType.IMarshaler<{typeName}, {underlyingType}>
{{
{underlyingType} global::PolyType.IMarshaler<{typeName}, {underlyingType}>.Marshal({typeName} value) => value.Value;
{typeName} global::PolyType.IMarshaler<{typeName}, {underlyingType}>.Unmarshal({underlyingType} value) => From(value);
}}";
}}
#nullable restore";
}

public static string GenerateCoverageExcludeAndGeneratedCodeAttributes() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ namespace generator
[global::System.ComponentModel.TypeConverter(typeof(MyIdTypeConverter))]
[global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(MyIdDebugView))]
[global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.Int32, Value = { _value }")]
[global::PolyType.TypeShapeAttribute(Marshaler = typeof(PolyTypeMarshaler), Kind = global::PolyType.TypeShapeKind.None)]
[global::PolyType.TypeShapeAttribute(Marshaler = typeof(PolyTypeMarshaler))]
// ReSharper disable once UnusedType.Global
public partial struct MyId : global::System.IEquatable<MyId>, global::System.IEquatable<System.Int32>, global::System.IComparable<MyId>, global::System.IComparable, global::System.IParsable<MyId>, global::System.ISpanParsable<MyId>, global::System.IUtf8SpanParsable<MyId>, global::System.IFormattable, global::System.ISpanFormattable, global::System.IUtf8SpanFormattable
{
Expand Down Expand Up @@ -735,11 +735,13 @@ private readonly global::System.Diagnostics.StackTrace _stackTrace = null!;
}
}

#nullable disable
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
public class PolyTypeMarshaler : global::PolyType.IMarshaler<MyId, System.Int32>
public sealed class PolyTypeMarshaler : global::PolyType.IMarshaler<MyId, System.Int32>
{
System.Int32 global::PolyType.IMarshaler<MyId, System.Int32>.Marshal(MyId value) => value.Value;
MyId global::PolyType.IMarshaler<MyId, System.Int32>.Unmarshal(System.Int32 value) => From(value);
}
#nullable restore
}
]