-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #580 from SteveDunn/571-guid-factory-method
Add factory method for GUIDs
- 7.0.1
- 7.0.0
- 7.0.0-beta.1
- 6.0.0
- 6.0.0-beta.4
- 6.0.0-beta.3
- 6.0.0-beta.2
- 6.0.0-beta.1
- 5.0.6
- 5.0.6-beta.3
- 5.0.6-beta.2
- 5.0.6-beta.1
- 5.0.5
- 5.0.5-rc.2
- 5.0.5-rc.1
- 5.0.5-beta.3
- 5.0.5-beta.2
- 5.0.4-beta.1
- 5.0.3
- 5.0.2
- 5.0.1
- 5.0.0
- 5.0.0-beta.1
- 4.0.19
- 4.0.18
- 4.0.17
- 4.0.16
- 4.0.15
- 4.0.14
- 4.0.13
- 4.0.12
- 4.0.11
- 4.0.10
- 4.0.9
- 4.0.8
- 4.0.7
- 4.0.6
- 4.0.5.1
- 4.0.5
- 4.0.4
- 4.0.3
- 4.0.2
- 4.0.1
Showing
39 changed files
with
10,097 additions
and
34 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
339 changes: 339 additions & 0 deletions
339
tests/SnapshotTests/GeneralStuff/snapshots/snap-v3.1/0Rjlo8wVsY.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,339 @@ | ||
// ------------------------------------------------------------------------------ | ||
// <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 | ||
|
||
// Suppress warnings about CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member' | ||
#pragma warning disable CS1591 | ||
|
||
using Vogen; | ||
|
||
|
||
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")] | ||
[global::System.Text.Json.Serialization.JsonConverter(typeof(MyVoSystemTextJsonConverter))] | ||
[global::System.ComponentModel.TypeConverter(typeof(MyVoTypeConverter))] | ||
|
||
[global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(MyVoDebugView))] | ||
[global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.Guid, Value = { _value }")] | ||
public partial struct MyVo : global::System.IEquatable<MyVo>, global::System.IEquatable<System.Guid>, global::System.IComparable<MyVo>, global::System.IComparable | ||
{ | ||
#if DEBUG | ||
private readonly global::System.Diagnostics.StackTrace _stackTrace = null; | ||
#endif | ||
|
||
private readonly global::System.Boolean _isInitialized; | ||
|
||
private readonly System.Guid _value; | ||
|
||
/// <summary> | ||
/// Gets the underlying <see cref="System.Guid" /> value if set, otherwise a <see cref="ValueObjectValidationException" /> is thrown. | ||
/// </summary> | ||
public readonly System.Guid Value | ||
{ | ||
[global::System.Diagnostics.DebuggerStepThroughAttribute] | ||
get | ||
{ | ||
EnsureInitialized(); | ||
return _value; | ||
} | ||
} | ||
|
||
|
||
[global::System.Diagnostics.DebuggerStepThroughAttribute] | ||
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] | ||
public MyVo() | ||
{ | ||
#if DEBUG | ||
_stackTrace = new global::System.Diagnostics.StackTrace(); | ||
#endif | ||
|
||
_isInitialized = false; | ||
_value = default; | ||
} | ||
|
||
[global::System.Diagnostics.DebuggerStepThroughAttribute] | ||
private MyVo(System.Guid value) | ||
{ | ||
_value = value; | ||
_isInitialized = true; | ||
} | ||
|
||
/// <summary> | ||
/// Builds an instance from the provided underlying type. | ||
/// </summary> | ||
/// <param name="value">The underlying type.</param> | ||
/// <returns>An instance of this type.</returns> | ||
public static MyVo From(System.Guid value) | ||
{ | ||
|
||
|
||
|
||
|
||
MyVo instance = new MyVo(value); | ||
|
||
return instance; | ||
} | ||
|
||
|
||
public static explicit operator MyVo(System.Guid value) => From(value); | ||
public static explicit operator System.Guid(MyVo value) => value.Value; | ||
public static MyVo FromNewGuid() { return From(global::System.Guid.NewGuid()); } | ||
// only called internally when something has been deserialized into | ||
// its primitive type. | ||
private static MyVo Deserialize(System.Guid value) | ||
{ | ||
|
||
|
||
|
||
|
||
return new MyVo(value); | ||
} | ||
public readonly global::System.Boolean Equals(MyVo other) | ||
{ | ||
// It's possible to create uninitialized instances via converters such as EfCore (HasDefaultValue), which call Equals. | ||
// We treat anything uninitialized as not equal to anything, even other uninitialized instances of this type. | ||
if(!_isInitialized || !other._isInitialized) return false; | ||
|
||
return global::System.Collections.Generic.EqualityComparer<System.Guid>.Default.Equals(Value, other.Value); | ||
} | ||
public global::System.Boolean Equals(MyVo other, global::System.Collections.Generic.IEqualityComparer<MyVo> comparer) | ||
{ | ||
return comparer.Equals(this, other); | ||
} | ||
|
||
|
||
public readonly global::System.Boolean Equals(System.Guid primitive) | ||
{ | ||
return Value.Equals(primitive); | ||
} | ||
|
||
public readonly override global::System.Boolean Equals(global::System.Object obj) | ||
{ | ||
return obj is MyVo && Equals((MyVo) obj); | ||
} | ||
|
||
public static global::System.Boolean operator ==(MyVo left, MyVo right) => Equals(left, right); | ||
public static global::System.Boolean operator !=(MyVo left, MyVo right) => !(left == right); | ||
|
||
public static global::System.Boolean operator ==(MyVo left, System.Guid right) => Equals(left.Value, right); | ||
public static global::System.Boolean operator !=(MyVo left, System.Guid right) => !Equals(left.Value, right); | ||
|
||
public static global::System.Boolean operator ==(System.Guid left, MyVo right) => Equals(left, right.Value); | ||
public static global::System.Boolean operator !=(System.Guid left, MyVo right) => !Equals(left, right.Value); | ||
|
||
public int CompareTo(MyVo other) => Value.CompareTo(other.Value); | ||
public int CompareTo(object other) { | ||
if(other is null) return 1; | ||
if(other is MyVo x) return CompareTo(x); | ||
throw new global::System.ArgumentException("Cannot compare to object as it is not of type MyVo", nameof(other)); | ||
} | ||
|
||
|
||
/// <inheritdoc cref="System.Guid.TryParse(System.ReadOnlySpan{char}, out System.Guid)"/> | ||
/// <summary> | ||
/// </summary> | ||
/// <returns> | ||
/// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization). | ||
/// </returns> | ||
public static global::System.Boolean TryParse(global::System.ReadOnlySpan<char> input, | ||
#if NETCOREAPP3_0_OR_GREATER | ||
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] | ||
#endif | ||
out MyVo result) { | ||
if(System.Guid.TryParse(input, out var __v)) { | ||
|
||
|
||
result = new MyVo(__v); | ||
return true; | ||
} | ||
|
||
result = default; | ||
return false; | ||
} | ||
|
||
/// <inheritdoc cref="System.Guid.TryParse(string?, out System.Guid)"/> | ||
/// <summary> | ||
/// </summary> | ||
/// <returns> | ||
/// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization). | ||
/// </returns> | ||
public static global::System.Boolean TryParse(string input, | ||
#if NETCOREAPP3_0_OR_GREATER | ||
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] | ||
#endif | ||
out MyVo result) { | ||
if(System.Guid.TryParse(input, out var __v)) { | ||
|
||
|
||
result = new MyVo(__v); | ||
return true; | ||
} | ||
|
||
result = default; | ||
return false; | ||
} | ||
|
||
/// <inheritdoc cref="System.Guid.Parse(System.ReadOnlySpan{char})"/> | ||
/// <summary> | ||
/// </summary> | ||
/// <returns> | ||
/// The value created via the <see cref="From"/> method. | ||
/// </returns> | ||
/// <exception cref="ValueObjectValidationException">Thrown when the value can be parsed, but is not valid.</exception> | ||
public static MyVo Parse(global::System.ReadOnlySpan<char> input) { | ||
var r = System.Guid.Parse(input); | ||
return From(r); | ||
} | ||
|
||
/// <inheritdoc cref="System.Guid.Parse(string)"/> | ||
/// <summary> | ||
/// </summary> | ||
/// <returns> | ||
/// The value created via the <see cref="From"/> method. | ||
/// </returns> | ||
/// <exception cref="ValueObjectValidationException">Thrown when the value can be parsed, but is not valid.</exception> | ||
public static MyVo Parse(string input) { | ||
var r = System.Guid.Parse(input); | ||
return From(r); | ||
} | ||
|
||
|
||
|
||
public readonly override global::System.Int32 GetHashCode() | ||
{ | ||
return global::System.Collections.Generic.EqualityComparer<System.Guid>.Default.GetHashCode(Value); | ||
} | ||
|
||
/// <summary>Returns the string representation of the underlying type</summary> | ||
/// <inheritdoc cref="System.Guid.ToString()" /> | ||
public readonly override global::System.String ToString() =>_isInitialized ? Value.ToString() : "[UNINITIALIZED]"; | ||
|
||
private readonly void EnsureInitialized() | ||
{ | ||
if (!_isInitialized) | ||
{ | ||
#if DEBUG | ||
global::System.String message = "Use of uninitialized Value Object at: " + _stackTrace ?? ""; | ||
#else | ||
global::System.String message = "Use of uninitialized Value Object."; | ||
#endif | ||
|
||
throw new global::Vogen.ValueObjectValidationException(message); | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
class MyVoSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter<MyVo> | ||
{ | ||
public override MyVo Read(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options) | ||
{ | ||
return MyVo.Deserialize(System.Guid.Parse(reader.GetString())); | ||
} | ||
|
||
public override void Write(System.Text.Json.Utf8JsonWriter writer, MyVo value, global::System.Text.Json.JsonSerializerOptions options) | ||
{ | ||
writer.WriteStringValue(value.Value); | ||
} | ||
|
||
#if NET6_0_OR_GREATER | ||
public override MyVo ReadAsPropertyName(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options) | ||
{ | ||
return MyVo.Deserialize(System.Guid.Parse(reader.GetString())); | ||
} | ||
|
||
public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, MyVo value, global::System.Text.Json.JsonSerializerOptions options) | ||
{ | ||
writer.WritePropertyName(value.Value.ToString()); | ||
} | ||
#endif | ||
} | ||
|
||
|
||
class MyVoTypeConverter : global::System.ComponentModel.TypeConverter | ||
{ | ||
public override global::System.Boolean CanConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType) | ||
{ | ||
return sourceType == typeof(global::System.Guid) || sourceType == typeof(global::System.String) || base.CanConvertFrom(context, sourceType); | ||
} | ||
|
||
public override global::System.Object ConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Globalization.CultureInfo culture, global::System.Object value) | ||
{ | ||
return value switch | ||
{ | ||
global::System.Guid guidValue => MyVo.Deserialize(guidValue), | ||
global::System.String stringValue when !global::System.String.IsNullOrEmpty(stringValue) && global::System.Guid.TryParse(stringValue, out var result) => MyVo.Deserialize(result), | ||
_ => base.ConvertFrom(context, culture, value), | ||
}; | ||
} | ||
|
||
public override bool CanConvertTo(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType) | ||
{ | ||
return sourceType == typeof(global::System.Guid) || sourceType == typeof(global::System.String) || base.CanConvertTo(context, sourceType); | ||
} | ||
|
||
public override object ConvertTo(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Globalization.CultureInfo culture, global::System.Object value, global::System.Type destinationType) | ||
{ | ||
if (value is MyVo idValue) | ||
{ | ||
if (destinationType == typeof(global::System.Guid)) | ||
{ | ||
return idValue.Value; | ||
} | ||
|
||
if (destinationType == typeof(global::System.String)) | ||
{ | ||
return idValue.Value.ToString(); | ||
} | ||
} | ||
|
||
return base.ConvertTo(context, culture, value, destinationType); | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
internal sealed class MyVoDebugView | ||
{ | ||
private readonly MyVo _t; | ||
|
||
MyVoDebugView(MyVo t) | ||
{ | ||
_t = t; | ||
} | ||
|
||
public global::System.Boolean IsInitialized => _t._isInitialized; | ||
public global::System.String UnderlyingType => "System.Guid"; | ||
public global::System.String Value => _t._isInitialized ? _t._value.ToString() : "[not initialized]" ; | ||
|
||
#if DEBUG | ||
public global::System.String CreatedWith => _t._stackTrace?.ToString() ?? "the From method"; | ||
#endif | ||
|
||
public global::System.String Conversions => @"Default"; | ||
} | ||
|
||
} | ||
|
357 changes: 357 additions & 0 deletions
357
tests/SnapshotTests/GeneralStuff/snapshots/snap-v3.1/LZDZ0jdOF6.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,357 @@ | ||
// ------------------------------------------------------------------------------ | ||
// <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 | ||
|
||
// Suppress warnings about CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member' | ||
#pragma warning disable CS1591 | ||
|
||
using Vogen; | ||
|
||
|
||
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")] | ||
[global::System.Text.Json.Serialization.JsonConverter(typeof(MyVoSystemTextJsonConverter))] | ||
[global::System.ComponentModel.TypeConverter(typeof(MyVoTypeConverter))] | ||
|
||
[global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(MyVoDebugView))] | ||
[global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.Guid, Value = { _value }")] | ||
public partial record class MyVo : global::System.IEquatable<MyVo>, global::System.IEquatable<System.Guid>, global::System.IComparable<MyVo>, global::System.IComparable | ||
{ | ||
#if DEBUG | ||
private readonly global::System.Diagnostics.StackTrace _stackTrace = null; | ||
#endif | ||
private readonly global::System.Boolean _isInitialized; | ||
private readonly System.Guid _value; | ||
|
||
/// <summary> | ||
/// Gets the underlying <see cref="System.Guid" /> value if set, otherwise a <see cref="ValueObjectValidationException" /> is thrown. | ||
/// </summary> | ||
public System.Guid Value | ||
{ | ||
[global::System.Diagnostics.DebuggerStepThroughAttribute] | ||
get | ||
{ | ||
EnsureInitialized(); | ||
return _value; | ||
} | ||
[global::System.Diagnostics.DebuggerStepThroughAttribute] | ||
init | ||
{ | ||
|
||
|
||
|
||
|
||
|
||
|
||
_value = value; | ||
} | ||
} | ||
|
||
|
||
[global::System.Diagnostics.DebuggerStepThroughAttribute] | ||
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] | ||
public MyVo() | ||
{ | ||
#if DEBUG | ||
_stackTrace = new global::System.Diagnostics.StackTrace(); | ||
#endif | ||
_isInitialized = false; | ||
_value = default; | ||
} | ||
|
||
[global::System.Diagnostics.DebuggerStepThroughAttribute] | ||
private MyVo(System.Guid value) | ||
{ | ||
_value = value; | ||
_isInitialized = true; | ||
} | ||
|
||
/// <summary> | ||
/// Builds an instance from the provided underlying type. | ||
/// </summary> | ||
/// <param name="value">The underlying type.</param> | ||
/// <returns>An instance of this type.</returns> | ||
public static MyVo From(System.Guid value) | ||
{ | ||
|
||
|
||
|
||
|
||
|
||
|
||
MyVo instance = new MyVo(value); | ||
|
||
return instance; | ||
} | ||
|
||
// only called internally when something has been deserialized into | ||
// its primitive type. | ||
private static MyVo Deserialize(System.Guid value) | ||
{ | ||
|
||
|
||
|
||
|
||
|
||
|
||
return new MyVo(value); | ||
} | ||
|
||
public virtual global::System.Boolean Equals(MyVo other) | ||
{ | ||
if (ReferenceEquals(null, other)) | ||
{ | ||
return false; | ||
} | ||
|
||
// It's possible to create uninitialized instances via converters such as EfCore (HasDefaultValue), which call Equals. | ||
// We treat anything uninitialized as not equal to anything, even other uninitialized instances of this type. | ||
if(!_isInitialized || !other._isInitialized) return false; | ||
|
||
if (ReferenceEquals(this, other)) | ||
{ | ||
return true; | ||
} | ||
|
||
return GetType() == other.GetType() && global::System.Collections.Generic.EqualityComparer<System.Guid>.Default.Equals(Value, other.Value); | ||
} | ||
public global::System.Boolean Equals(MyVo other, global::System.Collections.Generic.IEqualityComparer<MyVo> comparer) | ||
{ | ||
return comparer.Equals(this, other); | ||
} | ||
|
||
|
||
public global::System.Boolean Equals(System.Guid primitive) | ||
{ | ||
return Value.Equals(primitive); | ||
} | ||
|
||
|
||
public static global::System.Boolean operator ==(MyVo left, System.Guid right) => Equals(left.Value, right); | ||
public static global::System.Boolean operator !=(MyVo left, System.Guid right) => !Equals(left.Value, right); | ||
|
||
public static global::System.Boolean operator ==(System.Guid left, MyVo right) => Equals(left, right.Value); | ||
public static global::System.Boolean operator !=(System.Guid left, MyVo right) => !Equals(left, right.Value); | ||
|
||
public static explicit operator MyVo(System.Guid value) => From(value); | ||
public static explicit operator System.Guid(MyVo value) => value.Value; | ||
public static MyVo FromNewGuid() { return From(global::System.Guid.NewGuid()); } | ||
public int CompareTo(MyVo other) => Value.CompareTo(other.Value); | ||
public int CompareTo(object other) { | ||
if(other is null) return 1; | ||
if(other is MyVo x) return CompareTo(x); | ||
throw new global::System.ArgumentException("Cannot compare to object as it is not of type MyVo", nameof(other)); | ||
} | ||
|
||
|
||
/// <inheritdoc cref="System.Guid.TryParse(System.ReadOnlySpan{char}, out System.Guid)"/> | ||
/// <summary> | ||
/// </summary> | ||
/// <returns> | ||
/// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization). | ||
/// </returns> | ||
public static global::System.Boolean TryParse(global::System.ReadOnlySpan<char> input, | ||
#if NETCOREAPP3_0_OR_GREATER | ||
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] | ||
#endif | ||
out MyVo result) { | ||
if(System.Guid.TryParse(input, out var __v)) { | ||
|
||
|
||
result = new MyVo(__v); | ||
return true; | ||
} | ||
|
||
result = default; | ||
return false; | ||
} | ||
|
||
/// <inheritdoc cref="System.Guid.TryParse(string?, out System.Guid)"/> | ||
/// <summary> | ||
/// </summary> | ||
/// <returns> | ||
/// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization). | ||
/// </returns> | ||
public static global::System.Boolean TryParse(string input, | ||
#if NETCOREAPP3_0_OR_GREATER | ||
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] | ||
#endif | ||
out MyVo result) { | ||
if(System.Guid.TryParse(input, out var __v)) { | ||
|
||
|
||
result = new MyVo(__v); | ||
return true; | ||
} | ||
|
||
result = default; | ||
return false; | ||
} | ||
|
||
/// <inheritdoc cref="System.Guid.Parse(System.ReadOnlySpan{char})"/> | ||
/// <summary> | ||
/// </summary> | ||
/// <returns> | ||
/// The value created via the <see cref="From"/> method. | ||
/// </returns> | ||
/// <exception cref="ValueObjectValidationException">Thrown when the value can be parsed, but is not valid.</exception> | ||
public static MyVo Parse(global::System.ReadOnlySpan<char> input) { | ||
var r = System.Guid.Parse(input); | ||
return From(r); | ||
} | ||
|
||
/// <inheritdoc cref="System.Guid.Parse(string)"/> | ||
/// <summary> | ||
/// </summary> | ||
/// <returns> | ||
/// The value created via the <see cref="From"/> method. | ||
/// </returns> | ||
/// <exception cref="ValueObjectValidationException">Thrown when the value can be parsed, but is not valid.</exception> | ||
public static MyVo Parse(string input) { | ||
var r = System.Guid.Parse(input); | ||
return From(r); | ||
} | ||
|
||
|
||
|
||
public override global::System.Int32 GetHashCode() | ||
{ | ||
unchecked // Overflow is fine, just wrap | ||
{ | ||
global::System.Int32 hash = (global::System.Int32) 2166136261; | ||
hash = (hash * 16777619) ^ GetType().GetHashCode(); | ||
hash = (hash * 16777619) ^ global::System.Collections.Generic.EqualityComparer<System.Guid>.Default.GetHashCode(Value); | ||
return hash; | ||
} | ||
} | ||
|
||
private void EnsureInitialized() | ||
{ | ||
if (!_isInitialized) | ||
{ | ||
#if DEBUG | ||
global::System.String message = "Use of uninitialized Value Object at: " + _stackTrace ?? ""; | ||
#else | ||
global::System.String message = "Use of uninitialized Value Object."; | ||
#endif | ||
|
||
throw new global::Vogen.ValueObjectValidationException(message); | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
// record enumerates fields - we just want our Value and to throw if it's not initialized. | ||
/// <summary>Returns the string representation of the underlying <see cref="System.Guid" />.</summary> | ||
/// <inheritdoc cref="System.Guid.ToString()" /> | ||
public override global::System.String ToString() => _isInitialized ? Value.ToString() : "[UNINITIALIZED]"; | ||
|
||
|
||
class MyVoSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter<MyVo> | ||
{ | ||
public override MyVo Read(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options) | ||
{ | ||
return MyVo.Deserialize(System.Guid.Parse(reader.GetString())); | ||
} | ||
|
||
public override void Write(System.Text.Json.Utf8JsonWriter writer, MyVo value, global::System.Text.Json.JsonSerializerOptions options) | ||
{ | ||
writer.WriteStringValue(value.Value); | ||
} | ||
|
||
#if NET6_0_OR_GREATER | ||
public override MyVo ReadAsPropertyName(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options) | ||
{ | ||
return MyVo.Deserialize(System.Guid.Parse(reader.GetString())); | ||
} | ||
|
||
public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, MyVo value, global::System.Text.Json.JsonSerializerOptions options) | ||
{ | ||
writer.WritePropertyName(value.Value.ToString()); | ||
} | ||
#endif | ||
} | ||
|
||
|
||
class MyVoTypeConverter : global::System.ComponentModel.TypeConverter | ||
{ | ||
public override global::System.Boolean CanConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType) | ||
{ | ||
return sourceType == typeof(global::System.Guid) || sourceType == typeof(global::System.String) || base.CanConvertFrom(context, sourceType); | ||
} | ||
|
||
public override global::System.Object ConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Globalization.CultureInfo culture, global::System.Object value) | ||
{ | ||
return value switch | ||
{ | ||
global::System.Guid guidValue => MyVo.Deserialize(guidValue), | ||
global::System.String stringValue when !global::System.String.IsNullOrEmpty(stringValue) && global::System.Guid.TryParse(stringValue, out var result) => MyVo.Deserialize(result), | ||
_ => base.ConvertFrom(context, culture, value), | ||
}; | ||
} | ||
|
||
public override bool CanConvertTo(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType) | ||
{ | ||
return sourceType == typeof(global::System.Guid) || sourceType == typeof(global::System.String) || base.CanConvertTo(context, sourceType); | ||
} | ||
|
||
public override object ConvertTo(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Globalization.CultureInfo culture, global::System.Object value, global::System.Type destinationType) | ||
{ | ||
if (value is MyVo idValue) | ||
{ | ||
if (destinationType == typeof(global::System.Guid)) | ||
{ | ||
return idValue.Value; | ||
} | ||
|
||
if (destinationType == typeof(global::System.String)) | ||
{ | ||
return idValue.Value.ToString(); | ||
} | ||
} | ||
|
||
return base.ConvertTo(context, culture, value, destinationType); | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
||
internal sealed class MyVoDebugView | ||
{ | ||
private readonly MyVo _t; | ||
|
||
MyVoDebugView(MyVo t) | ||
{ | ||
_t = t; | ||
} | ||
|
||
public global::System.String UnderlyingType => "System.Guid"; | ||
public System.Guid Value => _t.Value ; | ||
|
||
public global::System.String Conversions => @"[global::System.Text.Json.Serialization.JsonConverter(typeof(MyVoSystemTextJsonConverter))] | ||
[global::System.ComponentModel.TypeConverter(typeof(MyVoTypeConverter))] | ||
"; | ||
} | ||
} | ||
|
353 changes: 353 additions & 0 deletions
353
tests/SnapshotTests/GeneralStuff/snapshots/snap-v3.1/jXZ79bcjc9.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,353 @@ | ||
// ------------------------------------------------------------------------------ | ||
// <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 | ||
|
||
// Suppress warnings about CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member' | ||
#pragma warning disable CS1591 | ||
|
||
using Vogen; | ||
|
||
|
||
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")] | ||
[global::System.Text.Json.Serialization.JsonConverter(typeof(MyVoSystemTextJsonConverter))] | ||
[global::System.ComponentModel.TypeConverter(typeof(MyVoTypeConverter))] | ||
|
||
[global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(MyVoDebugView))] | ||
[global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.Guid, Value = { _value }")] | ||
public partial class MyVo : global::System.IEquatable<MyVo>, global::System.IEquatable<System.Guid> , global::System.IComparable<MyVo>, global::System.IComparable | ||
{ | ||
#if DEBUG | ||
private readonly global::System.Diagnostics.StackTrace _stackTrace = null; | ||
#endif | ||
private readonly global::System.Boolean _isInitialized; | ||
private readonly System.Guid _value; | ||
|
||
/// <summary> | ||
/// Gets the underlying <see cref="System.Guid" /> value if set, otherwise a <see cref="ValueObjectValidationException" /> is thrown. | ||
/// </summary> | ||
public System.Guid Value | ||
{ | ||
[global::System.Diagnostics.DebuggerStepThroughAttribute] | ||
get | ||
{ | ||
EnsureInitialized(); | ||
return _value; | ||
} | ||
} | ||
|
||
|
||
[global::System.Diagnostics.DebuggerStepThroughAttribute] | ||
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] | ||
public MyVo() | ||
{ | ||
#if DEBUG | ||
_stackTrace = new global::System.Diagnostics.StackTrace(); | ||
#endif | ||
_isInitialized = false; | ||
_value = default; | ||
} | ||
|
||
[global::System.Diagnostics.DebuggerStepThroughAttribute] | ||
private MyVo(System.Guid value) | ||
{ | ||
_value = value; | ||
_isInitialized = true; | ||
} | ||
|
||
/// <summary> | ||
/// Builds an instance from the provided underlying type. | ||
/// </summary> | ||
/// <param name="value">The underlying type.</param> | ||
/// <returns>An instance of this type.</returns> | ||
public static MyVo From(System.Guid value) | ||
{ | ||
|
||
|
||
|
||
|
||
|
||
|
||
MyVo instance = new MyVo(value); | ||
|
||
return instance; | ||
} | ||
|
||
|
||
// only called internally when something has been deserialized into | ||
// its primitive type. | ||
private static MyVo Deserialize(System.Guid value) | ||
{ | ||
|
||
|
||
|
||
|
||
|
||
|
||
return new MyVo(value); | ||
} | ||
|
||
public global::System.Boolean Equals(MyVo other) | ||
{ | ||
if (ReferenceEquals(null, other)) | ||
{ | ||
return false; | ||
} | ||
|
||
// It's possible to create uninitialized instances via converters such as EfCore (HasDefaultValue), which call Equals. | ||
// We treat anything uninitialized as not equal to anything, even other uninitialized instances of this type. | ||
if(!_isInitialized || !other._isInitialized) return false; | ||
|
||
if (ReferenceEquals(this, other)) | ||
{ | ||
return true; | ||
} | ||
|
||
return GetType() == other.GetType() && global::System.Collections.Generic.EqualityComparer<System.Guid>.Default.Equals(Value, other.Value); | ||
} | ||
public global::System.Boolean Equals(MyVo other, global::System.Collections.Generic.IEqualityComparer<MyVo> comparer) | ||
{ | ||
return comparer.Equals(this, other); | ||
} | ||
|
||
|
||
public global::System.Boolean Equals(System.Guid primitive) | ||
{ | ||
return Value.Equals(primitive); | ||
} | ||
|
||
public override global::System.Boolean Equals(global::System.Object obj) | ||
{ | ||
return Equals(obj as MyVo); | ||
} | ||
|
||
public static global::System.Boolean operator ==(MyVo left, MyVo right) => Equals(left, right); | ||
public static global::System.Boolean operator !=(MyVo left, MyVo right) => !Equals(left, right); | ||
|
||
public static global::System.Boolean operator ==(MyVo left, System.Guid right) => Equals(left.Value, right); | ||
public static global::System.Boolean operator !=(MyVo left, System.Guid right) => !Equals(left.Value, right); | ||
|
||
public static global::System.Boolean operator ==(System.Guid left, MyVo right) => Equals(left, right.Value); | ||
public static global::System.Boolean operator !=(System.Guid left, MyVo right) => !Equals(left, right.Value); | ||
|
||
public static explicit operator MyVo(System.Guid value) => From(value); | ||
public static explicit operator System.Guid(MyVo value) => value.Value; | ||
public static MyVo FromNewGuid() { return From(global::System.Guid.NewGuid()); } | ||
public int CompareTo(MyVo other) => Value.CompareTo(other.Value); | ||
public int CompareTo(object other) { | ||
if(other is null) return 1; | ||
if(other is MyVo x) return CompareTo(x); | ||
throw new global::System.ArgumentException("Cannot compare to object as it is not of type MyVo", nameof(other)); | ||
} | ||
|
||
|
||
/// <inheritdoc cref="System.Guid.TryParse(System.ReadOnlySpan{char}, out System.Guid)"/> | ||
/// <summary> | ||
/// </summary> | ||
/// <returns> | ||
/// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization). | ||
/// </returns> | ||
public static global::System.Boolean TryParse(global::System.ReadOnlySpan<char> input, | ||
#if NETCOREAPP3_0_OR_GREATER | ||
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] | ||
#endif | ||
out MyVo result) { | ||
if(System.Guid.TryParse(input, out var __v)) { | ||
|
||
|
||
result = new MyVo(__v); | ||
return true; | ||
} | ||
|
||
result = default; | ||
return false; | ||
} | ||
|
||
/// <inheritdoc cref="System.Guid.TryParse(string?, out System.Guid)"/> | ||
/// <summary> | ||
/// </summary> | ||
/// <returns> | ||
/// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization). | ||
/// </returns> | ||
public static global::System.Boolean TryParse(string input, | ||
#if NETCOREAPP3_0_OR_GREATER | ||
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] | ||
#endif | ||
out MyVo result) { | ||
if(System.Guid.TryParse(input, out var __v)) { | ||
|
||
|
||
result = new MyVo(__v); | ||
return true; | ||
} | ||
|
||
result = default; | ||
return false; | ||
} | ||
|
||
/// <inheritdoc cref="System.Guid.Parse(System.ReadOnlySpan{char})"/> | ||
/// <summary> | ||
/// </summary> | ||
/// <returns> | ||
/// The value created via the <see cref="From"/> method. | ||
/// </returns> | ||
/// <exception cref="ValueObjectValidationException">Thrown when the value can be parsed, but is not valid.</exception> | ||
public static MyVo Parse(global::System.ReadOnlySpan<char> input) { | ||
var r = System.Guid.Parse(input); | ||
return From(r); | ||
} | ||
|
||
/// <inheritdoc cref="System.Guid.Parse(string)"/> | ||
/// <summary> | ||
/// </summary> | ||
/// <returns> | ||
/// The value created via the <see cref="From"/> method. | ||
/// </returns> | ||
/// <exception cref="ValueObjectValidationException">Thrown when the value can be parsed, but is not valid.</exception> | ||
public static MyVo Parse(string input) { | ||
var r = System.Guid.Parse(input); | ||
return From(r); | ||
} | ||
|
||
|
||
|
||
public override global::System.Int32 GetHashCode() | ||
{ | ||
unchecked // Overflow is fine, just wrap | ||
{ | ||
global::System.Int32 hash = (global::System.Int32) 2166136261; | ||
hash = (hash * 16777619) ^ GetType().GetHashCode(); | ||
hash = (hash * 16777619) ^ global::System.Collections.Generic.EqualityComparer<System.Guid>.Default.GetHashCode(Value); | ||
return hash; | ||
} | ||
} | ||
|
||
private void EnsureInitialized() | ||
{ | ||
if (!_isInitialized) | ||
{ | ||
#if DEBUG | ||
global::System.String message = "Use of uninitialized Value Object at: " + _stackTrace ?? ""; | ||
#else | ||
global::System.String message = "Use of uninitialized Value Object."; | ||
#endif | ||
|
||
throw new global::Vogen.ValueObjectValidationException(message); | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
/// <summary>Returns the string representation of the underlying <see cref="System.Guid" />.</summary> | ||
/// <inheritdoc cref="System.Guid.ToString()" /> | ||
public override global::System.String ToString() => _isInitialized ? Value.ToString() : "[UNINITIALIZED]"; | ||
|
||
|
||
class MyVoSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter<MyVo> | ||
{ | ||
public override MyVo Read(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options) | ||
{ | ||
return MyVo.Deserialize(System.Guid.Parse(reader.GetString())); | ||
} | ||
|
||
public override void Write(System.Text.Json.Utf8JsonWriter writer, MyVo value, global::System.Text.Json.JsonSerializerOptions options) | ||
{ | ||
writer.WriteStringValue(value.Value); | ||
} | ||
|
||
#if NET6_0_OR_GREATER | ||
public override MyVo ReadAsPropertyName(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options) | ||
{ | ||
return MyVo.Deserialize(System.Guid.Parse(reader.GetString())); | ||
} | ||
|
||
public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, MyVo value, global::System.Text.Json.JsonSerializerOptions options) | ||
{ | ||
writer.WritePropertyName(value.Value.ToString()); | ||
} | ||
#endif | ||
} | ||
|
||
|
||
class MyVoTypeConverter : global::System.ComponentModel.TypeConverter | ||
{ | ||
public override global::System.Boolean CanConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType) | ||
{ | ||
return sourceType == typeof(global::System.Guid) || sourceType == typeof(global::System.String) || base.CanConvertFrom(context, sourceType); | ||
} | ||
|
||
public override global::System.Object ConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Globalization.CultureInfo culture, global::System.Object value) | ||
{ | ||
return value switch | ||
{ | ||
global::System.Guid guidValue => MyVo.Deserialize(guidValue), | ||
global::System.String stringValue when !global::System.String.IsNullOrEmpty(stringValue) && global::System.Guid.TryParse(stringValue, out var result) => MyVo.Deserialize(result), | ||
_ => base.ConvertFrom(context, culture, value), | ||
}; | ||
} | ||
|
||
public override bool CanConvertTo(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType) | ||
{ | ||
return sourceType == typeof(global::System.Guid) || sourceType == typeof(global::System.String) || base.CanConvertTo(context, sourceType); | ||
} | ||
|
||
public override object ConvertTo(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Globalization.CultureInfo culture, global::System.Object value, global::System.Type destinationType) | ||
{ | ||
if (value is MyVo idValue) | ||
{ | ||
if (destinationType == typeof(global::System.Guid)) | ||
{ | ||
return idValue.Value; | ||
} | ||
|
||
if (destinationType == typeof(global::System.String)) | ||
{ | ||
return idValue.Value.ToString(); | ||
} | ||
} | ||
|
||
return base.ConvertTo(context, culture, value, destinationType); | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
||
internal sealed class MyVoDebugView | ||
{ | ||
private readonly MyVo _t; | ||
|
||
MyVoDebugView(MyVo t) | ||
{ | ||
_t = t; | ||
} | ||
|
||
public global::System.String UnderlyingType => "System.Guid"; | ||
public System.Guid Value => _t.Value ; | ||
|
||
public global::System.String Conversions => @"[global::System.Text.Json.Serialization.JsonConverter(typeof(MyVoSystemTextJsonConverter))] | ||
[global::System.ComponentModel.TypeConverter(typeof(MyVoTypeConverter))] | ||
"; | ||
} | ||
} | ||
|
343 changes: 343 additions & 0 deletions
343
tests/SnapshotTests/GeneralStuff/snapshots/snap-v3.1/r69L6MTLWN.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,343 @@ | ||
// ------------------------------------------------------------------------------ | ||
// <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 | ||
|
||
// Suppress warnings about CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member' | ||
#pragma warning disable CS1591 | ||
|
||
using Vogen; | ||
|
||
|
||
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")] | ||
[global::System.Text.Json.Serialization.JsonConverter(typeof(MyVoSystemTextJsonConverter))] | ||
[global::System.ComponentModel.TypeConverter(typeof(MyVoTypeConverter))] | ||
|
||
[global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(MyVoDebugView))] | ||
[global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.Guid, Value = { _value }")] | ||
public partial record struct MyVo : global::System.IEquatable<MyVo>, global::System.IEquatable<System.Guid>, global::System.IComparable<MyVo>, global::System.IComparable | ||
{ | ||
#if DEBUG | ||
private readonly global::System.Diagnostics.StackTrace _stackTrace = null; | ||
#endif | ||
|
||
private readonly global::System.Boolean _isInitialized; | ||
|
||
private readonly System.Guid _value; | ||
|
||
/// <summary> | ||
/// Gets the underlying <see cref="System.Guid" /> value if set, otherwise a <see cref="ValueObjectValidationException" /> is thrown. | ||
/// </summary> | ||
public readonly System.Guid Value | ||
{ | ||
[global::System.Diagnostics.DebuggerStepThroughAttribute] | ||
get | ||
{ | ||
EnsureInitialized(); | ||
return _value; | ||
} | ||
[global::System.Diagnostics.DebuggerStepThroughAttribute] | ||
init | ||
{ | ||
|
||
|
||
|
||
|
||
|
||
|
||
_value = value; | ||
} | ||
} | ||
|
||
|
||
[global::System.Diagnostics.DebuggerStepThroughAttribute] | ||
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] | ||
public MyVo() | ||
{ | ||
#if DEBUG | ||
_stackTrace = new global::System.Diagnostics.StackTrace(); | ||
#endif | ||
|
||
_isInitialized = false; | ||
_value = default; | ||
} | ||
|
||
[global::System.Diagnostics.DebuggerStepThroughAttribute] | ||
private MyVo(System.Guid value) | ||
{ | ||
_value = value; | ||
_isInitialized = true; | ||
} | ||
|
||
/// <summary> | ||
/// Builds an instance from the provided underlying type. | ||
/// </summary> | ||
/// <param name="value">The underlying type.</param> | ||
/// <returns>An instance of this type.</returns> | ||
public static MyVo From(System.Guid value) | ||
{ | ||
|
||
|
||
|
||
|
||
MyVo instance = new MyVo(value); | ||
|
||
return instance; | ||
} | ||
|
||
public static explicit operator MyVo(System.Guid value) => From(value); | ||
public static explicit operator System.Guid(MyVo value) => value.Value; | ||
public static MyVo FromNewGuid() { return From(global::System.Guid.NewGuid()); } | ||
// only called internally when something has been deserialized into | ||
// its primitive type. | ||
private static MyVo Deserialize(System.Guid value) | ||
{ | ||
|
||
|
||
|
||
|
||
return new MyVo(value); | ||
} | ||
public readonly global::System.Boolean Equals(MyVo other) | ||
{ | ||
// It's possible to create uninitialized instances via converters such as EfCore (HasDefaultValue), which call Equals. | ||
// We treat anything uninitialized as not equal to anything, even other uninitialized instances of this type. | ||
if(!_isInitialized || !other._isInitialized) return false; | ||
|
||
return global::System.Collections.Generic.EqualityComparer<System.Guid>.Default.Equals(Value, other.Value); | ||
} | ||
public global::System.Boolean Equals(MyVo other, global::System.Collections.Generic.IEqualityComparer<MyVo> comparer) | ||
{ | ||
return comparer.Equals(this, other); | ||
} | ||
|
||
|
||
public readonly global::System.Boolean Equals(System.Guid primitive) | ||
{ | ||
return Value.Equals(primitive); | ||
} | ||
|
||
|
||
public static global::System.Boolean operator ==(MyVo left, System.Guid right) => Equals(left.Value, right); | ||
public static global::System.Boolean operator !=(MyVo left, System.Guid right) => !Equals(left.Value, right); | ||
|
||
public static global::System.Boolean operator ==(System.Guid left, MyVo right) => Equals(left, right.Value); | ||
public static global::System.Boolean operator !=(System.Guid left, MyVo right) => !Equals(left, right.Value); | ||
|
||
public int CompareTo(MyVo other) => Value.CompareTo(other.Value); | ||
public int CompareTo(object other) { | ||
if(other is null) return 1; | ||
if(other is MyVo x) return CompareTo(x); | ||
throw new global::System.ArgumentException("Cannot compare to object as it is not of type MyVo", nameof(other)); | ||
} | ||
|
||
|
||
/// <inheritdoc cref="System.Guid.TryParse(System.ReadOnlySpan{char}, out System.Guid)"/> | ||
/// <summary> | ||
/// </summary> | ||
/// <returns> | ||
/// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization). | ||
/// </returns> | ||
public static global::System.Boolean TryParse(global::System.ReadOnlySpan<char> input, | ||
#if NETCOREAPP3_0_OR_GREATER | ||
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] | ||
#endif | ||
out MyVo result) { | ||
if(System.Guid.TryParse(input, out var __v)) { | ||
|
||
|
||
result = new MyVo(__v); | ||
return true; | ||
} | ||
|
||
result = default; | ||
return false; | ||
} | ||
|
||
/// <inheritdoc cref="System.Guid.TryParse(string?, out System.Guid)"/> | ||
/// <summary> | ||
/// </summary> | ||
/// <returns> | ||
/// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization). | ||
/// </returns> | ||
public static global::System.Boolean TryParse(string input, | ||
#if NETCOREAPP3_0_OR_GREATER | ||
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] | ||
#endif | ||
out MyVo result) { | ||
if(System.Guid.TryParse(input, out var __v)) { | ||
|
||
|
||
result = new MyVo(__v); | ||
return true; | ||
} | ||
|
||
result = default; | ||
return false; | ||
} | ||
|
||
/// <inheritdoc cref="System.Guid.Parse(System.ReadOnlySpan{char})"/> | ||
/// <summary> | ||
/// </summary> | ||
/// <returns> | ||
/// The value created via the <see cref="From"/> method. | ||
/// </returns> | ||
/// <exception cref="ValueObjectValidationException">Thrown when the value can be parsed, but is not valid.</exception> | ||
public static MyVo Parse(global::System.ReadOnlySpan<char> input) { | ||
var r = System.Guid.Parse(input); | ||
return From(r); | ||
} | ||
|
||
/// <inheritdoc cref="System.Guid.Parse(string)"/> | ||
/// <summary> | ||
/// </summary> | ||
/// <returns> | ||
/// The value created via the <see cref="From"/> method. | ||
/// </returns> | ||
/// <exception cref="ValueObjectValidationException">Thrown when the value can be parsed, but is not valid.</exception> | ||
public static MyVo Parse(string input) { | ||
var r = System.Guid.Parse(input); | ||
return From(r); | ||
} | ||
|
||
|
||
|
||
public readonly override global::System.Int32 GetHashCode() | ||
{ | ||
return global::System.Collections.Generic.EqualityComparer<System.Guid>.Default.GetHashCode(Value); | ||
} | ||
|
||
private readonly void EnsureInitialized() | ||
{ | ||
if (!_isInitialized) | ||
{ | ||
#if DEBUG | ||
global::System.String message = "Use of uninitialized Value Object at: " + _stackTrace ?? ""; | ||
#else | ||
global::System.String message = "Use of uninitialized Value Object."; | ||
#endif | ||
|
||
throw new global::Vogen.ValueObjectValidationException(message); | ||
} | ||
} | ||
|
||
// record enumerates fields - we just want our Value and to throw if it's not initialized. | ||
/// <summary>Returns the string representation of the underlying type</summary> | ||
/// <inheritdoc cref="System.Guid.ToString()" /> | ||
public readonly override global::System.String ToString() =>_isInitialized ? Value.ToString() : "[UNINITIALIZED]"; | ||
|
||
|
||
|
||
|
||
class MyVoSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter<MyVo> | ||
{ | ||
public override MyVo Read(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options) | ||
{ | ||
return MyVo.Deserialize(System.Guid.Parse(reader.GetString())); | ||
} | ||
|
||
public override void Write(System.Text.Json.Utf8JsonWriter writer, MyVo value, global::System.Text.Json.JsonSerializerOptions options) | ||
{ | ||
writer.WriteStringValue(value.Value); | ||
} | ||
|
||
#if NET6_0_OR_GREATER | ||
public override MyVo ReadAsPropertyName(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options) | ||
{ | ||
return MyVo.Deserialize(System.Guid.Parse(reader.GetString())); | ||
} | ||
|
||
public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, MyVo value, global::System.Text.Json.JsonSerializerOptions options) | ||
{ | ||
writer.WritePropertyName(value.Value.ToString()); | ||
} | ||
#endif | ||
} | ||
|
||
|
||
class MyVoTypeConverter : global::System.ComponentModel.TypeConverter | ||
{ | ||
public override global::System.Boolean CanConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType) | ||
{ | ||
return sourceType == typeof(global::System.Guid) || sourceType == typeof(global::System.String) || base.CanConvertFrom(context, sourceType); | ||
} | ||
|
||
public override global::System.Object ConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Globalization.CultureInfo culture, global::System.Object value) | ||
{ | ||
return value switch | ||
{ | ||
global::System.Guid guidValue => MyVo.Deserialize(guidValue), | ||
global::System.String stringValue when !global::System.String.IsNullOrEmpty(stringValue) && global::System.Guid.TryParse(stringValue, out var result) => MyVo.Deserialize(result), | ||
_ => base.ConvertFrom(context, culture, value), | ||
}; | ||
} | ||
|
||
public override bool CanConvertTo(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType) | ||
{ | ||
return sourceType == typeof(global::System.Guid) || sourceType == typeof(global::System.String) || base.CanConvertTo(context, sourceType); | ||
} | ||
|
||
public override object ConvertTo(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Globalization.CultureInfo culture, global::System.Object value, global::System.Type destinationType) | ||
{ | ||
if (value is MyVo idValue) | ||
{ | ||
if (destinationType == typeof(global::System.Guid)) | ||
{ | ||
return idValue.Value; | ||
} | ||
|
||
if (destinationType == typeof(global::System.String)) | ||
{ | ||
return idValue.Value.ToString(); | ||
} | ||
} | ||
|
||
return base.ConvertTo(context, culture, value, destinationType); | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
internal sealed class MyVoDebugView | ||
{ | ||
private readonly MyVo _t; | ||
|
||
MyVoDebugView(MyVo t) | ||
{ | ||
_t = t; | ||
} | ||
|
||
public global::System.Boolean IsInitialized => _t._isInitialized; | ||
public global::System.String UnderlyingType => "System.Guid"; | ||
public global::System.String Value => _t._isInitialized ? _t._value.ToString() : "[not initialized]" ; | ||
|
||
#if DEBUG | ||
public global::System.String CreatedWith => _t._stackTrace?.ToString() ?? "the From method"; | ||
#endif | ||
|
||
public global::System.String Conversions => @"Default"; | ||
} | ||
|
||
} | ||
|
305 changes: 305 additions & 0 deletions
305
tests/SnapshotTests/GeneralStuff/snapshots/snap-v4.6.1/0Rjlo8wVsY.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,305 @@ | ||
// ------------------------------------------------------------------------------ | ||
// <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 | ||
|
||
// Suppress warnings about CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member' | ||
#pragma warning disable CS1591 | ||
|
||
using Vogen; | ||
|
||
|
||
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")] | ||
[global::System.Text.Json.Serialization.JsonConverter(typeof(MyVoSystemTextJsonConverter))] | ||
[global::System.ComponentModel.TypeConverter(typeof(MyVoTypeConverter))] | ||
|
||
[global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(MyVoDebugView))] | ||
[global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.Guid, Value = { _value }")] | ||
public partial struct MyVo : global::System.IEquatable<MyVo>, global::System.IEquatable<System.Guid>, global::System.IComparable<MyVo>, global::System.IComparable | ||
{ | ||
#if DEBUG | ||
private readonly global::System.Diagnostics.StackTrace _stackTrace = null; | ||
#endif | ||
|
||
private readonly global::System.Boolean _isInitialized; | ||
|
||
private readonly System.Guid _value; | ||
|
||
/// <summary> | ||
/// Gets the underlying <see cref="System.Guid" /> value if set, otherwise a <see cref="ValueObjectValidationException" /> is thrown. | ||
/// </summary> | ||
public readonly System.Guid Value | ||
{ | ||
[global::System.Diagnostics.DebuggerStepThroughAttribute] | ||
get | ||
{ | ||
EnsureInitialized(); | ||
return _value; | ||
} | ||
} | ||
|
||
|
||
[global::System.Diagnostics.DebuggerStepThroughAttribute] | ||
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] | ||
public MyVo() | ||
{ | ||
#if DEBUG | ||
_stackTrace = new global::System.Diagnostics.StackTrace(); | ||
#endif | ||
|
||
_isInitialized = false; | ||
_value = default; | ||
} | ||
|
||
[global::System.Diagnostics.DebuggerStepThroughAttribute] | ||
private MyVo(System.Guid value) | ||
{ | ||
_value = value; | ||
_isInitialized = true; | ||
} | ||
|
||
/// <summary> | ||
/// Builds an instance from the provided underlying type. | ||
/// </summary> | ||
/// <param name="value">The underlying type.</param> | ||
/// <returns>An instance of this type.</returns> | ||
public static MyVo From(System.Guid value) | ||
{ | ||
|
||
|
||
|
||
|
||
MyVo instance = new MyVo(value); | ||
|
||
return instance; | ||
} | ||
|
||
|
||
public static explicit operator MyVo(System.Guid value) => From(value); | ||
public static explicit operator System.Guid(MyVo value) => value.Value; | ||
public static MyVo FromNewGuid() { return From(global::System.Guid.NewGuid()); } | ||
// only called internally when something has been deserialized into | ||
// its primitive type. | ||
private static MyVo Deserialize(System.Guid value) | ||
{ | ||
|
||
|
||
|
||
|
||
return new MyVo(value); | ||
} | ||
public readonly global::System.Boolean Equals(MyVo other) | ||
{ | ||
// It's possible to create uninitialized instances via converters such as EfCore (HasDefaultValue), which call Equals. | ||
// We treat anything uninitialized as not equal to anything, even other uninitialized instances of this type. | ||
if(!_isInitialized || !other._isInitialized) return false; | ||
|
||
return global::System.Collections.Generic.EqualityComparer<System.Guid>.Default.Equals(Value, other.Value); | ||
} | ||
public global::System.Boolean Equals(MyVo other, global::System.Collections.Generic.IEqualityComparer<MyVo> comparer) | ||
{ | ||
return comparer.Equals(this, other); | ||
} | ||
|
||
|
||
public readonly global::System.Boolean Equals(System.Guid primitive) | ||
{ | ||
return Value.Equals(primitive); | ||
} | ||
|
||
public readonly override global::System.Boolean Equals(global::System.Object obj) | ||
{ | ||
return obj is MyVo && Equals((MyVo) obj); | ||
} | ||
|
||
public static global::System.Boolean operator ==(MyVo left, MyVo right) => Equals(left, right); | ||
public static global::System.Boolean operator !=(MyVo left, MyVo right) => !(left == right); | ||
|
||
public static global::System.Boolean operator ==(MyVo left, System.Guid right) => Equals(left.Value, right); | ||
public static global::System.Boolean operator !=(MyVo left, System.Guid right) => !Equals(left.Value, right); | ||
|
||
public static global::System.Boolean operator ==(System.Guid left, MyVo right) => Equals(left, right.Value); | ||
public static global::System.Boolean operator !=(System.Guid left, MyVo right) => !Equals(left, right.Value); | ||
|
||
public int CompareTo(MyVo other) => Value.CompareTo(other.Value); | ||
public int CompareTo(object other) { | ||
if(other is null) return 1; | ||
if(other is MyVo x) return CompareTo(x); | ||
throw new global::System.ArgumentException("Cannot compare to object as it is not of type MyVo", nameof(other)); | ||
} | ||
|
||
|
||
/// <inheritdoc cref="System.Guid.TryParse(string, out System.Guid)"/> | ||
/// <summary> | ||
/// </summary> | ||
/// <returns> | ||
/// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization). | ||
/// </returns> | ||
public static global::System.Boolean TryParse(string input, | ||
#if NETCOREAPP3_0_OR_GREATER | ||
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] | ||
#endif | ||
out MyVo result) { | ||
if(System.Guid.TryParse(input, out var __v)) { | ||
|
||
|
||
result = new MyVo(__v); | ||
return true; | ||
} | ||
|
||
result = default; | ||
return false; | ||
} | ||
|
||
/// <inheritdoc cref="System.Guid.Parse(string)"/> | ||
/// <summary> | ||
/// </summary> | ||
/// <returns> | ||
/// The value created via the <see cref="From"/> method. | ||
/// </returns> | ||
/// <exception cref="ValueObjectValidationException">Thrown when the value can be parsed, but is not valid.</exception> | ||
public static MyVo Parse(string input) { | ||
var r = System.Guid.Parse(input); | ||
return From(r); | ||
} | ||
|
||
|
||
|
||
public readonly override global::System.Int32 GetHashCode() | ||
{ | ||
return global::System.Collections.Generic.EqualityComparer<System.Guid>.Default.GetHashCode(Value); | ||
} | ||
|
||
/// <summary>Returns the string representation of the underlying type</summary> | ||
/// <inheritdoc cref="System.Guid.ToString()" /> | ||
public readonly override global::System.String ToString() =>_isInitialized ? Value.ToString() : "[UNINITIALIZED]"; | ||
|
||
private readonly void EnsureInitialized() | ||
{ | ||
if (!_isInitialized) | ||
{ | ||
#if DEBUG | ||
global::System.String message = "Use of uninitialized Value Object at: " + _stackTrace ?? ""; | ||
#else | ||
global::System.String message = "Use of uninitialized Value Object."; | ||
#endif | ||
|
||
throw new global::Vogen.ValueObjectValidationException(message); | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
class MyVoSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter<MyVo> | ||
{ | ||
public override MyVo Read(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options) | ||
{ | ||
return MyVo.Deserialize(System.Guid.Parse(reader.GetString())); | ||
} | ||
|
||
public override void Write(System.Text.Json.Utf8JsonWriter writer, MyVo value, global::System.Text.Json.JsonSerializerOptions options) | ||
{ | ||
writer.WriteStringValue(value.Value); | ||
} | ||
|
||
#if NET6_0_OR_GREATER | ||
public override MyVo ReadAsPropertyName(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options) | ||
{ | ||
return MyVo.Deserialize(System.Guid.Parse(reader.GetString())); | ||
} | ||
|
||
public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, MyVo value, global::System.Text.Json.JsonSerializerOptions options) | ||
{ | ||
writer.WritePropertyName(value.Value.ToString()); | ||
} | ||
#endif | ||
} | ||
|
||
|
||
class MyVoTypeConverter : global::System.ComponentModel.TypeConverter | ||
{ | ||
public override global::System.Boolean CanConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType) | ||
{ | ||
return sourceType == typeof(global::System.Guid) || sourceType == typeof(global::System.String) || base.CanConvertFrom(context, sourceType); | ||
} | ||
|
||
public override global::System.Object ConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Globalization.CultureInfo culture, global::System.Object value) | ||
{ | ||
return value switch | ||
{ | ||
global::System.Guid guidValue => MyVo.Deserialize(guidValue), | ||
global::System.String stringValue when !global::System.String.IsNullOrEmpty(stringValue) && global::System.Guid.TryParse(stringValue, out var result) => MyVo.Deserialize(result), | ||
_ => base.ConvertFrom(context, culture, value), | ||
}; | ||
} | ||
|
||
public override bool CanConvertTo(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType) | ||
{ | ||
return sourceType == typeof(global::System.Guid) || sourceType == typeof(global::System.String) || base.CanConvertTo(context, sourceType); | ||
} | ||
|
||
public override object ConvertTo(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Globalization.CultureInfo culture, global::System.Object value, global::System.Type destinationType) | ||
{ | ||
if (value is MyVo idValue) | ||
{ | ||
if (destinationType == typeof(global::System.Guid)) | ||
{ | ||
return idValue.Value; | ||
} | ||
|
||
if (destinationType == typeof(global::System.String)) | ||
{ | ||
return idValue.Value.ToString(); | ||
} | ||
} | ||
|
||
return base.ConvertTo(context, culture, value, destinationType); | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
internal sealed class MyVoDebugView | ||
{ | ||
private readonly MyVo _t; | ||
|
||
MyVoDebugView(MyVo t) | ||
{ | ||
_t = t; | ||
} | ||
|
||
public global::System.Boolean IsInitialized => _t._isInitialized; | ||
public global::System.String UnderlyingType => "System.Guid"; | ||
public global::System.String Value => _t._isInitialized ? _t._value.ToString() : "[not initialized]" ; | ||
|
||
#if DEBUG | ||
public global::System.String CreatedWith => _t._stackTrace?.ToString() ?? "the From method"; | ||
#endif | ||
|
||
public global::System.String Conversions => @"Default"; | ||
} | ||
|
||
} | ||
|
323 changes: 323 additions & 0 deletions
323
tests/SnapshotTests/GeneralStuff/snapshots/snap-v4.6.1/LZDZ0jdOF6.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,323 @@ | ||
// ------------------------------------------------------------------------------ | ||
// <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 | ||
|
||
// Suppress warnings about CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member' | ||
#pragma warning disable CS1591 | ||
|
||
using Vogen; | ||
|
||
|
||
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")] | ||
[global::System.Text.Json.Serialization.JsonConverter(typeof(MyVoSystemTextJsonConverter))] | ||
[global::System.ComponentModel.TypeConverter(typeof(MyVoTypeConverter))] | ||
|
||
[global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(MyVoDebugView))] | ||
[global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.Guid, Value = { _value }")] | ||
public partial record class MyVo : global::System.IEquatable<MyVo>, global::System.IEquatable<System.Guid>, global::System.IComparable<MyVo>, global::System.IComparable | ||
{ | ||
#if DEBUG | ||
private readonly global::System.Diagnostics.StackTrace _stackTrace = null; | ||
#endif | ||
private readonly global::System.Boolean _isInitialized; | ||
private readonly System.Guid _value; | ||
|
||
/// <summary> | ||
/// Gets the underlying <see cref="System.Guid" /> value if set, otherwise a <see cref="ValueObjectValidationException" /> is thrown. | ||
/// </summary> | ||
public System.Guid Value | ||
{ | ||
[global::System.Diagnostics.DebuggerStepThroughAttribute] | ||
get | ||
{ | ||
EnsureInitialized(); | ||
return _value; | ||
} | ||
[global::System.Diagnostics.DebuggerStepThroughAttribute] | ||
init | ||
{ | ||
|
||
|
||
|
||
|
||
|
||
|
||
_value = value; | ||
} | ||
} | ||
|
||
|
||
[global::System.Diagnostics.DebuggerStepThroughAttribute] | ||
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] | ||
public MyVo() | ||
{ | ||
#if DEBUG | ||
_stackTrace = new global::System.Diagnostics.StackTrace(); | ||
#endif | ||
_isInitialized = false; | ||
_value = default; | ||
} | ||
|
||
[global::System.Diagnostics.DebuggerStepThroughAttribute] | ||
private MyVo(System.Guid value) | ||
{ | ||
_value = value; | ||
_isInitialized = true; | ||
} | ||
|
||
/// <summary> | ||
/// Builds an instance from the provided underlying type. | ||
/// </summary> | ||
/// <param name="value">The underlying type.</param> | ||
/// <returns>An instance of this type.</returns> | ||
public static MyVo From(System.Guid value) | ||
{ | ||
|
||
|
||
|
||
|
||
|
||
|
||
MyVo instance = new MyVo(value); | ||
|
||
return instance; | ||
} | ||
|
||
// only called internally when something has been deserialized into | ||
// its primitive type. | ||
private static MyVo Deserialize(System.Guid value) | ||
{ | ||
|
||
|
||
|
||
|
||
|
||
|
||
return new MyVo(value); | ||
} | ||
|
||
public virtual global::System.Boolean Equals(MyVo other) | ||
{ | ||
if (ReferenceEquals(null, other)) | ||
{ | ||
return false; | ||
} | ||
|
||
// It's possible to create uninitialized instances via converters such as EfCore (HasDefaultValue), which call Equals. | ||
// We treat anything uninitialized as not equal to anything, even other uninitialized instances of this type. | ||
if(!_isInitialized || !other._isInitialized) return false; | ||
|
||
if (ReferenceEquals(this, other)) | ||
{ | ||
return true; | ||
} | ||
|
||
return GetType() == other.GetType() && global::System.Collections.Generic.EqualityComparer<System.Guid>.Default.Equals(Value, other.Value); | ||
} | ||
public global::System.Boolean Equals(MyVo other, global::System.Collections.Generic.IEqualityComparer<MyVo> comparer) | ||
{ | ||
return comparer.Equals(this, other); | ||
} | ||
|
||
|
||
public global::System.Boolean Equals(System.Guid primitive) | ||
{ | ||
return Value.Equals(primitive); | ||
} | ||
|
||
|
||
public static global::System.Boolean operator ==(MyVo left, System.Guid right) => Equals(left.Value, right); | ||
public static global::System.Boolean operator !=(MyVo left, System.Guid right) => !Equals(left.Value, right); | ||
|
||
public static global::System.Boolean operator ==(System.Guid left, MyVo right) => Equals(left, right.Value); | ||
public static global::System.Boolean operator !=(System.Guid left, MyVo right) => !Equals(left, right.Value); | ||
|
||
public static explicit operator MyVo(System.Guid value) => From(value); | ||
public static explicit operator System.Guid(MyVo value) => value.Value; | ||
public static MyVo FromNewGuid() { return From(global::System.Guid.NewGuid()); } | ||
public int CompareTo(MyVo other) => Value.CompareTo(other.Value); | ||
public int CompareTo(object other) { | ||
if(other is null) return 1; | ||
if(other is MyVo x) return CompareTo(x); | ||
throw new global::System.ArgumentException("Cannot compare to object as it is not of type MyVo", nameof(other)); | ||
} | ||
|
||
|
||
/// <inheritdoc cref="System.Guid.TryParse(string, out System.Guid)"/> | ||
/// <summary> | ||
/// </summary> | ||
/// <returns> | ||
/// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization). | ||
/// </returns> | ||
public static global::System.Boolean TryParse(string input, | ||
#if NETCOREAPP3_0_OR_GREATER | ||
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] | ||
#endif | ||
out MyVo result) { | ||
if(System.Guid.TryParse(input, out var __v)) { | ||
|
||
|
||
result = new MyVo(__v); | ||
return true; | ||
} | ||
|
||
result = default; | ||
return false; | ||
} | ||
|
||
/// <inheritdoc cref="System.Guid.Parse(string)"/> | ||
/// <summary> | ||
/// </summary> | ||
/// <returns> | ||
/// The value created via the <see cref="From"/> method. | ||
/// </returns> | ||
/// <exception cref="ValueObjectValidationException">Thrown when the value can be parsed, but is not valid.</exception> | ||
public static MyVo Parse(string input) { | ||
var r = System.Guid.Parse(input); | ||
return From(r); | ||
} | ||
|
||
|
||
|
||
public override global::System.Int32 GetHashCode() | ||
{ | ||
unchecked // Overflow is fine, just wrap | ||
{ | ||
global::System.Int32 hash = (global::System.Int32) 2166136261; | ||
hash = (hash * 16777619) ^ GetType().GetHashCode(); | ||
hash = (hash * 16777619) ^ global::System.Collections.Generic.EqualityComparer<System.Guid>.Default.GetHashCode(Value); | ||
return hash; | ||
} | ||
} | ||
|
||
private void EnsureInitialized() | ||
{ | ||
if (!_isInitialized) | ||
{ | ||
#if DEBUG | ||
global::System.String message = "Use of uninitialized Value Object at: " + _stackTrace ?? ""; | ||
#else | ||
global::System.String message = "Use of uninitialized Value Object."; | ||
#endif | ||
|
||
throw new global::Vogen.ValueObjectValidationException(message); | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
// record enumerates fields - we just want our Value and to throw if it's not initialized. | ||
/// <summary>Returns the string representation of the underlying <see cref="System.Guid" />.</summary> | ||
/// <inheritdoc cref="System.Guid.ToString()" /> | ||
public override global::System.String ToString() => _isInitialized ? Value.ToString() : "[UNINITIALIZED]"; | ||
|
||
|
||
class MyVoSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter<MyVo> | ||
{ | ||
public override MyVo Read(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options) | ||
{ | ||
return MyVo.Deserialize(System.Guid.Parse(reader.GetString())); | ||
} | ||
|
||
public override void Write(System.Text.Json.Utf8JsonWriter writer, MyVo value, global::System.Text.Json.JsonSerializerOptions options) | ||
{ | ||
writer.WriteStringValue(value.Value); | ||
} | ||
|
||
#if NET6_0_OR_GREATER | ||
public override MyVo ReadAsPropertyName(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options) | ||
{ | ||
return MyVo.Deserialize(System.Guid.Parse(reader.GetString())); | ||
} | ||
|
||
public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, MyVo value, global::System.Text.Json.JsonSerializerOptions options) | ||
{ | ||
writer.WritePropertyName(value.Value.ToString()); | ||
} | ||
#endif | ||
} | ||
|
||
|
||
class MyVoTypeConverter : global::System.ComponentModel.TypeConverter | ||
{ | ||
public override global::System.Boolean CanConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType) | ||
{ | ||
return sourceType == typeof(global::System.Guid) || sourceType == typeof(global::System.String) || base.CanConvertFrom(context, sourceType); | ||
} | ||
|
||
public override global::System.Object ConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Globalization.CultureInfo culture, global::System.Object value) | ||
{ | ||
return value switch | ||
{ | ||
global::System.Guid guidValue => MyVo.Deserialize(guidValue), | ||
global::System.String stringValue when !global::System.String.IsNullOrEmpty(stringValue) && global::System.Guid.TryParse(stringValue, out var result) => MyVo.Deserialize(result), | ||
_ => base.ConvertFrom(context, culture, value), | ||
}; | ||
} | ||
|
||
public override bool CanConvertTo(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType) | ||
{ | ||
return sourceType == typeof(global::System.Guid) || sourceType == typeof(global::System.String) || base.CanConvertTo(context, sourceType); | ||
} | ||
|
||
public override object ConvertTo(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Globalization.CultureInfo culture, global::System.Object value, global::System.Type destinationType) | ||
{ | ||
if (value is MyVo idValue) | ||
{ | ||
if (destinationType == typeof(global::System.Guid)) | ||
{ | ||
return idValue.Value; | ||
} | ||
|
||
if (destinationType == typeof(global::System.String)) | ||
{ | ||
return idValue.Value.ToString(); | ||
} | ||
} | ||
|
||
return base.ConvertTo(context, culture, value, destinationType); | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
||
internal sealed class MyVoDebugView | ||
{ | ||
private readonly MyVo _t; | ||
|
||
MyVoDebugView(MyVo t) | ||
{ | ||
_t = t; | ||
} | ||
|
||
public global::System.String UnderlyingType => "System.Guid"; | ||
public System.Guid Value => _t.Value ; | ||
|
||
public global::System.String Conversions => @"[global::System.Text.Json.Serialization.JsonConverter(typeof(MyVoSystemTextJsonConverter))] | ||
[global::System.ComponentModel.TypeConverter(typeof(MyVoTypeConverter))] | ||
"; | ||
} | ||
} | ||
|
319 changes: 319 additions & 0 deletions
319
tests/SnapshotTests/GeneralStuff/snapshots/snap-v4.6.1/jXZ79bcjc9.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,319 @@ | ||
// ------------------------------------------------------------------------------ | ||
// <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 | ||
|
||
// Suppress warnings about CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member' | ||
#pragma warning disable CS1591 | ||
|
||
using Vogen; | ||
|
||
|
||
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")] | ||
[global::System.Text.Json.Serialization.JsonConverter(typeof(MyVoSystemTextJsonConverter))] | ||
[global::System.ComponentModel.TypeConverter(typeof(MyVoTypeConverter))] | ||
|
||
[global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(MyVoDebugView))] | ||
[global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.Guid, Value = { _value }")] | ||
public partial class MyVo : global::System.IEquatable<MyVo>, global::System.IEquatable<System.Guid> , global::System.IComparable<MyVo>, global::System.IComparable | ||
{ | ||
#if DEBUG | ||
private readonly global::System.Diagnostics.StackTrace _stackTrace = null; | ||
#endif | ||
private readonly global::System.Boolean _isInitialized; | ||
private readonly System.Guid _value; | ||
|
||
/// <summary> | ||
/// Gets the underlying <see cref="System.Guid" /> value if set, otherwise a <see cref="ValueObjectValidationException" /> is thrown. | ||
/// </summary> | ||
public System.Guid Value | ||
{ | ||
[global::System.Diagnostics.DebuggerStepThroughAttribute] | ||
get | ||
{ | ||
EnsureInitialized(); | ||
return _value; | ||
} | ||
} | ||
|
||
|
||
[global::System.Diagnostics.DebuggerStepThroughAttribute] | ||
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] | ||
public MyVo() | ||
{ | ||
#if DEBUG | ||
_stackTrace = new global::System.Diagnostics.StackTrace(); | ||
#endif | ||
_isInitialized = false; | ||
_value = default; | ||
} | ||
|
||
[global::System.Diagnostics.DebuggerStepThroughAttribute] | ||
private MyVo(System.Guid value) | ||
{ | ||
_value = value; | ||
_isInitialized = true; | ||
} | ||
|
||
/// <summary> | ||
/// Builds an instance from the provided underlying type. | ||
/// </summary> | ||
/// <param name="value">The underlying type.</param> | ||
/// <returns>An instance of this type.</returns> | ||
public static MyVo From(System.Guid value) | ||
{ | ||
|
||
|
||
|
||
|
||
|
||
|
||
MyVo instance = new MyVo(value); | ||
|
||
return instance; | ||
} | ||
|
||
|
||
// only called internally when something has been deserialized into | ||
// its primitive type. | ||
private static MyVo Deserialize(System.Guid value) | ||
{ | ||
|
||
|
||
|
||
|
||
|
||
|
||
return new MyVo(value); | ||
} | ||
|
||
public global::System.Boolean Equals(MyVo other) | ||
{ | ||
if (ReferenceEquals(null, other)) | ||
{ | ||
return false; | ||
} | ||
|
||
// It's possible to create uninitialized instances via converters such as EfCore (HasDefaultValue), which call Equals. | ||
// We treat anything uninitialized as not equal to anything, even other uninitialized instances of this type. | ||
if(!_isInitialized || !other._isInitialized) return false; | ||
|
||
if (ReferenceEquals(this, other)) | ||
{ | ||
return true; | ||
} | ||
|
||
return GetType() == other.GetType() && global::System.Collections.Generic.EqualityComparer<System.Guid>.Default.Equals(Value, other.Value); | ||
} | ||
public global::System.Boolean Equals(MyVo other, global::System.Collections.Generic.IEqualityComparer<MyVo> comparer) | ||
{ | ||
return comparer.Equals(this, other); | ||
} | ||
|
||
|
||
public global::System.Boolean Equals(System.Guid primitive) | ||
{ | ||
return Value.Equals(primitive); | ||
} | ||
|
||
public override global::System.Boolean Equals(global::System.Object obj) | ||
{ | ||
return Equals(obj as MyVo); | ||
} | ||
|
||
public static global::System.Boolean operator ==(MyVo left, MyVo right) => Equals(left, right); | ||
public static global::System.Boolean operator !=(MyVo left, MyVo right) => !Equals(left, right); | ||
|
||
public static global::System.Boolean operator ==(MyVo left, System.Guid right) => Equals(left.Value, right); | ||
public static global::System.Boolean operator !=(MyVo left, System.Guid right) => !Equals(left.Value, right); | ||
|
||
public static global::System.Boolean operator ==(System.Guid left, MyVo right) => Equals(left, right.Value); | ||
public static global::System.Boolean operator !=(System.Guid left, MyVo right) => !Equals(left, right.Value); | ||
|
||
public static explicit operator MyVo(System.Guid value) => From(value); | ||
public static explicit operator System.Guid(MyVo value) => value.Value; | ||
public static MyVo FromNewGuid() { return From(global::System.Guid.NewGuid()); } | ||
public int CompareTo(MyVo other) => Value.CompareTo(other.Value); | ||
public int CompareTo(object other) { | ||
if(other is null) return 1; | ||
if(other is MyVo x) return CompareTo(x); | ||
throw new global::System.ArgumentException("Cannot compare to object as it is not of type MyVo", nameof(other)); | ||
} | ||
|
||
|
||
/// <inheritdoc cref="System.Guid.TryParse(string, out System.Guid)"/> | ||
/// <summary> | ||
/// </summary> | ||
/// <returns> | ||
/// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization). | ||
/// </returns> | ||
public static global::System.Boolean TryParse(string input, | ||
#if NETCOREAPP3_0_OR_GREATER | ||
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] | ||
#endif | ||
out MyVo result) { | ||
if(System.Guid.TryParse(input, out var __v)) { | ||
|
||
|
||
result = new MyVo(__v); | ||
return true; | ||
} | ||
|
||
result = default; | ||
return false; | ||
} | ||
|
||
/// <inheritdoc cref="System.Guid.Parse(string)"/> | ||
/// <summary> | ||
/// </summary> | ||
/// <returns> | ||
/// The value created via the <see cref="From"/> method. | ||
/// </returns> | ||
/// <exception cref="ValueObjectValidationException">Thrown when the value can be parsed, but is not valid.</exception> | ||
public static MyVo Parse(string input) { | ||
var r = System.Guid.Parse(input); | ||
return From(r); | ||
} | ||
|
||
|
||
|
||
public override global::System.Int32 GetHashCode() | ||
{ | ||
unchecked // Overflow is fine, just wrap | ||
{ | ||
global::System.Int32 hash = (global::System.Int32) 2166136261; | ||
hash = (hash * 16777619) ^ GetType().GetHashCode(); | ||
hash = (hash * 16777619) ^ global::System.Collections.Generic.EqualityComparer<System.Guid>.Default.GetHashCode(Value); | ||
return hash; | ||
} | ||
} | ||
|
||
private void EnsureInitialized() | ||
{ | ||
if (!_isInitialized) | ||
{ | ||
#if DEBUG | ||
global::System.String message = "Use of uninitialized Value Object at: " + _stackTrace ?? ""; | ||
#else | ||
global::System.String message = "Use of uninitialized Value Object."; | ||
#endif | ||
|
||
throw new global::Vogen.ValueObjectValidationException(message); | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
/// <summary>Returns the string representation of the underlying <see cref="System.Guid" />.</summary> | ||
/// <inheritdoc cref="System.Guid.ToString()" /> | ||
public override global::System.String ToString() => _isInitialized ? Value.ToString() : "[UNINITIALIZED]"; | ||
|
||
|
||
class MyVoSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter<MyVo> | ||
{ | ||
public override MyVo Read(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options) | ||
{ | ||
return MyVo.Deserialize(System.Guid.Parse(reader.GetString())); | ||
} | ||
|
||
public override void Write(System.Text.Json.Utf8JsonWriter writer, MyVo value, global::System.Text.Json.JsonSerializerOptions options) | ||
{ | ||
writer.WriteStringValue(value.Value); | ||
} | ||
|
||
#if NET6_0_OR_GREATER | ||
public override MyVo ReadAsPropertyName(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options) | ||
{ | ||
return MyVo.Deserialize(System.Guid.Parse(reader.GetString())); | ||
} | ||
|
||
public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, MyVo value, global::System.Text.Json.JsonSerializerOptions options) | ||
{ | ||
writer.WritePropertyName(value.Value.ToString()); | ||
} | ||
#endif | ||
} | ||
|
||
|
||
class MyVoTypeConverter : global::System.ComponentModel.TypeConverter | ||
{ | ||
public override global::System.Boolean CanConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType) | ||
{ | ||
return sourceType == typeof(global::System.Guid) || sourceType == typeof(global::System.String) || base.CanConvertFrom(context, sourceType); | ||
} | ||
|
||
public override global::System.Object ConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Globalization.CultureInfo culture, global::System.Object value) | ||
{ | ||
return value switch | ||
{ | ||
global::System.Guid guidValue => MyVo.Deserialize(guidValue), | ||
global::System.String stringValue when !global::System.String.IsNullOrEmpty(stringValue) && global::System.Guid.TryParse(stringValue, out var result) => MyVo.Deserialize(result), | ||
_ => base.ConvertFrom(context, culture, value), | ||
}; | ||
} | ||
|
||
public override bool CanConvertTo(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType) | ||
{ | ||
return sourceType == typeof(global::System.Guid) || sourceType == typeof(global::System.String) || base.CanConvertTo(context, sourceType); | ||
} | ||
|
||
public override object ConvertTo(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Globalization.CultureInfo culture, global::System.Object value, global::System.Type destinationType) | ||
{ | ||
if (value is MyVo idValue) | ||
{ | ||
if (destinationType == typeof(global::System.Guid)) | ||
{ | ||
return idValue.Value; | ||
} | ||
|
||
if (destinationType == typeof(global::System.String)) | ||
{ | ||
return idValue.Value.ToString(); | ||
} | ||
} | ||
|
||
return base.ConvertTo(context, culture, value, destinationType); | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
||
internal sealed class MyVoDebugView | ||
{ | ||
private readonly MyVo _t; | ||
|
||
MyVoDebugView(MyVo t) | ||
{ | ||
_t = t; | ||
} | ||
|
||
public global::System.String UnderlyingType => "System.Guid"; | ||
public System.Guid Value => _t.Value ; | ||
|
||
public global::System.String Conversions => @"[global::System.Text.Json.Serialization.JsonConverter(typeof(MyVoSystemTextJsonConverter))] | ||
[global::System.ComponentModel.TypeConverter(typeof(MyVoTypeConverter))] | ||
"; | ||
} | ||
} | ||
|
Oops, something went wrong.