diff --git a/Consumers.sln b/Consumers.sln
index 77bf43f4fb..eeaeb07a80 100644
--- a/Consumers.sln
+++ b/Consumers.sln
@@ -42,6 +42,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExampleExtensions", "sample
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vogen.Benchmarks", "tests\Vogen.Benchmarks\Vogen.Benchmarks.csproj", "{0FF8DF8D-76E3-4511-B204-44687615429D}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "1MyProg", "samples\1MyProg\1MyProg.csproj", "{2CDDD2E7-2CC0-470B-AE5A-60B018F08998}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -96,6 +98,10 @@ Global
{0FF8DF8D-76E3-4511-B204-44687615429D}.Debug|Any CPU.Build.0 = Release|Any CPU
{0FF8DF8D-76E3-4511-B204-44687615429D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0FF8DF8D-76E3-4511-B204-44687615429D}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2CDDD2E7-2CC0-470B-AE5A-60B018F08998}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2CDDD2E7-2CC0-470B-AE5A-60B018F08998}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2CDDD2E7-2CC0-470B-AE5A-60B018F08998}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2CDDD2E7-2CC0-470B-AE5A-60B018F08998}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/samples/1MyProg/1MyProg.csproj b/samples/1MyProg/1MyProg.csproj
new file mode 100644
index 0000000000..4c3eb003ad
--- /dev/null
+++ b/samples/1MyProg/1MyProg.csproj
@@ -0,0 +1,25 @@
+
+
+
+ Exe
+ net10.0
+ _1MyProg
+ enable
+ enable
+ true
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
+
+
+
diff --git a/samples/1MyProg/Program.cs b/samples/1MyProg/Program.cs
new file mode 100644
index 0000000000..40f422dea7
--- /dev/null
+++ b/samples/1MyProg/Program.cs
@@ -0,0 +1,6 @@
+using Vogen;
+
+Console.WriteLine("Hello, World!");
+
+[ValueObject]
+public partial class MyId;
\ No newline at end of file
diff --git a/samples/AotTrimmedSample/Program.cs b/samples/AotTrimmedSample/Program.cs
index 3a0079d6a0..0c6aa35597 100644
--- a/samples/AotTrimmedSample/Program.cs
+++ b/samples/AotTrimmedSample/Program.cs
@@ -1,6 +1,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
-using AotTrimmedSample;
+using MyApp;
+//using AotTrimmedSample;
using Vogen;
// to *not* generate the factory, use:
diff --git a/src/Vogen/GenerateCodeForBsonSerializers.cs b/src/Vogen/GenerateCodeForBsonSerializers.cs
index 1968a0e756..4849e76df4 100644
--- a/src/Vogen/GenerateCodeForBsonSerializers.cs
+++ b/src/Vogen/GenerateCodeForBsonSerializers.cs
@@ -21,7 +21,8 @@ internal class GenerateCodeForBsonSerializers
public static void GenerateForApplicableValueObjects(SourceProductionContext context,
Compilation compilation,
List workItems,
- Customizations? customizations)
+ Customizations? customizations,
+ string? rootNamespace)
{
if (!compilation.IsAtLeastCSharp12())
{
@@ -39,7 +40,7 @@ public static void GenerateForApplicableValueObjects(SourceProductionContext con
Util.AddSourceToContext(filename, context, Util.FormatSource(eachGenerated));
}
- WriteRegistration(applicableWrappers, compilation, context, customizations);
+ WriteRegistration(applicableWrappers, compilation, context, customizations, rootNamespace);
}
///
@@ -138,7 +139,8 @@ string GenerateSerializers()
private static void WriteRegistration(List items,
Compilation compilation,
SourceProductionContext context,
- Customizations? customizations)
+ Customizations? customizations,
+ string? rootNamespace)
{
if (items.Count == 0)
{
@@ -154,7 +156,7 @@ private static void WriteRegistration(List items,
string ClassNameForRegistering()
{
- string projectName = ProjectName.FromAssemblyName(compilation.AssemblyName ?? "").Value;
+ string projectName = ProjectName.FromRootNamespaceOrAssemblyName(rootNamespace, compilation.AssemblyName ?? "").Value;
string s = "BsonSerializationRegister";
if(projectName.Length > 0)
diff --git a/src/Vogen/GenerateCodeForOpenApiSchemaCustomization.cs b/src/Vogen/GenerateCodeForOpenApiSchemaCustomization.cs
index 0651958084..3e74d84766 100644
--- a/src/Vogen/GenerateCodeForOpenApiSchemaCustomization.cs
+++ b/src/Vogen/GenerateCodeForOpenApiSchemaCustomization.cs
@@ -16,14 +16,15 @@ public static void WriteIfNeeded(VogenConfiguration? globalConfig,
List workItems,
VogenKnownSymbols knownSymbols,
MarkersCollection markerClasses,
- Compilation compilation)
+ Compilation compilation,
+ string? rootNamespace)
{
GenerateCodeForAspNetCoreOpenApiSchema.WriteOpenApiSpecForMarkers(context, workItems, knownSymbols, markerClasses);
var c = globalConfig?.OpenApiSchemaCustomizations ??
VogenConfiguration.DefaultInstance.OpenApiSchemaCustomizations;
- var projectName = ProjectName.FromAssemblyName(compilation.Assembly.Name);
+ var projectName = ProjectName.FromRootNamespaceOrAssemblyName(rootNamespace, compilation.Assembly.Name);
var className = string.IsNullOrEmpty(projectName) ? string.Empty : $"MapVogenTypesIn{projectName}";
diff --git a/src/Vogen/GenerateCodeForSystemTextJsonConverterFactories.cs b/src/Vogen/GenerateCodeForSystemTextJsonConverterFactories.cs
index b3cbca752d..4c24909a0f 100644
--- a/src/Vogen/GenerateCodeForSystemTextJsonConverterFactories.cs
+++ b/src/Vogen/GenerateCodeForSystemTextJsonConverterFactories.cs
@@ -11,7 +11,8 @@ public static void WriteIfNeeded(VogenConfiguration? globalConfig,
List workItems,
SourceProductionContext context,
Compilation compilation,
- VogenKnownSymbols vogenKnownSymbols)
+ VogenKnownSymbols vogenKnownSymbols,
+ string? rootNamespace)
{
if (vogenKnownSymbols.JsonConverterFactory is null)
{
@@ -29,7 +30,7 @@ public static void WriteIfNeeded(VogenConfiguration? globalConfig,
var entries = workItems.Where(i => i.Config.Conversions.HasFlag(Conversions.SystemTextJson)).Select(BuildEntry);
- var fullNamespace = ProjectName.FromAssemblyName(compilation.Assembly.Name);
+ var fullNamespace = ProjectName.FromRootNamespaceOrAssemblyName(rootNamespace, compilation.Assembly.Name);
string source =
$$"""
diff --git a/src/Vogen/Types/ProjectName.cs b/src/Vogen/Types/ProjectName.cs
index d506309c70..7235f7c183 100644
--- a/src/Vogen/Types/ProjectName.cs
+++ b/src/Vogen/Types/ProjectName.cs
@@ -5,18 +5,31 @@ internal class ProjectName
private ProjectName(string value) => Value = value;
///
- /// Replaces [., -] with [_] for use as type type names etc.
+ /// Returns a from the MSBuild RootNamespace property when it is set,
+ /// otherwise falls back to . Either value is normalised.
///
- ///
- ///
- public static ProjectName FromAssemblyName(string assemblyName)
+ public static ProjectName FromRootNamespaceOrAssemblyName(string? rootNamespace, string assemblyName) =>
+ !string.IsNullOrWhiteSpace(rootNamespace) ? new(Normalise(rootNamespace!)) : FromAssemblyName(assemblyName);
+
+ ///
+ /// Replaces [., ,, space, -] with [_] for use as type names etc., and ensures the result
+ /// does not start with a digit (which would produce an invalid C# identifier).
+ ///
+ public static ProjectName FromAssemblyName(string assemblyName) => new(Normalise(assemblyName));
+
+ private static string Normalise(string value)
{
- assemblyName = assemblyName.Replace(".", "_");
- assemblyName = assemblyName.Replace(",", "_");
- assemblyName = assemblyName.Replace(" ", "_");
- assemblyName = assemblyName.Replace("-", "_");
+ value = value.Replace(".", "_");
+ value = value.Replace(",", "_");
+ value = value.Replace(" ", "_");
+ value = value.Replace("-", "_");
+
+ if (value.Length > 0 && char.IsDigit(value[0]))
+ {
+ value = "_" + value;
+ }
- return new(assemblyName);
+ return value;
}
public string Value { get; }
diff --git a/src/Vogen/ValueObjectGenerator.cs b/src/Vogen/ValueObjectGenerator.cs
index 2117039250..1a3cde4fcb 100644
--- a/src/Vogen/ValueObjectGenerator.cs
+++ b/src/Vogen/ValueObjectGenerator.cs
@@ -32,18 +32,30 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
var compilationAndValues = context.CompilationProvider.Combine(targetsConfigAndMarkers);
var everything = compilationAndValues.Combine(knownSymbols);
+
+ IncrementalValueProvider rootNamespace = context.AnalyzerConfigOptionsProvider
+ .Select(static (options, _) =>
+ {
+ options.GlobalOptions.TryGetValue("build_property.RootNamespace", out var ns);
+ return ns;
+ });
+
+ var everythingWithNs = everything.Combine(rootNamespace);
- context.RegisterSourceOutput(everything,
+ context.RegisterSourceOutput(everythingWithNs,
static (spc, source) =>
{
- var left = source.Left;
+ var everything = source.Left;
+ string? rootNs = source.Right;
+
+ var left = everything.Left;
// todo: break apart building the work items, as that only needs global config,
// which will make the following less horrific!
Compilation compilation = left.Left;
var targets = left.Right.Left.Left;
var globalConfig = left.Right.Left.Right;
- var ks = source.Right;
+ var ks = everything.Right;
ImmutableArray markerClasses = left.Right.Right;
Execute(
@@ -52,7 +64,8 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
targets,
globalConfig,
markerClasses,
- spc);
+ spc,
+ rootNs);
});
}
@@ -88,7 +101,8 @@ private static void Execute(
ImmutableArray targets,
ImmutableArray globalConfigBuildResult,
ImmutableArray markerDiscoveries,
- SourceProductionContext spc)
+ SourceProductionContext spc,
+ string? rootNamespace)
{
var csharpCompilation = compilation as CSharpCompilation;
if (csharpCompilation is null)
@@ -127,7 +141,7 @@ private static void Execute(
// get all the ValueObject types found.
List workItems = GetWorkItems(targets, spc, globalConfig, csharpCompilation.LanguageVersion, vogenKnownSymbols, compilation).ToList();
- GenerateCodeForOpenApiSchemaCustomization.WriteIfNeeded(globalConfig, spc, workItems, vogenKnownSymbols, markerClasses, compilation);
+ GenerateCodeForOpenApiSchemaCustomization.WriteIfNeeded(globalConfig, spc, workItems, vogenKnownSymbols, markerClasses, compilation, rootNamespace);
GenerateCodeForEfCoreMarkers.Generate(spc, compilation, markerClasses);
@@ -136,7 +150,7 @@ private static void Execute(
GenerateCodeForMessagePack.GenerateForApplicableValueObjects(spc, compilation, workItems);
GenerateCodeForMessagePack.GenerateForMarkerClasses(spc, markerClasses);
- GenerateCodeForBsonSerializers.GenerateForApplicableValueObjects(spc, compilation, workItems, globalConfig?.Customizations);
+ GenerateCodeForBsonSerializers.GenerateForApplicableValueObjects(spc, compilation, workItems, globalConfig?.Customizations, rootNamespace);
GenerateCodeForBsonSerializers.GenerateForMarkerClasses(spc, markerClasses);
GenerateCodeForOrleansSerializers.WriteIfNeeded(spc, workItems);
@@ -149,7 +163,7 @@ private static void Execute(
GenerateCodeForStaticAbstracts.WriteInterfacesAndMethodsIfNeeded(mergedConfig, spc, compilation);
- GenerateCodeForSystemTextJsonConverterFactories.WriteIfNeeded(mergedConfig, workItems, spc, compilation, vogenKnownSymbols);
+ GenerateCodeForSystemTextJsonConverterFactories.WriteIfNeeded(mergedConfig, workItems, spc, compilation, vogenKnownSymbols, rootNamespace);
foreach (var eachWorkItem in workItems)
{
diff --git a/tests/Shared/ProjectBuilder.cs b/tests/Shared/ProjectBuilder.cs
index acbbd7a32e..933964dffb 100644
--- a/tests/Shared/ProjectBuilder.cs
+++ b/tests/Shared/ProjectBuilder.cs
@@ -44,6 +44,7 @@ public sealed class ProjectBuilder
private bool _excludeStj;
private LanguageVersion _languageVersion = LanguageVersion.Default;
private string _assemblyName = "generator";
+ private readonly Dictionary _buildProperties = new();
public ProjectBuilder WithTargetFramework(TargetFramework targetFramework)
{
@@ -296,6 +297,13 @@ public ProjectBuilder WithAssemblyName(string assemblyName)
return this;
}
+ public ProjectBuilder WithBuildProperty(string key, string value)
+ {
+ _buildProperties[key] = value;
+
+ return this;
+ }
+
public ProjectBuilder WithNugetPackages(IEnumerable packages)
{
foreach (var nuGetPackage in packages)
@@ -350,7 +358,7 @@ internal static class IsExternalInit {}
_references,
options);
- AnalyzerConfigOptionsProvider optionsProvider = new TestAnalyzerConfigOptionsProvider(new Dictionary());
+ AnalyzerConfigOptionsProvider optionsProvider = new TestAnalyzerConfigOptionsProvider(_buildProperties);
ImmutableArray initialDiags;
@@ -378,7 +386,8 @@ internal static class IsExternalInit {}
var driver = CSharpGeneratorDriver
.Create(generator)
- .WithUpdatedParseOptions(parseOptions.WithDocumentationMode(DocumentationMode.Diagnose));
+ .WithUpdatedParseOptions(parseOptions.WithDocumentationMode(DocumentationMode.Diagnose))
+ .WithUpdatedAnalyzerConfigOptions(optionsProvider);
driver.RunGeneratorsAndUpdateCompilation(compilation, out var outputCompilation, out var generatorDiags);
diff --git a/tests/SnapshotTests/BsonSerializationGeneration/BsonSerializationGenerationTests.cs b/tests/SnapshotTests/BsonSerializationGeneration/BsonSerializationGenerationTests.cs
index 316e24f76b..7b63057f95 100644
--- a/tests/SnapshotTests/BsonSerializationGeneration/BsonSerializationGenerationTests.cs
+++ b/tests/SnapshotTests/BsonSerializationGeneration/BsonSerializationGenerationTests.cs
@@ -13,9 +13,13 @@ public async Task Writes_bson_serializers()
using System;
using Vogen;
- [assembly: VogenDefaults(conversions: Conversions.Bson)]
+ [assembly: VogenDefaults(
+ staticAbstractsGeneration: StaticAbstractsGeneration.MostCommon | StaticAbstractsGeneration.InstanceMethodsAndProperties,
+ conversions: Conversions.Default | Conversions.Bson)]
+
+ // [assembly: VogenDefaults(conversions: Conversions.Bson)]
- namespace Whatever;
+ namespace Vogen.Examples.SerializationAndConversion.Mongo;
[ValueObject]
public partial struct Age;
@@ -25,6 +29,7 @@ public partial struct Name;
await new SnapshotRunner()
.WithSource(source)
+ .WithAssemblyName("Vogen.Examples")
.IgnoreInitialCompilationErrors()
.RunOn(TargetFramework.Net8_0);
}
diff --git a/tests/SnapshotTests/BsonSerializationGeneration/snapshots/snap-v8.0/BsonSerializationGenerationTests.Writes_bson_serializers.verified.txt b/tests/SnapshotTests/BsonSerializationGeneration/snapshots/snap-v8.0/BsonSerializationGenerationTests.Writes_bson_serializers.verified.txt
index f68add9e43..b45d1e1f3d 100644
--- a/tests/SnapshotTests/BsonSerializationGeneration/snapshots/snap-v8.0/BsonSerializationGenerationTests.Writes_bson_serializers.verified.txt
+++ b/tests/SnapshotTests/BsonSerializationGeneration/snapshots/snap-v8.0/BsonSerializationGenerationTests.Writes_bson_serializers.verified.txt
@@ -22,11 +22,11 @@
#pragma warning disable CS1591
// Suppress warnings about CS8767 : Nullability of reference types in type of parameter doesn't match implicitly implemented member (possibly because of nullability attributes).
#pragma warning disable CS8767
-namespace Whatever;
-public partial class AgeBsonSerializer : global::MongoDB.Bson.Serialization.Serializers.SerializerBase
+namespace Vogen.Examples.SerializationAndConversion.Mongo;
+public partial class AgeBsonSerializer : global::MongoDB.Bson.Serialization.Serializers.SerializerBase
{
private readonly global::MongoDB.Bson.Serialization.IBsonSerializer _serializer = global::MongoDB.Bson.Serialization.BsonSerializer.LookupSerializer();
- public override Whatever.Age Deserialize(global::MongoDB.Bson.Serialization.BsonDeserializationContext context, global::MongoDB.Bson.Serialization.BsonDeserializationArgs args)
+ public override Vogen.Examples.SerializationAndConversion.Mongo.Age Deserialize(global::MongoDB.Bson.Serialization.BsonDeserializationContext context, global::MongoDB.Bson.Serialization.BsonDeserializationArgs args)
{
var newArgs = new global::MongoDB.Bson.Serialization.BsonDeserializationArgs
{
@@ -35,10 +35,10 @@ public partial class AgeBsonSerializer : global::MongoDB.Bson.Serialization.Seri
return Deserialize(_serializer.Deserialize(context, newArgs));
}
- public override void Serialize(global::MongoDB.Bson.Serialization.BsonSerializationContext context, global::MongoDB.Bson.Serialization.BsonSerializationArgs args, Whatever.Age value) => _serializer.Serialize(context, args, value.Value);
- static Whatever.Age Deserialize(global::System.Int32 value) => UnsafeDeserialize(default, value);
+ public override void Serialize(global::MongoDB.Bson.Serialization.BsonSerializationContext context, global::MongoDB.Bson.Serialization.BsonSerializationArgs args, Vogen.Examples.SerializationAndConversion.Mongo.Age value) => _serializer.Serialize(context, args, value.Value);
+ static Vogen.Examples.SerializationAndConversion.Mongo.Age Deserialize(global::System.Int32 value) => UnsafeDeserialize(default, value);
[global::System.Runtime.CompilerServices.UnsafeAccessor(global::System.Runtime.CompilerServices.UnsafeAccessorKind.StaticMethod, Name = "__Deserialize")]
- static extern Whatever.Age UnsafeDeserialize(Whatever.Age @this, global::System.Int32 value);
+ static extern Vogen.Examples.SerializationAndConversion.Mongo.Age UnsafeDeserialize(Vogen.Examples.SerializationAndConversion.Mongo.Age @this, global::System.Int32 value);
}
// ------------------------------------------------------------------------------
@@ -64,11 +64,11 @@ public partial class AgeBsonSerializer : global::MongoDB.Bson.Serialization.Seri
#pragma warning disable CS1591
// Suppress warnings about CS8767 : Nullability of reference types in type of parameter doesn't match implicitly implemented member (possibly because of nullability attributes).
#pragma warning disable CS8767
-namespace Whatever;
-public partial class NameBsonSerializer : global::MongoDB.Bson.Serialization.Serializers.SerializerBase
+namespace Vogen.Examples.SerializationAndConversion.Mongo;
+public partial class NameBsonSerializer : global::MongoDB.Bson.Serialization.Serializers.SerializerBase
{
private readonly global::MongoDB.Bson.Serialization.IBsonSerializer _serializer = global::MongoDB.Bson.Serialization.BsonSerializer.LookupSerializer();
- public override Whatever.Name Deserialize(global::MongoDB.Bson.Serialization.BsonDeserializationContext context, global::MongoDB.Bson.Serialization.BsonDeserializationArgs args)
+ public override Vogen.Examples.SerializationAndConversion.Mongo.Name Deserialize(global::MongoDB.Bson.Serialization.BsonDeserializationContext context, global::MongoDB.Bson.Serialization.BsonDeserializationArgs args)
{
var newArgs = new global::MongoDB.Bson.Serialization.BsonDeserializationArgs
{
@@ -77,10 +77,10 @@ public partial class NameBsonSerializer : global::MongoDB.Bson.Serialization.Ser
return Deserialize(_serializer.Deserialize(context, newArgs));
}
- public override void Serialize(global::MongoDB.Bson.Serialization.BsonSerializationContext context, global::MongoDB.Bson.Serialization.BsonSerializationArgs args, Whatever.Name value) => _serializer.Serialize(context, args, value.Value);
- static Whatever.Name Deserialize(global::System.String value) => UnsafeDeserialize(default, value);
+ public override void Serialize(global::MongoDB.Bson.Serialization.BsonSerializationContext context, global::MongoDB.Bson.Serialization.BsonSerializationArgs args, Vogen.Examples.SerializationAndConversion.Mongo.Name value) => _serializer.Serialize(context, args, value.Value);
+ static Vogen.Examples.SerializationAndConversion.Mongo.Name Deserialize(global::System.String value) => UnsafeDeserialize(default, value);
[global::System.Runtime.CompilerServices.UnsafeAccessor(global::System.Runtime.CompilerServices.UnsafeAccessorKind.StaticMethod, Name = "__Deserialize")]
- static extern Whatever.Name UnsafeDeserialize(Whatever.Name @this, global::System.String value);
+ static extern Vogen.Examples.SerializationAndConversion.Mongo.Name UnsafeDeserialize(Vogen.Examples.SerializationAndConversion.Mongo.Name @this, global::System.String value);
}
// ------------------------------------------------------------------------------
@@ -106,12 +106,12 @@ public partial class NameBsonSerializer : global::MongoDB.Bson.Serialization.Ser
#pragma warning disable CS1591
// Suppress warnings about CS8767 : Nullability of reference types in type of parameter doesn't match implicitly implemented member (possibly because of nullability attributes).
#pragma warning disable CS8767
-public static class BsonSerializationRegisterForgenerator
+public static class BsonSerializationRegisterForVogen_Examples
{
- static BsonSerializationRegisterForgenerator()
+ static BsonSerializationRegisterForVogen_Examples()
{
- global::MongoDB.Bson.Serialization.BsonSerializer.TryRegisterSerializer(new Whatever.AgeBsonSerializer());
- global::MongoDB.Bson.Serialization.BsonSerializer.TryRegisterSerializer(new Whatever.NameBsonSerializer());
+ global::MongoDB.Bson.Serialization.BsonSerializer.TryRegisterSerializer(new Vogen.Examples.SerializationAndConversion.Mongo.AgeBsonSerializer());
+ global::MongoDB.Bson.Serialization.BsonSerializer.TryRegisterSerializer(new Vogen.Examples.SerializationAndConversion.Mongo.NameBsonSerializer());
}
public static void TryRegister()
@@ -142,7 +142,48 @@ public static class BsonSerializationRegisterForgenerator
#pragma warning disable CS1591
// Suppress warnings about CS8767 : Nullability of reference types in type of parameter doesn't match implicitly implemented member (possibly because of nullability attributes).
#pragma warning disable CS8767
-namespace generator
+public interface IVogen
+ where TSelf : IVogen
+{
+ static abstract explicit operator TSelf(TPrimitive value);
+ static abstract explicit operator TPrimitive(TSelf value);
+ static abstract bool operator ==(TSelf left, TSelf right);
+ static abstract bool operator !=(TSelf left, TSelf right);
+ static abstract bool operator ==(TSelf left, TPrimitive right);
+ static abstract bool operator !=(TSelf left, TPrimitive right);
+ static abstract bool operator ==(TPrimitive left, TSelf right);
+ static abstract bool operator !=(TPrimitive left, TSelf right);
+ static abstract TSelf From(TPrimitive value);
+ static abstract bool TryFrom(TPrimitive value, out TSelf vo);
+ TPrimitive Value { get; }
+
+ bool IsInitialized();
+}
+
+// ------------------------------------------------------------------------------
+//
+// 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.
+//
+// ------------------------------------------------------------------------------
+// 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 or IComparable should override comparison operators
+#pragma warning disable MA0097
+// Suppress warning for 'The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source.'
+// The generator copies signatures from the BCL, e.g. for `TryParse`, and some of those have nullable annotations.
+#pragma warning disable CS8669, CS8632
+#pragma warning disable CS8604 // Possible null reference argument.
+
+// Suppress warnings about CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member'
+#pragma warning disable CS1591
+// Suppress warnings about CS8767 : Nullability of reference types in type of parameter doesn't match implicitly implemented member (possibly because of nullability attributes).
+#pragma warning disable CS8767
+namespace Vogen_Examples
{
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
@@ -154,6 +195,14 @@ namespace generator
private static readonly global::System.Collections.Generic.Dictionary> _lookup = new global::System.Collections.Generic.Dictionary>
{
+ {
+ typeof(global::Vogen.Examples.SerializationAndConversion.Mongo.Age),
+ new global::System.Lazy(() => new global::Vogen.Examples.SerializationAndConversion.Mongo.Age.AgeSystemTextJsonConverter())
+ },
+ {
+ typeof(global::Vogen.Examples.SerializationAndConversion.Mongo.Name),
+ new global::System.Lazy(() => new global::Vogen.Examples.SerializationAndConversion.Mongo.Name.NameSystemTextJsonConverter())
+ }
};
public override bool CanConvert(global::System.Type typeToConvert) => _lookup.ContainsKey(typeToConvert);
public override global::System.Text.Json.Serialization.JsonConverter CreateConverter(global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options) => _lookup[typeToConvert].Value;
@@ -183,14 +232,16 @@ namespace generator
#pragma warning disable CS1591
// Suppress warnings about CS8767 : Nullability of reference types in type of parameter doesn't match implicitly implemented member (possibly because of nullability attributes).
#pragma warning disable CS8767
-namespace Whatever
+namespace Vogen.Examples.SerializationAndConversion.Mongo
{
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
+ [global::System.Text.Json.Serialization.JsonConverter(typeof(AgeSystemTextJsonConverter))]
+ [global::System.ComponentModel.TypeConverter(typeof(AgeTypeConverter))]
[global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(AgeDebugView))]
[global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: global::System.Int32, Value = { _value }")]
// ReSharper disable once UnusedType.Global
- public partial struct Age : global::System.IEquatable, global::System.IEquatable, global::System.IComparable, global::System.IComparable, global::System.IParsable, global::System.ISpanParsable, global::System.IUtf8SpanParsable, global::System.IFormattable, global::System.ISpanFormattable, global::System.IUtf8SpanFormattable, global::System.IConvertible
+ public partial struct Age : global::System.IEquatable, global::System.IEquatable, global::System.IComparable, global::System.IComparable, global::System.IParsable, global::System.ISpanParsable, global::System.IUtf8SpanParsable, global::System.IFormattable, global::System.ISpanFormattable, global::System.IUtf8SpanFormattable, global::System.IConvertible, IVogen
{
#if DEBUG
private readonly global::System.Diagnostics.StackTrace _stackTrace = null!;
@@ -787,6 +838,100 @@ private readonly global::System.Diagnostics.StackTrace _stackTrace = null!;
}
}
+#nullable disable
+ ///
+ /// Converts a Age to or from JSON.
+ ///
+ public partial class AgeSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter
+ {
+ public override Age Read(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
+ {
+#if NET5_0_OR_GREATER
+ return DeserializeJson(global::System.Text.Json.JsonSerializer.Deserialize(ref reader, (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)options.GetTypeInfo(typeof(global::System.Int32))));
+#else
+ return DeserializeJson(reader.GetInt32());
+#endif
+ }
+
+ public override void Write(global::System.Text.Json.Utf8JsonWriter writer, Age value, global::System.Text.Json.JsonSerializerOptions options)
+ {
+#if NET5_0_OR_GREATER
+ global::System.Text.Json.JsonSerializer.Serialize(writer, value.Value, options);
+#else
+ writer.WriteNumberValue(value.Value);
+#endif
+ }
+
+#if NET6_0_OR_GREATER
+ public override Age ReadAsPropertyName(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
+ {
+ return DeserializeJson(global::System.Int32.Parse(reader.GetString(), global::System.Globalization.NumberStyles.Any, global::System.Globalization.CultureInfo.InvariantCulture));
+ }
+
+ public override void WriteAsPropertyName(global::System.Text.Json.Utf8JsonWriter writer, Age value, global::System.Text.Json.JsonSerializerOptions options)
+ {
+ writer.WritePropertyName(value.Value.ToString(global::System.Globalization.CultureInfo.InvariantCulture));
+ }
+#endif
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ private static void ThrowJsonExceptionWhenValidationFails(global::Vogen.Validation validation)
+ {
+ var e = ThrowHelper.CreateValidationException(validation);
+ throw new global::System.Text.Json.JsonException(null, e);
+ }
+
+ private static Age DeserializeJson(global::System.Int32 value)
+ {
+ return new Age(value);
+ }
+ }
+
+#nullable restore
+#nullable disable
+ class AgeTypeConverter : global::System.ComponentModel.TypeConverter
+ {
+ public override global::System.Boolean CanConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType)
+ {
+ return sourceType == typeof(global::System.Int32) || 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.Int32 intValue => Age.__Deserialize(intValue),
+ global::System.String stringValue when !global::System.String.IsNullOrEmpty(stringValue) && global::System.Int32.TryParse(stringValue, out var result) => Age.__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.Int32) || 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 Age idValue)
+ {
+ if (destinationType == typeof(global::System.Int32))
+ {
+ return idValue.Value;
+ }
+
+ if (destinationType == typeof(global::System.String))
+ {
+ return idValue.Value.ToString();
+ }
+ }
+
+ return base.ConvertTo(context, culture, value, destinationType);
+ }
+ }
+
+#nullable restore
#nullable disable
internal sealed class AgeDebugView
{
@@ -802,7 +947,7 @@ private readonly global::System.Diagnostics.StackTrace _stackTrace = null!;
#if DEBUG
public global::System.String CreatedWith => _t._stackTrace.ToString() ?? "the From method";
#endif
- public global::System.String Conversions => @"Bson";
+ public global::System.String Conversions => @"Default, Bson";
}
#nullable restore
@@ -878,14 +1023,16 @@ private readonly global::System.Diagnostics.StackTrace _stackTrace = null!;
#pragma warning disable CS1591
// Suppress warnings about CS8767 : Nullability of reference types in type of parameter doesn't match implicitly implemented member (possibly because of nullability attributes).
#pragma warning disable CS8767
-namespace Whatever
+namespace Vogen.Examples.SerializationAndConversion.Mongo
{
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
+ [global::System.Text.Json.Serialization.JsonConverter(typeof(NameSystemTextJsonConverter))]
+ [global::System.ComponentModel.TypeConverter(typeof(NameTypeConverter))]
[global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(NameDebugView))]
[global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: global::System.String, Value = { _value }")]
// ReSharper disable once UnusedType.Global
- public partial struct Name : global::System.IEquatable, global::System.IEquatable, global::System.IComparable, global::System.IComparable, global::System.IParsable, global::System.IConvertible
+ public partial struct Name : global::System.IEquatable, global::System.IEquatable, global::System.IComparable, global::System.IComparable, global::System.IParsable, global::System.IConvertible, IVogen
{
#if DEBUG
private readonly global::System.Diagnostics.StackTrace _stackTrace = null!;
@@ -1222,6 +1369,98 @@ private readonly global::System.Diagnostics.StackTrace _stackTrace = null!;
}
}
+#nullable disable
+ ///
+ /// Converts a Name to or from JSON.
+ ///
+ public partial class NameSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter
+ {
+ public override Name Read(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
+ {
+ return DeserializeJson(reader.GetString());
+ }
+
+ public override void Write(global::System.Text.Json.Utf8JsonWriter writer, Name value, global::System.Text.Json.JsonSerializerOptions options)
+ {
+ writer.WriteStringValue(value.Value);
+ }
+
+#if NET6_0_OR_GREATER
+ public override Name ReadAsPropertyName(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
+ {
+ return DeserializeJson(reader.GetString());
+ }
+
+ public override void WriteAsPropertyName(global::System.Text.Json.Utf8JsonWriter writer, Name value, global::System.Text.Json.JsonSerializerOptions options)
+ {
+ writer.WritePropertyName(value.Value);
+ }
+#endif
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ private static void ThrowJsonExceptionWhenValidationFails(global::Vogen.Validation validation)
+ {
+ var e = ThrowHelper.CreateValidationException(validation);
+ throw new global::System.Text.Json.JsonException(null, e);
+ }
+
+ private static void ThrowJsonExceptionWhenNull(global::System.String value)
+ {
+ if (value == null)
+ {
+ var e = ThrowHelper.CreateCannotBeNullException();
+ throw new global::System.Text.Json.JsonException(null, e);
+ }
+ }
+
+ private static Name DeserializeJson(global::System.String value)
+ {
+ ThrowJsonExceptionWhenNull(value);
+ return new Name(value);
+ }
+ }
+
+#nullable restore
+#nullable disable
+ class NameTypeConverter : global::System.ComponentModel.TypeConverter
+ {
+ public override global::System.Boolean CanConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType)
+ {
+ return 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)
+ {
+ var stringValue = value as global::System.String;
+ if (stringValue != null)
+ {
+ return Name.__Deserialize(stringValue);
+ }
+
+ return base.ConvertFrom(context, culture, value);
+ }
+
+ public override bool CanConvertTo(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType)
+ {
+ return 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 Name idValue)
+ {
+ if (destinationType == typeof(global::System.String))
+ {
+ return idValue.Value;
+ }
+ }
+
+ return base.ConvertTo(context, culture, value, destinationType);
+ }
+ }
+
+#nullable restore
#nullable disable
internal sealed class NameDebugView
{
@@ -1237,7 +1476,7 @@ private readonly global::System.Diagnostics.StackTrace _stackTrace = null!;
#if DEBUG
public global::System.String CreatedWith => _t._stackTrace.ToString() ?? "the From method";
#endif
- public global::System.String Conversions => @"Bson";
+ public global::System.String Conversions => @"Default, Bson";
}
#nullable restore
diff --git a/tests/SnapshotTests/BugFixes/Bug918_AssemblyNameStartingWithDigit.cs b/tests/SnapshotTests/BugFixes/Bug918_AssemblyNameStartingWithDigit.cs
new file mode 100644
index 0000000000..c19b870e13
--- /dev/null
+++ b/tests/SnapshotTests/BugFixes/Bug918_AssemblyNameStartingWithDigit.cs
@@ -0,0 +1,40 @@
+using System.Threading.Tasks;
+using Vogen;
+
+namespace SnapshotTests.BugFixes;
+
+// See https://github.com/SteveDunn/Vogen/issues/918
+public class Bug918_AssemblyNameStartingWithDigit
+{
+ private const string Source = """
+ using System;
+ using Vogen;
+ using System.Text.Json;
+
+ namespace MyNamespace;
+
+ [ValueObject(typeof(int), conversions: Conversions.SystemTextJson)]
+ public partial struct MyVo;
+ """;
+
+ [Fact]
+ public async Task Assembly_name_starting_with_digit_is_sanitised()
+ {
+ await new SnapshotRunner()
+ .WithAssemblyName("1MyProject")
+ .WithSource(Source)
+ .IgnoreInitialCompilationErrors()
+ .RunOnAllFrameworks();
+ }
+
+ [Fact]
+ public async Task RootNamespace_overrides_assembly_name()
+ {
+ await new SnapshotRunner()
+ .WithAssemblyName("1MyProject")
+ .WithBuildProperty("build_property.RootNamespace", "OneProject")
+ .WithSource(Source)
+ .IgnoreInitialCompilationErrors()
+ .RunOnAllFrameworks();
+ }
+}
diff --git a/tests/SnapshotTests/BugFixes/snapshots/snap-v4.8/Bug918_AssemblyNameStartingWithDigit.Assembly_name_starting_with_digit_is_sanitised.verified.txt b/tests/SnapshotTests/BugFixes/snapshots/snap-v4.8/Bug918_AssemblyNameStartingWithDigit.Assembly_name_starting_with_digit_is_sanitised.verified.txt
new file mode 100644
index 0000000000..27410907b0
--- /dev/null
+++ b/tests/SnapshotTests/BugFixes/snapshots/snap-v4.8/Bug918_AssemblyNameStartingWithDigit.Assembly_name_starting_with_digit_is_sanitised.verified.txt
@@ -0,0 +1,574 @@
+[
+// ------------------------------------------------------------------------------
+//
+// 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.
+//
+// ------------------------------------------------------------------------------
+// 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 or IComparable should override comparison operators
+#pragma warning disable MA0097
+// Suppress warning for 'The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source.'
+// The generator copies signatures from the BCL, e.g. for `TryParse`, and some of those have nullable annotations.
+#pragma warning disable CS8669, CS8632
+#pragma warning disable CS8604 // Possible null reference argument.
+
+// Suppress warnings about CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member'
+#pragma warning disable CS1591
+// Suppress warnings about CS8767 : Nullability of reference types in type of parameter doesn't match implicitly implemented member (possibly because of nullability attributes).
+#pragma warning disable CS8767
+namespace _1MyProject
+{
+ [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
+ public class VogenTypesFactory : global::System.Text.Json.Serialization.JsonConverterFactory
+ {
+ public VogenTypesFactory()
+ {
+ }
+
+ private static readonly global::System.Collections.Generic.Dictionary> _lookup = new global::System.Collections.Generic.Dictionary>
+ {
+ {
+ typeof(global::MyNamespace.MyVo),
+ new global::System.Lazy(() => new global::MyNamespace.MyVo.MyVoSystemTextJsonConverter())
+ }
+ };
+ public override bool CanConvert(global::System.Type typeToConvert) => _lookup.ContainsKey(typeToConvert);
+ public override global::System.Text.Json.Serialization.JsonConverter CreateConverter(global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options) => _lookup[typeToConvert].Value;
+ }
+}
+
+// ------------------------------------------------------------------------------
+//
+// 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.
+//
+// ------------------------------------------------------------------------------
+// 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 or IComparable should override comparison operators
+#pragma warning disable MA0097
+// Suppress warning for 'The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source.'
+// The generator copies signatures from the BCL, e.g. for `TryParse`, and some of those have nullable annotations.
+#pragma warning disable CS8669, CS8632
+#pragma warning disable CS8604 // Possible null reference argument.
+
+// Suppress warnings about CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member'
+#pragma warning disable CS1591
+// Suppress warnings about CS8767 : Nullability of reference types in type of parameter doesn't match implicitly implemented member (possibly because of nullability attributes).
+#pragma warning disable CS8767
+namespace MyNamespace
+{
+ [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.Diagnostics.DebuggerTypeProxyAttribute(typeof(MyVoDebugView))]
+ [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: global::System.Int32, Value = { _value }")]
+ // ReSharper disable once UnusedType.Global
+ public partial struct MyVo : global::System.IEquatable, global::System.IEquatable, global::System.IComparable, global::System.IComparable, global::System.IFormattable, global::System.IConvertible
+ {
+#if DEBUG
+private readonly global::System.Diagnostics.StackTrace _stackTrace = null!;
+#endif
+#if !VOGEN_NO_VALIDATION
+ private readonly global::System.Boolean _isInitialized;
+#endif
+ private readonly global::System.Int32 _value;
+ ///
+ /// Gets the underlying value if set, otherwise a is thrown.
+ ///
+ public readonly global::System.Int32 Value
+ {
+ [global::System.Diagnostics.DebuggerStepThroughAttribute]
+ [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+ 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
+#if !VOGEN_NO_VALIDATION
+ _isInitialized = false;
+#endif
+ _value = default;
+ }
+
+ [global::System.Diagnostics.DebuggerStepThroughAttribute]
+ private MyVo(global::System.Int32 value)
+ {
+ _value = value;
+#if !VOGEN_NO_VALIDATION
+ _isInitialized = true;
+#endif
+#if DEBUG
+ _stackTrace = null;
+#endif
+ }
+
+ ///
+ /// Builds an instance from the provided underlying type.
+ ///
+ /// The underlying type.
+ /// An instance of this type.
+ [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+ public static MyVo From(global::System.Int32 value)
+ {
+ return new MyVo(value);
+ }
+
+ ///
+ /// Tries to build an instance from the provided underlying type.
+ /// If a normalization method is provided, it will be called.
+ /// If validation is provided, and it fails, false will be returned.
+ ///
+ /// The underlying type.
+ /// An instance of the value object.
+ /// True if the value object can be built, otherwise false.
+ public static bool TryFrom(
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ global::System.Int32 value,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)]
+#endif
+ out MyVo vo)
+ {
+ vo = new MyVo(value);
+ return true;
+ }
+
+ ///
+ /// Tries to build an instance from the provided underlying value.
+ /// If a normalization method is provided, it will be called.
+ /// If validation is provided, and it fails, an error will be returned.
+ ///
+ /// The primitive value.
+ /// A containing either the value object, or an error.
+ public static global::Vogen.ValueObjectOrError TryFrom(global::System.Int32 value)
+ {
+ return new global::Vogen.ValueObjectOrError(new MyVo(value));
+ }
+
+ [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+#if VOGEN_NO_VALIDATION
+#pragma warning disable CS8775
+ public readonly bool IsInitialized() => true;
+#pragma warning restore CS8775
+#else
+ public readonly bool IsInitialized() => _isInitialized;
+#endif
+ public static explicit operator MyVo(global::System.Int32 value) => From(value);
+ public static explicit operator global::System.Int32(MyVo value) => value.Value;
+ // only called internally when something has been deserialized into
+ // its primitive type.
+ private static MyVo __Deserialize(global::System.Int32 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.Default.Equals(Value, other.Value);
+ }
+
+ public global::System.Boolean Equals(MyVo other, global::System.Collections.Generic.IEqualityComparer comparer)
+ {
+ return comparer.Equals(this, other);
+ }
+
+ public readonly global::System.Boolean Equals(global::System.Int32 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) => left.Equals(right);
+ public static global::System.Boolean operator !=(MyVo left, MyVo right) => !(left == right);
+ public static global::System.Boolean operator ==(MyVo left, global::System.Int32 right) => left.Value.Equals(right);
+ public static global::System.Boolean operator ==(global::System.Int32 left, MyVo right) => right.Value.Equals(left);
+ public static global::System.Boolean operator !=(global::System.Int32 left, MyVo right) => !(left == right);
+ public static global::System.Boolean operator !=(MyVo left, global::System.Int32 right) => !(left == right);
+ 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);
+ ThrowHelper.ThrowArgumentException("Cannot compare to object as it is not of type MyVo", nameof(other));
+ return 0;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(string s,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(s, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(string s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(s, style, provider, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(string s)
+ {
+ var r = global::System.Int32.Parse(s);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(string s, global::System.Globalization.NumberStyles style)
+ {
+ var r = global::System.Int32.Parse(s, style);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(string s, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Int32.Parse(s, provider);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(string s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Int32.Parse(s, style, provider);
+ return From(r);
+ }
+
+#nullable disable
+ ///
+ [System.Security.SecuritySafeCriticalAttribute]
+ public string ToString(string format, global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? Value.ToString(format, provider) : "[UNINITIALIZED]";
+ }
+
+#nullable restore
+#nullable disable
+ ///
+ public System.TypeCode GetTypeCode()
+ {
+ return IsInitialized() ? Value.GetTypeCode() : default;
+ }
+
+ ///
+ bool System.IConvertible.ToBoolean(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToBoolean(provider) : default;
+ }
+
+ ///
+ char System.IConvertible.ToChar(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToChar(provider) : default;
+ }
+
+ ///
+ sbyte System.IConvertible.ToSByte(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToSByte(provider) : default;
+ }
+
+ ///
+ byte System.IConvertible.ToByte(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToByte(provider) : default;
+ }
+
+ ///
+ short System.IConvertible.ToInt16(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToInt16(provider) : default;
+ }
+
+ ///
+ ushort System.IConvertible.ToUInt16(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToUInt16(provider) : default;
+ }
+
+ ///
+ int System.IConvertible.ToInt32(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToInt32(provider) : default;
+ }
+
+ ///
+ uint System.IConvertible.ToUInt32(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToUInt32(provider) : default;
+ }
+
+ ///
+ long System.IConvertible.ToInt64(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToInt64(provider) : default;
+ }
+
+ ///
+ ulong System.IConvertible.ToUInt64(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToUInt64(provider) : default;
+ }
+
+ ///
+ float System.IConvertible.ToSingle(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToSingle(provider) : default;
+ }
+
+ ///
+ double System.IConvertible.ToDouble(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToDouble(provider) : default;
+ }
+
+ ///
+ decimal System.IConvertible.ToDecimal(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToDecimal(provider) : default;
+ }
+
+ ///
+ System.DateTime System.IConvertible.ToDateTime(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToDateTime(provider) : default;
+ }
+
+ ///
+ object System.IConvertible.ToType(global::System.Type @type, global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToType(@type, provider) : default;
+ }
+
+#nullable restore
+ public readonly override global::System.Int32 GetHashCode()
+ {
+ return global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value);
+ }
+
+ ///
+ public override global::System.String ToString() => IsInitialized() ? Value.ToString() ?? "" : "[UNINITIALIZED]";
+ ///
+ public global::System.String ToString(string format) => IsInitialized() ? Value.ToString(format) ?? "" : "[UNINITIALIZED]";
+ ///
+ public global::System.String ToString(global::System.IFormatProvider provider) => IsInitialized() ? Value.ToString(provider) ?? "" : "[UNINITIALIZED]";
+ [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+ private readonly void EnsureInitialized()
+ {
+ if (!IsInitialized())
+ {
+#if DEBUG
+ ThrowHelper.ThrowWhenNotInitialized(_stackTrace);
+#else
+ ThrowHelper.ThrowWhenNotInitialized();
+#endif
+ }
+ }
+
+#nullable disable
+ ///
+ /// Converts a MyVo to or from JSON.
+ ///
+ public partial class MyVoSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter
+ {
+ public override MyVo Read(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
+ {
+#if NET5_0_OR_GREATER
+ return DeserializeJson(global::System.Text.Json.JsonSerializer.Deserialize(ref reader, (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)options.GetTypeInfo(typeof(global::System.Int32))));
+#else
+ return DeserializeJson(reader.GetInt32());
+#endif
+ }
+
+ public override void Write(global::System.Text.Json.Utf8JsonWriter writer, MyVo value, global::System.Text.Json.JsonSerializerOptions options)
+ {
+#if NET5_0_OR_GREATER
+ global::System.Text.Json.JsonSerializer.Serialize(writer, value.Value, options);
+#else
+ writer.WriteNumberValue(value.Value);
+#endif
+ }
+
+#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 DeserializeJson(global::System.Int32.Parse(reader.GetString(), global::System.Globalization.NumberStyles.Any, global::System.Globalization.CultureInfo.InvariantCulture));
+ }
+
+ public override void WriteAsPropertyName(global::System.Text.Json.Utf8JsonWriter writer, MyVo value, global::System.Text.Json.JsonSerializerOptions options)
+ {
+ writer.WritePropertyName(value.Value.ToString(global::System.Globalization.CultureInfo.InvariantCulture));
+ }
+#endif
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ private static void ThrowJsonExceptionWhenValidationFails(global::Vogen.Validation validation)
+ {
+ var e = ThrowHelper.CreateValidationException(validation);
+ throw new global::System.Text.Json.JsonException(null, e);
+ }
+
+ private static MyVo DeserializeJson(global::System.Int32 value)
+ {
+ return new MyVo(value);
+ }
+ }
+
+#nullable restore
+#nullable disable
+ 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.Int32";
+ 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 => @"SystemTextJson";
+ }
+
+#nullable restore
+ static class ThrowHelper
+ {
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ internal static void ThrowInvalidOperationException(string message) => throw new global::System.InvalidOperationException(message);
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ internal static void ThrowArgumentException(string message, string arg) => throw new global::System.ArgumentException(message, arg);
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ internal static void ThrowWhenCreatedWithNull() => throw CreateCannotBeNullException();
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ internal static void ThrowWhenNotInitialized() => throw CreateValidationException("Use of uninitialized Value Object.");
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ internal static void ThrowWhenNotInitialized(global::System.Diagnostics.StackTrace stackTrace) => throw CreateValidationException("Use of uninitialized Value Object at: " + stackTrace ?? "");
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ internal static void ThrowWhenValidationFails(global::Vogen.Validation validation)
+ {
+ throw CreateValidationException(validation);
+ }
+
+ internal static global::System.Exception CreateValidationException(string message) => new global::Vogen.ValueObjectValidationException(message);
+ internal static global::System.Exception CreateCannotBeNullException() => new global::Vogen.ValueObjectValidationException("Cannot create a value object with null.");
+ internal static global::System.Exception CreateValidationException(global::Vogen.Validation validation)
+ {
+ var ex = CreateValidationException(validation.ErrorMessage);
+ if (validation.Data != null)
+ {
+ foreach (var kvp in validation.Data)
+ {
+ ex.Data[kvp.Key] = kvp.Value;
+ }
+ }
+
+ return ex;
+ }
+ }
+ }
+}
+]
\ No newline at end of file
diff --git a/tests/SnapshotTests/BugFixes/snapshots/snap-v4.8/Bug918_AssemblyNameStartingWithDigit.RootNamespace_overrides_assembly_name.verified.txt b/tests/SnapshotTests/BugFixes/snapshots/snap-v4.8/Bug918_AssemblyNameStartingWithDigit.RootNamespace_overrides_assembly_name.verified.txt
new file mode 100644
index 0000000000..b779eb5c86
--- /dev/null
+++ b/tests/SnapshotTests/BugFixes/snapshots/snap-v4.8/Bug918_AssemblyNameStartingWithDigit.RootNamespace_overrides_assembly_name.verified.txt
@@ -0,0 +1,574 @@
+[
+// ------------------------------------------------------------------------------
+//
+// 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.
+//
+// ------------------------------------------------------------------------------
+// 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 or IComparable should override comparison operators
+#pragma warning disable MA0097
+// Suppress warning for 'The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source.'
+// The generator copies signatures from the BCL, e.g. for `TryParse`, and some of those have nullable annotations.
+#pragma warning disable CS8669, CS8632
+#pragma warning disable CS8604 // Possible null reference argument.
+
+// Suppress warnings about CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member'
+#pragma warning disable CS1591
+// Suppress warnings about CS8767 : Nullability of reference types in type of parameter doesn't match implicitly implemented member (possibly because of nullability attributes).
+#pragma warning disable CS8767
+namespace OneProject
+{
+ [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
+ public class VogenTypesFactory : global::System.Text.Json.Serialization.JsonConverterFactory
+ {
+ public VogenTypesFactory()
+ {
+ }
+
+ private static readonly global::System.Collections.Generic.Dictionary> _lookup = new global::System.Collections.Generic.Dictionary>
+ {
+ {
+ typeof(global::MyNamespace.MyVo),
+ new global::System.Lazy(() => new global::MyNamespace.MyVo.MyVoSystemTextJsonConverter())
+ }
+ };
+ public override bool CanConvert(global::System.Type typeToConvert) => _lookup.ContainsKey(typeToConvert);
+ public override global::System.Text.Json.Serialization.JsonConverter CreateConverter(global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options) => _lookup[typeToConvert].Value;
+ }
+}
+
+// ------------------------------------------------------------------------------
+//
+// 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.
+//
+// ------------------------------------------------------------------------------
+// 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 or IComparable should override comparison operators
+#pragma warning disable MA0097
+// Suppress warning for 'The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source.'
+// The generator copies signatures from the BCL, e.g. for `TryParse`, and some of those have nullable annotations.
+#pragma warning disable CS8669, CS8632
+#pragma warning disable CS8604 // Possible null reference argument.
+
+// Suppress warnings about CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member'
+#pragma warning disable CS1591
+// Suppress warnings about CS8767 : Nullability of reference types in type of parameter doesn't match implicitly implemented member (possibly because of nullability attributes).
+#pragma warning disable CS8767
+namespace MyNamespace
+{
+ [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.Diagnostics.DebuggerTypeProxyAttribute(typeof(MyVoDebugView))]
+ [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: global::System.Int32, Value = { _value }")]
+ // ReSharper disable once UnusedType.Global
+ public partial struct MyVo : global::System.IEquatable, global::System.IEquatable, global::System.IComparable, global::System.IComparable, global::System.IFormattable, global::System.IConvertible
+ {
+#if DEBUG
+private readonly global::System.Diagnostics.StackTrace _stackTrace = null!;
+#endif
+#if !VOGEN_NO_VALIDATION
+ private readonly global::System.Boolean _isInitialized;
+#endif
+ private readonly global::System.Int32 _value;
+ ///
+ /// Gets the underlying value if set, otherwise a is thrown.
+ ///
+ public readonly global::System.Int32 Value
+ {
+ [global::System.Diagnostics.DebuggerStepThroughAttribute]
+ [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+ 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
+#if !VOGEN_NO_VALIDATION
+ _isInitialized = false;
+#endif
+ _value = default;
+ }
+
+ [global::System.Diagnostics.DebuggerStepThroughAttribute]
+ private MyVo(global::System.Int32 value)
+ {
+ _value = value;
+#if !VOGEN_NO_VALIDATION
+ _isInitialized = true;
+#endif
+#if DEBUG
+ _stackTrace = null;
+#endif
+ }
+
+ ///
+ /// Builds an instance from the provided underlying type.
+ ///
+ /// The underlying type.
+ /// An instance of this type.
+ [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+ public static MyVo From(global::System.Int32 value)
+ {
+ return new MyVo(value);
+ }
+
+ ///
+ /// Tries to build an instance from the provided underlying type.
+ /// If a normalization method is provided, it will be called.
+ /// If validation is provided, and it fails, false will be returned.
+ ///
+ /// The underlying type.
+ /// An instance of the value object.
+ /// True if the value object can be built, otherwise false.
+ public static bool TryFrom(
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ global::System.Int32 value,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)]
+#endif
+ out MyVo vo)
+ {
+ vo = new MyVo(value);
+ return true;
+ }
+
+ ///
+ /// Tries to build an instance from the provided underlying value.
+ /// If a normalization method is provided, it will be called.
+ /// If validation is provided, and it fails, an error will be returned.
+ ///
+ /// The primitive value.
+ /// A containing either the value object, or an error.
+ public static global::Vogen.ValueObjectOrError TryFrom(global::System.Int32 value)
+ {
+ return new global::Vogen.ValueObjectOrError(new MyVo(value));
+ }
+
+ [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+#if VOGEN_NO_VALIDATION
+#pragma warning disable CS8775
+ public readonly bool IsInitialized() => true;
+#pragma warning restore CS8775
+#else
+ public readonly bool IsInitialized() => _isInitialized;
+#endif
+ public static explicit operator MyVo(global::System.Int32 value) => From(value);
+ public static explicit operator global::System.Int32(MyVo value) => value.Value;
+ // only called internally when something has been deserialized into
+ // its primitive type.
+ private static MyVo __Deserialize(global::System.Int32 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.Default.Equals(Value, other.Value);
+ }
+
+ public global::System.Boolean Equals(MyVo other, global::System.Collections.Generic.IEqualityComparer comparer)
+ {
+ return comparer.Equals(this, other);
+ }
+
+ public readonly global::System.Boolean Equals(global::System.Int32 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) => left.Equals(right);
+ public static global::System.Boolean operator !=(MyVo left, MyVo right) => !(left == right);
+ public static global::System.Boolean operator ==(MyVo left, global::System.Int32 right) => left.Value.Equals(right);
+ public static global::System.Boolean operator ==(global::System.Int32 left, MyVo right) => right.Value.Equals(left);
+ public static global::System.Boolean operator !=(global::System.Int32 left, MyVo right) => !(left == right);
+ public static global::System.Boolean operator !=(MyVo left, global::System.Int32 right) => !(left == right);
+ 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);
+ ThrowHelper.ThrowArgumentException("Cannot compare to object as it is not of type MyVo", nameof(other));
+ return 0;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(string s,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(s, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(string s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(s, style, provider, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(string s)
+ {
+ var r = global::System.Int32.Parse(s);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(string s, global::System.Globalization.NumberStyles style)
+ {
+ var r = global::System.Int32.Parse(s, style);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(string s, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Int32.Parse(s, provider);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(string s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Int32.Parse(s, style, provider);
+ return From(r);
+ }
+
+#nullable disable
+ ///
+ [System.Security.SecuritySafeCriticalAttribute]
+ public string ToString(string format, global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? Value.ToString(format, provider) : "[UNINITIALIZED]";
+ }
+
+#nullable restore
+#nullable disable
+ ///
+ public System.TypeCode GetTypeCode()
+ {
+ return IsInitialized() ? Value.GetTypeCode() : default;
+ }
+
+ ///
+ bool System.IConvertible.ToBoolean(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToBoolean(provider) : default;
+ }
+
+ ///
+ char System.IConvertible.ToChar(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToChar(provider) : default;
+ }
+
+ ///
+ sbyte System.IConvertible.ToSByte(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToSByte(provider) : default;
+ }
+
+ ///
+ byte System.IConvertible.ToByte(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToByte(provider) : default;
+ }
+
+ ///
+ short System.IConvertible.ToInt16(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToInt16(provider) : default;
+ }
+
+ ///
+ ushort System.IConvertible.ToUInt16(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToUInt16(provider) : default;
+ }
+
+ ///
+ int System.IConvertible.ToInt32(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToInt32(provider) : default;
+ }
+
+ ///
+ uint System.IConvertible.ToUInt32(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToUInt32(provider) : default;
+ }
+
+ ///
+ long System.IConvertible.ToInt64(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToInt64(provider) : default;
+ }
+
+ ///
+ ulong System.IConvertible.ToUInt64(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToUInt64(provider) : default;
+ }
+
+ ///
+ float System.IConvertible.ToSingle(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToSingle(provider) : default;
+ }
+
+ ///
+ double System.IConvertible.ToDouble(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToDouble(provider) : default;
+ }
+
+ ///
+ decimal System.IConvertible.ToDecimal(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToDecimal(provider) : default;
+ }
+
+ ///
+ System.DateTime System.IConvertible.ToDateTime(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToDateTime(provider) : default;
+ }
+
+ ///
+ object System.IConvertible.ToType(global::System.Type @type, global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToType(@type, provider) : default;
+ }
+
+#nullable restore
+ public readonly override global::System.Int32 GetHashCode()
+ {
+ return global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value);
+ }
+
+ ///
+ public override global::System.String ToString() => IsInitialized() ? Value.ToString() ?? "" : "[UNINITIALIZED]";
+ ///
+ public global::System.String ToString(string format) => IsInitialized() ? Value.ToString(format) ?? "" : "[UNINITIALIZED]";
+ ///
+ public global::System.String ToString(global::System.IFormatProvider provider) => IsInitialized() ? Value.ToString(provider) ?? "" : "[UNINITIALIZED]";
+ [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+ private readonly void EnsureInitialized()
+ {
+ if (!IsInitialized())
+ {
+#if DEBUG
+ ThrowHelper.ThrowWhenNotInitialized(_stackTrace);
+#else
+ ThrowHelper.ThrowWhenNotInitialized();
+#endif
+ }
+ }
+
+#nullable disable
+ ///
+ /// Converts a MyVo to or from JSON.
+ ///
+ public partial class MyVoSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter
+ {
+ public override MyVo Read(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
+ {
+#if NET5_0_OR_GREATER
+ return DeserializeJson(global::System.Text.Json.JsonSerializer.Deserialize(ref reader, (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)options.GetTypeInfo(typeof(global::System.Int32))));
+#else
+ return DeserializeJson(reader.GetInt32());
+#endif
+ }
+
+ public override void Write(global::System.Text.Json.Utf8JsonWriter writer, MyVo value, global::System.Text.Json.JsonSerializerOptions options)
+ {
+#if NET5_0_OR_GREATER
+ global::System.Text.Json.JsonSerializer.Serialize(writer, value.Value, options);
+#else
+ writer.WriteNumberValue(value.Value);
+#endif
+ }
+
+#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 DeserializeJson(global::System.Int32.Parse(reader.GetString(), global::System.Globalization.NumberStyles.Any, global::System.Globalization.CultureInfo.InvariantCulture));
+ }
+
+ public override void WriteAsPropertyName(global::System.Text.Json.Utf8JsonWriter writer, MyVo value, global::System.Text.Json.JsonSerializerOptions options)
+ {
+ writer.WritePropertyName(value.Value.ToString(global::System.Globalization.CultureInfo.InvariantCulture));
+ }
+#endif
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ private static void ThrowJsonExceptionWhenValidationFails(global::Vogen.Validation validation)
+ {
+ var e = ThrowHelper.CreateValidationException(validation);
+ throw new global::System.Text.Json.JsonException(null, e);
+ }
+
+ private static MyVo DeserializeJson(global::System.Int32 value)
+ {
+ return new MyVo(value);
+ }
+ }
+
+#nullable restore
+#nullable disable
+ 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.Int32";
+ 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 => @"SystemTextJson";
+ }
+
+#nullable restore
+ static class ThrowHelper
+ {
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ internal static void ThrowInvalidOperationException(string message) => throw new global::System.InvalidOperationException(message);
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ internal static void ThrowArgumentException(string message, string arg) => throw new global::System.ArgumentException(message, arg);
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ internal static void ThrowWhenCreatedWithNull() => throw CreateCannotBeNullException();
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ internal static void ThrowWhenNotInitialized() => throw CreateValidationException("Use of uninitialized Value Object.");
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ internal static void ThrowWhenNotInitialized(global::System.Diagnostics.StackTrace stackTrace) => throw CreateValidationException("Use of uninitialized Value Object at: " + stackTrace ?? "");
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ internal static void ThrowWhenValidationFails(global::Vogen.Validation validation)
+ {
+ throw CreateValidationException(validation);
+ }
+
+ internal static global::System.Exception CreateValidationException(string message) => new global::Vogen.ValueObjectValidationException(message);
+ internal static global::System.Exception CreateCannotBeNullException() => new global::Vogen.ValueObjectValidationException("Cannot create a value object with null.");
+ internal static global::System.Exception CreateValidationException(global::Vogen.Validation validation)
+ {
+ var ex = CreateValidationException(validation.ErrorMessage);
+ if (validation.Data != null)
+ {
+ foreach (var kvp in validation.Data)
+ {
+ ex.Data[kvp.Key] = kvp.Value;
+ }
+ }
+
+ return ex;
+ }
+ }
+ }
+}
+]
\ No newline at end of file
diff --git a/tests/SnapshotTests/BugFixes/snapshots/snap-v8.0/Bug625_EFCoreConverters_uses_wrong_marker_interface_name.A_marker_interface_not_named_EfCoreConverters_is_still_referenced_and_that_name_is_used_in_the_generated_code.verified.txt b/tests/SnapshotTests/BugFixes/snapshots/snap-v8.0/Bug625_EFCoreConverters_uses_wrong_marker_interface_name.Handles_custom_marker_interface_name_in_generated_code.verified.txt
similarity index 100%
rename from tests/SnapshotTests/BugFixes/snapshots/snap-v8.0/Bug625_EFCoreConverters_uses_wrong_marker_interface_name.A_marker_interface_not_named_EfCoreConverters_is_still_referenced_and_that_name_is_used_in_the_generated_code.verified.txt
rename to tests/SnapshotTests/BugFixes/snapshots/snap-v8.0/Bug625_EFCoreConverters_uses_wrong_marker_interface_name.Handles_custom_marker_interface_name_in_generated_code.verified.txt
diff --git a/tests/SnapshotTests/BugFixes/snapshots/snap-v8.0/Bug918_AssemblyNameStartingWithDigit.Assembly_name_starting_with_digit_is_sanitised.verified.txt b/tests/SnapshotTests/BugFixes/snapshots/snap-v8.0/Bug918_AssemblyNameStartingWithDigit.Assembly_name_starting_with_digit_is_sanitised.verified.txt
new file mode 100644
index 0000000000..9a6d32ec18
--- /dev/null
+++ b/tests/SnapshotTests/BugFixes/snapshots/snap-v8.0/Bug918_AssemblyNameStartingWithDigit.Assembly_name_starting_with_digit_is_sanitised.verified.txt
@@ -0,0 +1,793 @@
+[
+// ------------------------------------------------------------------------------
+//
+// 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.
+//
+// ------------------------------------------------------------------------------
+// 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 or IComparable should override comparison operators
+#pragma warning disable MA0097
+// Suppress warning for 'The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source.'
+// The generator copies signatures from the BCL, e.g. for `TryParse`, and some of those have nullable annotations.
+#pragma warning disable CS8669, CS8632
+#pragma warning disable CS8604 // Possible null reference argument.
+
+// Suppress warnings about CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member'
+#pragma warning disable CS1591
+// Suppress warnings about CS8767 : Nullability of reference types in type of parameter doesn't match implicitly implemented member (possibly because of nullability attributes).
+#pragma warning disable CS8767
+namespace _1MyProject
+{
+ [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
+ public class VogenTypesFactory : global::System.Text.Json.Serialization.JsonConverterFactory
+ {
+ public VogenTypesFactory()
+ {
+ }
+
+ private static readonly global::System.Collections.Generic.Dictionary> _lookup = new global::System.Collections.Generic.Dictionary>
+ {
+ {
+ typeof(global::MyNamespace.MyVo),
+ new global::System.Lazy(() => new global::MyNamespace.MyVo.MyVoSystemTextJsonConverter())
+ }
+ };
+ public override bool CanConvert(global::System.Type typeToConvert) => _lookup.ContainsKey(typeToConvert);
+ public override global::System.Text.Json.Serialization.JsonConverter CreateConverter(global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options) => _lookup[typeToConvert].Value;
+ }
+}
+
+// ------------------------------------------------------------------------------
+//
+// 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.
+//
+// ------------------------------------------------------------------------------
+// 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 or IComparable should override comparison operators
+#pragma warning disable MA0097
+// Suppress warning for 'The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source.'
+// The generator copies signatures from the BCL, e.g. for `TryParse`, and some of those have nullable annotations.
+#pragma warning disable CS8669, CS8632
+#pragma warning disable CS8604 // Possible null reference argument.
+
+// Suppress warnings about CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member'
+#pragma warning disable CS1591
+// Suppress warnings about CS8767 : Nullability of reference types in type of parameter doesn't match implicitly implemented member (possibly because of nullability attributes).
+#pragma warning disable CS8767
+namespace MyNamespace
+{
+ [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.Diagnostics.DebuggerTypeProxyAttribute(typeof(MyVoDebugView))]
+ [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: global::System.Int32, Value = { _value }")]
+ // ReSharper disable once UnusedType.Global
+ public partial struct MyVo : global::System.IEquatable, global::System.IEquatable, global::System.IComparable, global::System.IComparable, global::System.IParsable, global::System.ISpanParsable, global::System.IUtf8SpanParsable, global::System.IFormattable, global::System.ISpanFormattable, global::System.IUtf8SpanFormattable, global::System.IConvertible
+ {
+#if DEBUG
+private readonly global::System.Diagnostics.StackTrace _stackTrace = null!;
+#endif
+#if !VOGEN_NO_VALIDATION
+ private readonly global::System.Boolean _isInitialized;
+#endif
+ private readonly global::System.Int32 _value;
+ ///
+ /// Gets the underlying value if set, otherwise a is thrown.
+ ///
+ public readonly global::System.Int32 Value
+ {
+ [global::System.Diagnostics.DebuggerStepThroughAttribute]
+ [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+ 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
+#if !VOGEN_NO_VALIDATION
+ _isInitialized = false;
+#endif
+ _value = default;
+ }
+
+ [global::System.Diagnostics.DebuggerStepThroughAttribute]
+ private MyVo(global::System.Int32 value)
+ {
+ _value = value;
+#if !VOGEN_NO_VALIDATION
+ _isInitialized = true;
+#endif
+#if DEBUG
+ _stackTrace = null;
+#endif
+ }
+
+ ///
+ /// Builds an instance from the provided underlying type.
+ ///
+ /// The underlying type.
+ /// An instance of this type.
+ [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+ public static MyVo From(global::System.Int32 value)
+ {
+ return new MyVo(value);
+ }
+
+ ///
+ /// Tries to build an instance from the provided underlying type.
+ /// If a normalization method is provided, it will be called.
+ /// If validation is provided, and it fails, false will be returned.
+ ///
+ /// The underlying type.
+ /// An instance of the value object.
+ /// True if the value object can be built, otherwise false.
+ public static bool TryFrom(
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ global::System.Int32 value,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)]
+#endif
+ out MyVo vo)
+ {
+ vo = new MyVo(value);
+ return true;
+ }
+
+ ///
+ /// Tries to build an instance from the provided underlying value.
+ /// If a normalization method is provided, it will be called.
+ /// If validation is provided, and it fails, an error will be returned.
+ ///
+ /// The primitive value.
+ /// A containing either the value object, or an error.
+ public static global::Vogen.ValueObjectOrError TryFrom(global::System.Int32 value)
+ {
+ return new global::Vogen.ValueObjectOrError(new MyVo(value));
+ }
+
+ [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+#if VOGEN_NO_VALIDATION
+#pragma warning disable CS8775
+ public readonly bool IsInitialized() => true;
+#pragma warning restore CS8775
+#else
+ public readonly bool IsInitialized() => _isInitialized;
+#endif
+ public static explicit operator MyVo(global::System.Int32 value) => From(value);
+ public static explicit operator global::System.Int32(MyVo value) => value.Value;
+ // only called internally when something has been deserialized into
+ // its primitive type.
+ private static MyVo __Deserialize(global::System.Int32 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.Default.Equals(Value, other.Value);
+ }
+
+ public global::System.Boolean Equals(MyVo other, global::System.Collections.Generic.IEqualityComparer comparer)
+ {
+ return comparer.Equals(this, other);
+ }
+
+ public readonly global::System.Boolean Equals(global::System.Int32 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) => left.Equals(right);
+ public static global::System.Boolean operator !=(MyVo left, MyVo right) => !(left == right);
+ public static global::System.Boolean operator ==(MyVo left, global::System.Int32 right) => left.Value.Equals(right);
+ public static global::System.Boolean operator ==(global::System.Int32 left, MyVo right) => right.Value.Equals(left);
+ public static global::System.Boolean operator !=(global::System.Int32 left, MyVo right) => !(left == right);
+ public static global::System.Boolean operator !=(MyVo left, global::System.Int32 right) => !(left == right);
+ 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);
+ ThrowHelper.ThrowArgumentException("Cannot compare to object as it is not of type MyVo", nameof(other));
+ return 0;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(global::System.ReadOnlySpan utf8Text, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(utf8Text, style, provider, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(global::System.ReadOnlySpan utf8Text, global::System.IFormatProvider provider,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(utf8Text, provider, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(global::System.ReadOnlySpan utf8Text,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(utf8Text, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(global::System.ReadOnlySpan s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(s, style, provider, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(global::System.ReadOnlySpan s, global::System.IFormatProvider provider,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(s, provider, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(global::System.ReadOnlySpan s,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(s, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(string s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(s, style, provider, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(string s, global::System.IFormatProvider provider,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(s, provider, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(string s,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(s, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(global::System.ReadOnlySpan utf8Text, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Int32.Parse(utf8Text, style, provider);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(global::System.ReadOnlySpan utf8Text, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Int32.Parse(utf8Text, provider);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(global::System.ReadOnlySpan s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Int32.Parse(s, style, provider);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(global::System.ReadOnlySpan s, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Int32.Parse(s, provider);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(string s)
+ {
+ var r = global::System.Int32.Parse(s);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(string s, global::System.Globalization.NumberStyles style)
+ {
+ var r = global::System.Int32.Parse(s, style);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(string s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Int32.Parse(s, style, provider);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(string s, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Int32.Parse(s, provider);
+ return From(r);
+ }
+
+#nullable disable
+ ///
+ public string ToString([System.Diagnostics.CodeAnalysis.StringSyntaxAttribute("NumericFormat")] string format, global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? Value.ToString(format, provider) : "[UNINITIALIZED]";
+ }
+
+ ///
+ public bool TryFormat(global::System.Span destination, out int charsWritten, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute("NumericFormat")] global::System.ReadOnlySpan format, global::System.IFormatProvider provider)
+ {
+ charsWritten = default;
+ return IsInitialized() ? Value.TryFormat(destination, out charsWritten, format, provider) : true;
+ }
+
+ ///
+ public bool TryFormat(global::System.Span utf8Destination, out int bytesWritten, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute("NumericFormat")] global::System.ReadOnlySpan format, global::System.IFormatProvider provider)
+ {
+ bytesWritten = default;
+ return IsInitialized() ? Value.TryFormat(utf8Destination, out bytesWritten, format, provider) : true;
+ }
+
+#nullable restore
+#nullable disable
+ ///
+ public System.TypeCode GetTypeCode()
+ {
+ return IsInitialized() ? Value.GetTypeCode() : default;
+ }
+
+ ///
+ bool System.IConvertible.ToBoolean(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToBoolean(provider) : default;
+ }
+
+ ///
+ byte System.IConvertible.ToByte(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToByte(provider) : default;
+ }
+
+ ///
+ char System.IConvertible.ToChar(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToChar(provider) : default;
+ }
+
+ ///
+ System.DateTime System.IConvertible.ToDateTime(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToDateTime(provider) : default;
+ }
+
+ ///
+ decimal System.IConvertible.ToDecimal(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToDecimal(provider) : default;
+ }
+
+ ///
+ double System.IConvertible.ToDouble(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToDouble(provider) : default;
+ }
+
+ ///
+ short System.IConvertible.ToInt16(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToInt16(provider) : default;
+ }
+
+ ///
+ int System.IConvertible.ToInt32(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToInt32(provider) : default;
+ }
+
+ ///
+ long System.IConvertible.ToInt64(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToInt64(provider) : default;
+ }
+
+ ///
+ sbyte System.IConvertible.ToSByte(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToSByte(provider) : default;
+ }
+
+ ///
+ float System.IConvertible.ToSingle(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToSingle(provider) : default;
+ }
+
+ ///
+ object System.IConvertible.ToType(global::System.Type @type, global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToType(@type, provider) : default;
+ }
+
+ ///
+ ushort System.IConvertible.ToUInt16(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToUInt16(provider) : default;
+ }
+
+ ///
+ uint System.IConvertible.ToUInt32(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToUInt32(provider) : default;
+ }
+
+ ///
+ ulong System.IConvertible.ToUInt64(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToUInt64(provider) : default;
+ }
+
+#nullable restore
+ public readonly override global::System.Int32 GetHashCode()
+ {
+ return global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value);
+ }
+
+ ///
+ public override global::System.String ToString() => IsInitialized() ? Value.ToString() ?? "" : "[UNINITIALIZED]";
+ ///
+ public global::System.String ToString(global::System.IFormatProvider provider) => IsInitialized() ? Value.ToString(provider) ?? "" : "[UNINITIALIZED]";
+ ///
+ public global::System.String ToString([System.Diagnostics.CodeAnalysis.StringSyntaxAttribute("NumericFormat")] string format) => IsInitialized() ? Value.ToString(format) ?? "" : "[UNINITIALIZED]";
+ [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+ private readonly void EnsureInitialized()
+ {
+ if (!IsInitialized())
+ {
+#if DEBUG
+ ThrowHelper.ThrowWhenNotInitialized(_stackTrace);
+#else
+ ThrowHelper.ThrowWhenNotInitialized();
+#endif
+ }
+ }
+
+#nullable disable
+ ///
+ /// Converts a MyVo to or from JSON.
+ ///
+ public partial class MyVoSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter
+ {
+ public override MyVo Read(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
+ {
+#if NET5_0_OR_GREATER
+ return DeserializeJson(global::System.Text.Json.JsonSerializer.Deserialize(ref reader, (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)options.GetTypeInfo(typeof(global::System.Int32))));
+#else
+ return DeserializeJson(reader.GetInt32());
+#endif
+ }
+
+ public override void Write(global::System.Text.Json.Utf8JsonWriter writer, MyVo value, global::System.Text.Json.JsonSerializerOptions options)
+ {
+#if NET5_0_OR_GREATER
+ global::System.Text.Json.JsonSerializer.Serialize(writer, value.Value, options);
+#else
+ writer.WriteNumberValue(value.Value);
+#endif
+ }
+
+#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 DeserializeJson(global::System.Int32.Parse(reader.GetString(), global::System.Globalization.NumberStyles.Any, global::System.Globalization.CultureInfo.InvariantCulture));
+ }
+
+ public override void WriteAsPropertyName(global::System.Text.Json.Utf8JsonWriter writer, MyVo value, global::System.Text.Json.JsonSerializerOptions options)
+ {
+ writer.WritePropertyName(value.Value.ToString(global::System.Globalization.CultureInfo.InvariantCulture));
+ }
+#endif
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ private static void ThrowJsonExceptionWhenValidationFails(global::Vogen.Validation validation)
+ {
+ var e = ThrowHelper.CreateValidationException(validation);
+ throw new global::System.Text.Json.JsonException(null, e);
+ }
+
+ private static MyVo DeserializeJson(global::System.Int32 value)
+ {
+ return new MyVo(value);
+ }
+ }
+
+#nullable restore
+#nullable disable
+ 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.Int32";
+ 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 => @"SystemTextJson";
+ }
+
+#nullable restore
+ static class ThrowHelper
+ {
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ internal static void ThrowInvalidOperationException(string message) => throw new global::System.InvalidOperationException(message);
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ internal static void ThrowArgumentException(string message, string arg) => throw new global::System.ArgumentException(message, arg);
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ internal static void ThrowWhenCreatedWithNull() => throw CreateCannotBeNullException();
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ internal static void ThrowWhenNotInitialized() => throw CreateValidationException("Use of uninitialized Value Object.");
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ internal static void ThrowWhenNotInitialized(global::System.Diagnostics.StackTrace stackTrace) => throw CreateValidationException("Use of uninitialized Value Object at: " + stackTrace ?? "");
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ internal static void ThrowWhenValidationFails(global::Vogen.Validation validation)
+ {
+ throw CreateValidationException(validation);
+ }
+
+ internal static global::System.Exception CreateValidationException(string message) => new global::Vogen.ValueObjectValidationException(message);
+ internal static global::System.Exception CreateCannotBeNullException() => new global::Vogen.ValueObjectValidationException("Cannot create a value object with null.");
+ internal static global::System.Exception CreateValidationException(global::Vogen.Validation validation)
+ {
+ var ex = CreateValidationException(validation.ErrorMessage);
+ if (validation.Data != null)
+ {
+ foreach (var kvp in validation.Data)
+ {
+ ex.Data[kvp.Key] = kvp.Value;
+ }
+ }
+
+ return ex;
+ }
+ }
+ }
+}
+]
\ No newline at end of file
diff --git a/tests/SnapshotTests/BugFixes/snapshots/snap-v8.0/Bug918_AssemblyNameStartingWithDigit.RootNamespace_overrides_assembly_name.verified.txt b/tests/SnapshotTests/BugFixes/snapshots/snap-v8.0/Bug918_AssemblyNameStartingWithDigit.RootNamespace_overrides_assembly_name.verified.txt
new file mode 100644
index 0000000000..a422946c03
--- /dev/null
+++ b/tests/SnapshotTests/BugFixes/snapshots/snap-v8.0/Bug918_AssemblyNameStartingWithDigit.RootNamespace_overrides_assembly_name.verified.txt
@@ -0,0 +1,793 @@
+[
+// ------------------------------------------------------------------------------
+//
+// 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.
+//
+// ------------------------------------------------------------------------------
+// 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 or IComparable should override comparison operators
+#pragma warning disable MA0097
+// Suppress warning for 'The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source.'
+// The generator copies signatures from the BCL, e.g. for `TryParse`, and some of those have nullable annotations.
+#pragma warning disable CS8669, CS8632
+#pragma warning disable CS8604 // Possible null reference argument.
+
+// Suppress warnings about CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member'
+#pragma warning disable CS1591
+// Suppress warnings about CS8767 : Nullability of reference types in type of parameter doesn't match implicitly implemented member (possibly because of nullability attributes).
+#pragma warning disable CS8767
+namespace OneProject
+{
+ [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
+ public class VogenTypesFactory : global::System.Text.Json.Serialization.JsonConverterFactory
+ {
+ public VogenTypesFactory()
+ {
+ }
+
+ private static readonly global::System.Collections.Generic.Dictionary> _lookup = new global::System.Collections.Generic.Dictionary>
+ {
+ {
+ typeof(global::MyNamespace.MyVo),
+ new global::System.Lazy(() => new global::MyNamespace.MyVo.MyVoSystemTextJsonConverter())
+ }
+ };
+ public override bool CanConvert(global::System.Type typeToConvert) => _lookup.ContainsKey(typeToConvert);
+ public override global::System.Text.Json.Serialization.JsonConverter CreateConverter(global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options) => _lookup[typeToConvert].Value;
+ }
+}
+
+// ------------------------------------------------------------------------------
+//
+// 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.
+//
+// ------------------------------------------------------------------------------
+// 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 or IComparable should override comparison operators
+#pragma warning disable MA0097
+// Suppress warning for 'The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source.'
+// The generator copies signatures from the BCL, e.g. for `TryParse`, and some of those have nullable annotations.
+#pragma warning disable CS8669, CS8632
+#pragma warning disable CS8604 // Possible null reference argument.
+
+// Suppress warnings about CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member'
+#pragma warning disable CS1591
+// Suppress warnings about CS8767 : Nullability of reference types in type of parameter doesn't match implicitly implemented member (possibly because of nullability attributes).
+#pragma warning disable CS8767
+namespace MyNamespace
+{
+ [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.Diagnostics.DebuggerTypeProxyAttribute(typeof(MyVoDebugView))]
+ [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: global::System.Int32, Value = { _value }")]
+ // ReSharper disable once UnusedType.Global
+ public partial struct MyVo : global::System.IEquatable, global::System.IEquatable, global::System.IComparable, global::System.IComparable, global::System.IParsable, global::System.ISpanParsable, global::System.IUtf8SpanParsable, global::System.IFormattable, global::System.ISpanFormattable, global::System.IUtf8SpanFormattable, global::System.IConvertible
+ {
+#if DEBUG
+private readonly global::System.Diagnostics.StackTrace _stackTrace = null!;
+#endif
+#if !VOGEN_NO_VALIDATION
+ private readonly global::System.Boolean _isInitialized;
+#endif
+ private readonly global::System.Int32 _value;
+ ///
+ /// Gets the underlying value if set, otherwise a is thrown.
+ ///
+ public readonly global::System.Int32 Value
+ {
+ [global::System.Diagnostics.DebuggerStepThroughAttribute]
+ [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+ 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
+#if !VOGEN_NO_VALIDATION
+ _isInitialized = false;
+#endif
+ _value = default;
+ }
+
+ [global::System.Diagnostics.DebuggerStepThroughAttribute]
+ private MyVo(global::System.Int32 value)
+ {
+ _value = value;
+#if !VOGEN_NO_VALIDATION
+ _isInitialized = true;
+#endif
+#if DEBUG
+ _stackTrace = null;
+#endif
+ }
+
+ ///
+ /// Builds an instance from the provided underlying type.
+ ///
+ /// The underlying type.
+ /// An instance of this type.
+ [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+ public static MyVo From(global::System.Int32 value)
+ {
+ return new MyVo(value);
+ }
+
+ ///
+ /// Tries to build an instance from the provided underlying type.
+ /// If a normalization method is provided, it will be called.
+ /// If validation is provided, and it fails, false will be returned.
+ ///
+ /// The underlying type.
+ /// An instance of the value object.
+ /// True if the value object can be built, otherwise false.
+ public static bool TryFrom(
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ global::System.Int32 value,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)]
+#endif
+ out MyVo vo)
+ {
+ vo = new MyVo(value);
+ return true;
+ }
+
+ ///
+ /// Tries to build an instance from the provided underlying value.
+ /// If a normalization method is provided, it will be called.
+ /// If validation is provided, and it fails, an error will be returned.
+ ///
+ /// The primitive value.
+ /// A containing either the value object, or an error.
+ public static global::Vogen.ValueObjectOrError TryFrom(global::System.Int32 value)
+ {
+ return new global::Vogen.ValueObjectOrError(new MyVo(value));
+ }
+
+ [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+#if VOGEN_NO_VALIDATION
+#pragma warning disable CS8775
+ public readonly bool IsInitialized() => true;
+#pragma warning restore CS8775
+#else
+ public readonly bool IsInitialized() => _isInitialized;
+#endif
+ public static explicit operator MyVo(global::System.Int32 value) => From(value);
+ public static explicit operator global::System.Int32(MyVo value) => value.Value;
+ // only called internally when something has been deserialized into
+ // its primitive type.
+ private static MyVo __Deserialize(global::System.Int32 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.Default.Equals(Value, other.Value);
+ }
+
+ public global::System.Boolean Equals(MyVo other, global::System.Collections.Generic.IEqualityComparer comparer)
+ {
+ return comparer.Equals(this, other);
+ }
+
+ public readonly global::System.Boolean Equals(global::System.Int32 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) => left.Equals(right);
+ public static global::System.Boolean operator !=(MyVo left, MyVo right) => !(left == right);
+ public static global::System.Boolean operator ==(MyVo left, global::System.Int32 right) => left.Value.Equals(right);
+ public static global::System.Boolean operator ==(global::System.Int32 left, MyVo right) => right.Value.Equals(left);
+ public static global::System.Boolean operator !=(global::System.Int32 left, MyVo right) => !(left == right);
+ public static global::System.Boolean operator !=(MyVo left, global::System.Int32 right) => !(left == right);
+ 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);
+ ThrowHelper.ThrowArgumentException("Cannot compare to object as it is not of type MyVo", nameof(other));
+ return 0;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(global::System.ReadOnlySpan utf8Text, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(utf8Text, style, provider, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(global::System.ReadOnlySpan utf8Text, global::System.IFormatProvider provider,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(utf8Text, provider, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(global::System.ReadOnlySpan utf8Text,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(utf8Text, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(global::System.ReadOnlySpan s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(s, style, provider, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(global::System.ReadOnlySpan s, global::System.IFormatProvider provider,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(s, provider, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(global::System.ReadOnlySpan s,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(s, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(string s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(s, style, provider, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(string s, global::System.IFormatProvider provider,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(s, provider, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(string s,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(s, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(global::System.ReadOnlySpan utf8Text, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Int32.Parse(utf8Text, style, provider);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(global::System.ReadOnlySpan utf8Text, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Int32.Parse(utf8Text, provider);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(global::System.ReadOnlySpan s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Int32.Parse(s, style, provider);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(global::System.ReadOnlySpan s, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Int32.Parse(s, provider);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(string s)
+ {
+ var r = global::System.Int32.Parse(s);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(string s, global::System.Globalization.NumberStyles style)
+ {
+ var r = global::System.Int32.Parse(s, style);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(string s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Int32.Parse(s, style, provider);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(string s, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Int32.Parse(s, provider);
+ return From(r);
+ }
+
+#nullable disable
+ ///
+ public string ToString([System.Diagnostics.CodeAnalysis.StringSyntaxAttribute("NumericFormat")] string format, global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? Value.ToString(format, provider) : "[UNINITIALIZED]";
+ }
+
+ ///
+ public bool TryFormat(global::System.Span destination, out int charsWritten, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute("NumericFormat")] global::System.ReadOnlySpan format, global::System.IFormatProvider provider)
+ {
+ charsWritten = default;
+ return IsInitialized() ? Value.TryFormat(destination, out charsWritten, format, provider) : true;
+ }
+
+ ///
+ public bool TryFormat(global::System.Span utf8Destination, out int bytesWritten, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute("NumericFormat")] global::System.ReadOnlySpan format, global::System.IFormatProvider provider)
+ {
+ bytesWritten = default;
+ return IsInitialized() ? Value.TryFormat(utf8Destination, out bytesWritten, format, provider) : true;
+ }
+
+#nullable restore
+#nullable disable
+ ///
+ public System.TypeCode GetTypeCode()
+ {
+ return IsInitialized() ? Value.GetTypeCode() : default;
+ }
+
+ ///
+ bool System.IConvertible.ToBoolean(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToBoolean(provider) : default;
+ }
+
+ ///
+ byte System.IConvertible.ToByte(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToByte(provider) : default;
+ }
+
+ ///
+ char System.IConvertible.ToChar(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToChar(provider) : default;
+ }
+
+ ///
+ System.DateTime System.IConvertible.ToDateTime(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToDateTime(provider) : default;
+ }
+
+ ///
+ decimal System.IConvertible.ToDecimal(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToDecimal(provider) : default;
+ }
+
+ ///
+ double System.IConvertible.ToDouble(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToDouble(provider) : default;
+ }
+
+ ///
+ short System.IConvertible.ToInt16(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToInt16(provider) : default;
+ }
+
+ ///
+ int System.IConvertible.ToInt32(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToInt32(provider) : default;
+ }
+
+ ///
+ long System.IConvertible.ToInt64(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToInt64(provider) : default;
+ }
+
+ ///
+ sbyte System.IConvertible.ToSByte(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToSByte(provider) : default;
+ }
+
+ ///
+ float System.IConvertible.ToSingle(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToSingle(provider) : default;
+ }
+
+ ///
+ object System.IConvertible.ToType(global::System.Type @type, global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToType(@type, provider) : default;
+ }
+
+ ///
+ ushort System.IConvertible.ToUInt16(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToUInt16(provider) : default;
+ }
+
+ ///
+ uint System.IConvertible.ToUInt32(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToUInt32(provider) : default;
+ }
+
+ ///
+ ulong System.IConvertible.ToUInt64(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToUInt64(provider) : default;
+ }
+
+#nullable restore
+ public readonly override global::System.Int32 GetHashCode()
+ {
+ return global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value);
+ }
+
+ ///
+ public override global::System.String ToString() => IsInitialized() ? Value.ToString() ?? "" : "[UNINITIALIZED]";
+ ///
+ public global::System.String ToString(global::System.IFormatProvider provider) => IsInitialized() ? Value.ToString(provider) ?? "" : "[UNINITIALIZED]";
+ ///
+ public global::System.String ToString([System.Diagnostics.CodeAnalysis.StringSyntaxAttribute("NumericFormat")] string format) => IsInitialized() ? Value.ToString(format) ?? "" : "[UNINITIALIZED]";
+ [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+ private readonly void EnsureInitialized()
+ {
+ if (!IsInitialized())
+ {
+#if DEBUG
+ ThrowHelper.ThrowWhenNotInitialized(_stackTrace);
+#else
+ ThrowHelper.ThrowWhenNotInitialized();
+#endif
+ }
+ }
+
+#nullable disable
+ ///
+ /// Converts a MyVo to or from JSON.
+ ///
+ public partial class MyVoSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter
+ {
+ public override MyVo Read(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
+ {
+#if NET5_0_OR_GREATER
+ return DeserializeJson(global::System.Text.Json.JsonSerializer.Deserialize(ref reader, (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)options.GetTypeInfo(typeof(global::System.Int32))));
+#else
+ return DeserializeJson(reader.GetInt32());
+#endif
+ }
+
+ public override void Write(global::System.Text.Json.Utf8JsonWriter writer, MyVo value, global::System.Text.Json.JsonSerializerOptions options)
+ {
+#if NET5_0_OR_GREATER
+ global::System.Text.Json.JsonSerializer.Serialize(writer, value.Value, options);
+#else
+ writer.WriteNumberValue(value.Value);
+#endif
+ }
+
+#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 DeserializeJson(global::System.Int32.Parse(reader.GetString(), global::System.Globalization.NumberStyles.Any, global::System.Globalization.CultureInfo.InvariantCulture));
+ }
+
+ public override void WriteAsPropertyName(global::System.Text.Json.Utf8JsonWriter writer, MyVo value, global::System.Text.Json.JsonSerializerOptions options)
+ {
+ writer.WritePropertyName(value.Value.ToString(global::System.Globalization.CultureInfo.InvariantCulture));
+ }
+#endif
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ private static void ThrowJsonExceptionWhenValidationFails(global::Vogen.Validation validation)
+ {
+ var e = ThrowHelper.CreateValidationException(validation);
+ throw new global::System.Text.Json.JsonException(null, e);
+ }
+
+ private static MyVo DeserializeJson(global::System.Int32 value)
+ {
+ return new MyVo(value);
+ }
+ }
+
+#nullable restore
+#nullable disable
+ 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.Int32";
+ 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 => @"SystemTextJson";
+ }
+
+#nullable restore
+ static class ThrowHelper
+ {
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ internal static void ThrowInvalidOperationException(string message) => throw new global::System.InvalidOperationException(message);
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ internal static void ThrowArgumentException(string message, string arg) => throw new global::System.ArgumentException(message, arg);
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ internal static void ThrowWhenCreatedWithNull() => throw CreateCannotBeNullException();
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ internal static void ThrowWhenNotInitialized() => throw CreateValidationException("Use of uninitialized Value Object.");
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ internal static void ThrowWhenNotInitialized(global::System.Diagnostics.StackTrace stackTrace) => throw CreateValidationException("Use of uninitialized Value Object at: " + stackTrace ?? "");
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ internal static void ThrowWhenValidationFails(global::Vogen.Validation validation)
+ {
+ throw CreateValidationException(validation);
+ }
+
+ internal static global::System.Exception CreateValidationException(string message) => new global::Vogen.ValueObjectValidationException(message);
+ internal static global::System.Exception CreateCannotBeNullException() => new global::Vogen.ValueObjectValidationException("Cannot create a value object with null.");
+ internal static global::System.Exception CreateValidationException(global::Vogen.Validation validation)
+ {
+ var ex = CreateValidationException(validation.ErrorMessage);
+ if (validation.Data != null)
+ {
+ foreach (var kvp in validation.Data)
+ {
+ ex.Data[kvp.Key] = kvp.Value;
+ }
+ }
+
+ return ex;
+ }
+ }
+ }
+}
+]
\ No newline at end of file
diff --git a/tests/SnapshotTests/BugFixes/snapshots/snap-v9.0/Bug907_GenericUnderlyingTypeInheritDocWarnings.Generic_underlying_type_does_not_generate_invalid_cref_in_parse_methods.verified.txt b/tests/SnapshotTests/BugFixes/snapshots/snap-v9.0/Bug907_GenericUnderlyingTypeInheritDocWarnings.Generic_underlying_type_does_not_generate_invalid_cref_in_parse_methods.verified.txt
deleted file mode 100644
index c0fa118d68..0000000000
--- a/tests/SnapshotTests/BugFixes/snapshots/snap-v9.0/Bug907_GenericUnderlyingTypeInheritDocWarnings.Generic_underlying_type_does_not_generate_invalid_cref_in_parse_methods.verified.txt
+++ /dev/null
@@ -1,465 +0,0 @@
-[
-// ------------------------------------------------------------------------------
-//
-// 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.
-//
-// ------------------------------------------------------------------------------
-// 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 or IComparable should override comparison operators
-#pragma warning disable MA0097
-// Suppress warning for 'The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source.'
-// The generator copies signatures from the BCL, e.g. for `TryParse`, and some of those have nullable annotations.
-#pragma warning disable CS8669, CS8632
-#pragma warning disable CS8604 // Possible null reference argument.
-
-// Suppress warnings about CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member'
-#pragma warning disable CS1591
-// Suppress warnings about CS8767 : Nullability of reference types in type of parameter doesn't match implicitly implemented member (possibly because of nullability attributes).
-#pragma warning disable CS8767
-namespace generator
-{
- [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
- public class VogenTypesFactory : global::System.Text.Json.Serialization.JsonConverterFactory
- {
- public VogenTypesFactory()
- {
- }
-
- private static readonly global::System.Collections.Generic.Dictionary> _lookup = new global::System.Collections.Generic.Dictionary>
- {
- {
- typeof(ImageAspectRatio),
- new global::System.Lazy(() => new ImageAspectRatio.ImageAspectRatioSystemTextJsonConverter())
- }
- };
- public override bool CanConvert(global::System.Type typeToConvert) => _lookup.ContainsKey(typeToConvert);
- public override global::System.Text.Json.Serialization.JsonConverter CreateConverter(global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options) => _lookup[typeToConvert].Value;
- }
-}
-
-// ------------------------------------------------------------------------------
-//
-// 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.
-//
-// ------------------------------------------------------------------------------
-// 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 or IComparable should override comparison operators
-#pragma warning disable MA0097
-// Suppress warning for 'The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source.'
-// The generator copies signatures from the BCL, e.g. for `TryParse`, and some of those have nullable annotations.
-#pragma warning disable CS8669, CS8632
-#pragma warning disable CS8604 // Possible null reference argument.
-
-// Suppress warnings about CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member'
-#pragma warning disable CS1591
-// Suppress warnings about CS8767 : Nullability of reference types in type of parameter doesn't match implicitly implemented member (possibly because of nullability attributes).
-#pragma warning disable CS8767
-#nullable enable
-[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
-[global::System.Text.Json.Serialization.JsonConverter(typeof(ImageAspectRatioSystemTextJsonConverter))]
-[global::System.ComponentModel.TypeConverter(typeof(ImageAspectRatioTypeConverter))]
-[global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(ImageAspectRatioDebugView))]
-[global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: global::Ratio, Value = { _value }")]
-public partial class ImageAspectRatio : global::System.IEquatable, global::System.IEquatable>, global::System.IParsable
-{
-#if DEBUG
-private readonly global::System.Diagnostics.StackTrace? _stackTrace = null!;
-#endif
-#if !VOGEN_NO_VALIDATION
- private readonly global::System.Boolean _isInitialized;
-#endif
- private readonly global::Ratio? _value;
- ///
- /// Gets the underlying value if set, otherwise a is thrown.
- ///
- public global::Ratio Value
- {
- [global::System.Diagnostics.DebuggerStepThroughAttribute]
- [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
- get
- {
- EnsureInitialized();
- return _value!;
- }
- }
-
- [global::System.Diagnostics.DebuggerStepThroughAttribute]
- [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
- public ImageAspectRatio()
- {
-#if DEBUG
- _stackTrace = new global::System.Diagnostics.StackTrace();
-#endif
-#if !VOGEN_NO_VALIDATION
- _isInitialized = false;
-#endif
- _value = default !;
- }
-
- [global::System.Diagnostics.DebuggerStepThroughAttribute]
- private ImageAspectRatio(global::Ratio value)
- {
- _value = value;
-#if !VOGEN_NO_VALIDATION
- _isInitialized = true;
-#endif
- }
-
- ///
- /// Builds an instance from the provided underlying type.
- ///
- /// The underlying type.
- /// An instance of this type.
- [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
- public static ImageAspectRatio From(global::Ratio value)
- {
- if (value is null)
- {
- ThrowHelper.ThrowWhenCreatedWithNull();
- return default !;
- }
-
- return new ImageAspectRatio(value);
- }
-
- ///
- /// Tries to build an instance from the provided underlying type.
- /// If a normalization method is provided, it will be called.
- /// If validation is provided, and it fails, false will be returned.
- ///
- /// The underlying type.
- /// An instance of the value object.
- /// True if the value object can be built, otherwise false.
- public static bool TryFrom(
-#if NETCOREAPP3_0_OR_GREATER
-[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
-#endif
- global::Ratio? value,
-#if NETCOREAPP3_0_OR_GREATER
-[global::System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)]
-#endif
- out ImageAspectRatio vo)
- {
- if (value is null)
- {
- vo = default !;
- return false;
- }
-
- vo = new ImageAspectRatio(value);
- return true;
- }
-
- ///
- /// Tries to build an instance from the provided underlying value.
- /// If a normalization method is provided, it will be called.
- /// If validation is provided, and it fails, an error will be returned.
- ///
- /// The primitive value.
- /// A containing either the value object, or an error.
- public static global::Vogen.ValueObjectOrError TryFrom(global::Ratio value)
- {
- if (value is null)
- {
- return new global::Vogen.ValueObjectOrError(global::Vogen.Validation.Invalid("The value provided was null"));
- }
-
- return new global::Vogen.ValueObjectOrError(new ImageAspectRatio(value));
- }
-
- [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
-#if VOGEN_NO_VALIDATION
-#pragma warning disable CS8775
- public bool IsInitialized() => true;
-#pragma warning restore CS8775
-#else
- public bool IsInitialized() => _isInitialized;
-#endif
- // only called internally when something has been deserialized into
- // its primitive type.
- private static ImageAspectRatio __Deserialize(global::Ratio value)
- {
- if (value is null)
- {
- ThrowHelper.ThrowWhenCreatedWithNull();
- return default !;
- }
-
- return new ImageAspectRatio(value);
- }
-
- public global::System.Boolean Equals(ImageAspectRatio? 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>.Default.Equals(Value, other.Value);
- }
-
- public global::System.Boolean Equals(ImageAspectRatio? other, global::System.Collections.Generic.IEqualityComparer comparer)
- {
- return comparer.Equals(this, other);
- }
-
- public global::System.Boolean Equals(global::Ratio? primitive)
- {
- return Value.Equals(primitive);
- }
-
- public override global::System.Boolean Equals(global::System.Object? obj)
- {
- return Equals(obj as ImageAspectRatio);
- }
-
- public static global::System.Boolean operator ==(ImageAspectRatio? left, ImageAspectRatio? right) => Equals(left, right);
- public static global::System.Boolean operator !=(ImageAspectRatio? left, ImageAspectRatio? right) => !Equals(left, right);
- public static global::System.Boolean operator ==(ImageAspectRatio? left, global::Ratio? right) => left?.Value.Equals(right) ?? false;
- public static global::System.Boolean operator ==(global::Ratio? left, ImageAspectRatio? right) => right?.Value.Equals(left) ?? false;
- public static global::System.Boolean operator !=(global::Ratio? left, ImageAspectRatio? right) => !(left == right);
- public static global::System.Boolean operator !=(ImageAspectRatio? left, global::Ratio? right) => !(left == right);
- public static explicit operator ImageAspectRatio(global::Ratio value) => From(value);
- public static explicit operator global::Ratio(ImageAspectRatio value) => value.Value;
- ///
- ///
- ///
- ///
- /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
- ///
- public static global::System.Boolean TryParse(string? s, global::System.IFormatProvider? provider,
-#if NETCOREAPP3_0_OR_GREATER
-[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
-#endif
- out ImageAspectRatio result)
- {
- if (global::Ratio.TryParse(s, provider, out var __v))
- {
- result = new ImageAspectRatio(__v);
- return true;
- }
-
- result = default !;
- return false;
- }
-
- ///
- ///
- ///
- ///
- /// The value created by calling the Parse method on the primitive.
- ///
- /// Thrown when the value can be parsed, but is not valid.
- public static ImageAspectRatio Parse(string s, global::System.IFormatProvider? provider)
- {
- var r = global::Ratio.Parse(s, provider);
- return From(r!);
- }
-
-#nullable disable
-#nullable restore
- 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>.Default.GetHashCode(Value);
- return hash;
- }
- }
-
- ///
- /// Returns the wrapped primitive's ToString representation.
- ///
- ///
- /// If this instance hasn't been initialised, it will return "[UNINITIALIZED]". Otherwise the wrapped primitive's ToString representation.
- ///
- public override global::System.String ToString() => IsInitialized() ? Value.ToString() ?? "" : "[UNINITIALIZED]";
- [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
- private void EnsureInitialized()
- {
- if (!IsInitialized())
- {
-#if DEBUG
- ThrowHelper.ThrowWhenNotInitialized(_stackTrace);
-#else
- ThrowHelper.ThrowWhenNotInitialized();
-#endif
- }
- }
-
-#nullable disable
- ///
- /// Converts a ImageAspectRatio to or from JSON.
- ///
- public partial class ImageAspectRatioSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter
- {
- public override ImageAspectRatio Read(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
- {
- var primitive = global::System.Text.Json.JsonSerializer.Deserialize>(ref reader, options);
- return DeserializeJson(primitive);
- }
-
- public override void Write(global::System.Text.Json.Utf8JsonWriter writer, ImageAspectRatio value, global::System.Text.Json.JsonSerializerOptions options)
- {
- global::System.Text.Json.JsonSerializer.Serialize(writer, value.Value, options);
- }
-
-#if NET6_0_OR_GREATER
- public override ImageAspectRatio ReadAsPropertyName(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
- {
- var primitive = global::System.Text.Json.JsonSerializer.Deserialize>(ref reader, options);
- return DeserializeJson(primitive);
- }
-
- public override void WriteAsPropertyName(global::System.Text.Json.Utf8JsonWriter writer, ImageAspectRatio value, global::System.Text.Json.JsonSerializerOptions options)
- {
- writer.WritePropertyName(global::System.Text.Json.JsonSerializer.Serialize(value.Value));
- }
-#endif
-#if NETCOREAPP3_0_OR_GREATER
- [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
-#endif
- private static void ThrowJsonExceptionWhenValidationFails(global::Vogen.Validation validation)
- {
- var e = ThrowHelper.CreateValidationException(validation);
- throw new global::System.Text.Json.JsonException(null, e);
- }
-
- private static void ThrowJsonExceptionWhenNull(global::Ratio value)
- {
- if (value == null)
- {
- var e = ThrowHelper.CreateCannotBeNullException();
- throw new global::System.Text.Json.JsonException(null, e);
- }
- }
-
- private static ImageAspectRatio DeserializeJson(global::Ratio value)
- {
- ThrowJsonExceptionWhenNull(value);
- return new ImageAspectRatio(value);
- }
- }
-
-#nullable restore
-#nullable disable
- class ImageAspectRatioTypeConverter : global::System.ComponentModel.TypeConverter
- {
- public override global::System.Boolean CanConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType)
- {
- return sourceType == typeof(global::Ratio);
- }
-
- public override global::System.Object ConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Globalization.CultureInfo culture, global::System.Object value)
- {
- global::Ratio ut = (global::Ratio)value;
- return ImageAspectRatio.__Deserialize(ut);
- }
-
- public override bool CanConvertTo(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType)
- {
- return sourceType == typeof(global::Ratio);
- }
-
- 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 ImageAspectRatio idValue)
- {
- return idValue.Value;
- }
-
- return base.ConvertTo(context, culture, value, destinationType);
- }
- }
-
-#nullable restore
- internal sealed class ImageAspectRatioDebugView
- {
- private readonly ImageAspectRatio _t;
- ImageAspectRatioDebugView(ImageAspectRatio t)
- {
- _t = t;
- }
-
- public global::System.String UnderlyingType => "global::Ratio";
- public global::Ratio Value => _t.Value;
- public global::System.String Conversions => @"[global::System.Text.Json.Serialization.JsonConverter(typeof(ImageAspectRatioSystemTextJsonConverter))]
-[global::System.ComponentModel.TypeConverter(typeof(ImageAspectRatioTypeConverter))]
-";
- }
-
- static class ThrowHelper
- {
-#if NETCOREAPP3_0_OR_GREATER
- [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
-#endif
- internal static void ThrowInvalidOperationException(string message) => throw new global::System.InvalidOperationException(message);
-#if NETCOREAPP3_0_OR_GREATER
- [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
-#endif
- internal static void ThrowArgumentException(string message, string arg) => throw new global::System.ArgumentException(message, arg);
-#if NETCOREAPP3_0_OR_GREATER
- [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
-#endif
- internal static void ThrowWhenCreatedWithNull() => throw CreateCannotBeNullException();
-#if NETCOREAPP3_0_OR_GREATER
- [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
-#endif
- internal static void ThrowWhenNotInitialized() => throw CreateValidationException("Use of uninitialized Value Object.");
-#if NETCOREAPP3_0_OR_GREATER
- [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
-#endif
- internal static void ThrowWhenNotInitialized(global::System.Diagnostics.StackTrace? stackTrace) => throw CreateValidationException("Use of uninitialized Value Object at: " + stackTrace ?? "");
-#if NETCOREAPP3_0_OR_GREATER
- [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
-#endif
- internal static void ThrowWhenValidationFails(global::Vogen.Validation validation)
- {
- throw CreateValidationException(validation);
- }
-
- internal static global::System.Exception CreateValidationException(string message) => new global::Vogen.ValueObjectValidationException(message);
- internal static global::System.Exception CreateCannotBeNullException() => new global::Vogen.ValueObjectValidationException("Cannot create a value object with null.");
- internal static global::System.Exception CreateValidationException(global::Vogen.Validation validation)
- {
- var ex = CreateValidationException(validation.ErrorMessage);
- if (validation.Data != null)
- {
- foreach (var kvp in validation.Data)
- {
- ex.Data[kvp.Key] = kvp.Value;
- }
- }
-
- return ex;
- }
- }
-}
-#nullable restore
-
-]
\ No newline at end of file
diff --git a/tests/SnapshotTests/BugFixes/snapshots/snap-v9.0/Bug918_AssemblyNameStartingWithDigit.Assembly_name_starting_with_digit_is_sanitised.verified.txt b/tests/SnapshotTests/BugFixes/snapshots/snap-v9.0/Bug918_AssemblyNameStartingWithDigit.Assembly_name_starting_with_digit_is_sanitised.verified.txt
new file mode 100644
index 0000000000..9a6d32ec18
--- /dev/null
+++ b/tests/SnapshotTests/BugFixes/snapshots/snap-v9.0/Bug918_AssemblyNameStartingWithDigit.Assembly_name_starting_with_digit_is_sanitised.verified.txt
@@ -0,0 +1,793 @@
+[
+// ------------------------------------------------------------------------------
+//
+// 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.
+//
+// ------------------------------------------------------------------------------
+// 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 or IComparable should override comparison operators
+#pragma warning disable MA0097
+// Suppress warning for 'The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source.'
+// The generator copies signatures from the BCL, e.g. for `TryParse`, and some of those have nullable annotations.
+#pragma warning disable CS8669, CS8632
+#pragma warning disable CS8604 // Possible null reference argument.
+
+// Suppress warnings about CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member'
+#pragma warning disable CS1591
+// Suppress warnings about CS8767 : Nullability of reference types in type of parameter doesn't match implicitly implemented member (possibly because of nullability attributes).
+#pragma warning disable CS8767
+namespace _1MyProject
+{
+ [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
+ public class VogenTypesFactory : global::System.Text.Json.Serialization.JsonConverterFactory
+ {
+ public VogenTypesFactory()
+ {
+ }
+
+ private static readonly global::System.Collections.Generic.Dictionary> _lookup = new global::System.Collections.Generic.Dictionary>
+ {
+ {
+ typeof(global::MyNamespace.MyVo),
+ new global::System.Lazy(() => new global::MyNamespace.MyVo.MyVoSystemTextJsonConverter())
+ }
+ };
+ public override bool CanConvert(global::System.Type typeToConvert) => _lookup.ContainsKey(typeToConvert);
+ public override global::System.Text.Json.Serialization.JsonConverter CreateConverter(global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options) => _lookup[typeToConvert].Value;
+ }
+}
+
+// ------------------------------------------------------------------------------
+//
+// 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.
+//
+// ------------------------------------------------------------------------------
+// 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 or IComparable should override comparison operators
+#pragma warning disable MA0097
+// Suppress warning for 'The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source.'
+// The generator copies signatures from the BCL, e.g. for `TryParse`, and some of those have nullable annotations.
+#pragma warning disable CS8669, CS8632
+#pragma warning disable CS8604 // Possible null reference argument.
+
+// Suppress warnings about CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member'
+#pragma warning disable CS1591
+// Suppress warnings about CS8767 : Nullability of reference types in type of parameter doesn't match implicitly implemented member (possibly because of nullability attributes).
+#pragma warning disable CS8767
+namespace MyNamespace
+{
+ [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.Diagnostics.DebuggerTypeProxyAttribute(typeof(MyVoDebugView))]
+ [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: global::System.Int32, Value = { _value }")]
+ // ReSharper disable once UnusedType.Global
+ public partial struct MyVo : global::System.IEquatable, global::System.IEquatable, global::System.IComparable, global::System.IComparable, global::System.IParsable, global::System.ISpanParsable, global::System.IUtf8SpanParsable, global::System.IFormattable, global::System.ISpanFormattable, global::System.IUtf8SpanFormattable, global::System.IConvertible
+ {
+#if DEBUG
+private readonly global::System.Diagnostics.StackTrace _stackTrace = null!;
+#endif
+#if !VOGEN_NO_VALIDATION
+ private readonly global::System.Boolean _isInitialized;
+#endif
+ private readonly global::System.Int32 _value;
+ ///
+ /// Gets the underlying value if set, otherwise a is thrown.
+ ///
+ public readonly global::System.Int32 Value
+ {
+ [global::System.Diagnostics.DebuggerStepThroughAttribute]
+ [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+ 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
+#if !VOGEN_NO_VALIDATION
+ _isInitialized = false;
+#endif
+ _value = default;
+ }
+
+ [global::System.Diagnostics.DebuggerStepThroughAttribute]
+ private MyVo(global::System.Int32 value)
+ {
+ _value = value;
+#if !VOGEN_NO_VALIDATION
+ _isInitialized = true;
+#endif
+#if DEBUG
+ _stackTrace = null;
+#endif
+ }
+
+ ///
+ /// Builds an instance from the provided underlying type.
+ ///
+ /// The underlying type.
+ /// An instance of this type.
+ [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+ public static MyVo From(global::System.Int32 value)
+ {
+ return new MyVo(value);
+ }
+
+ ///
+ /// Tries to build an instance from the provided underlying type.
+ /// If a normalization method is provided, it will be called.
+ /// If validation is provided, and it fails, false will be returned.
+ ///
+ /// The underlying type.
+ /// An instance of the value object.
+ /// True if the value object can be built, otherwise false.
+ public static bool TryFrom(
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ global::System.Int32 value,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)]
+#endif
+ out MyVo vo)
+ {
+ vo = new MyVo(value);
+ return true;
+ }
+
+ ///
+ /// Tries to build an instance from the provided underlying value.
+ /// If a normalization method is provided, it will be called.
+ /// If validation is provided, and it fails, an error will be returned.
+ ///
+ /// The primitive value.
+ /// A containing either the value object, or an error.
+ public static global::Vogen.ValueObjectOrError TryFrom(global::System.Int32 value)
+ {
+ return new global::Vogen.ValueObjectOrError(new MyVo(value));
+ }
+
+ [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+#if VOGEN_NO_VALIDATION
+#pragma warning disable CS8775
+ public readonly bool IsInitialized() => true;
+#pragma warning restore CS8775
+#else
+ public readonly bool IsInitialized() => _isInitialized;
+#endif
+ public static explicit operator MyVo(global::System.Int32 value) => From(value);
+ public static explicit operator global::System.Int32(MyVo value) => value.Value;
+ // only called internally when something has been deserialized into
+ // its primitive type.
+ private static MyVo __Deserialize(global::System.Int32 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.Default.Equals(Value, other.Value);
+ }
+
+ public global::System.Boolean Equals(MyVo other, global::System.Collections.Generic.IEqualityComparer comparer)
+ {
+ return comparer.Equals(this, other);
+ }
+
+ public readonly global::System.Boolean Equals(global::System.Int32 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) => left.Equals(right);
+ public static global::System.Boolean operator !=(MyVo left, MyVo right) => !(left == right);
+ public static global::System.Boolean operator ==(MyVo left, global::System.Int32 right) => left.Value.Equals(right);
+ public static global::System.Boolean operator ==(global::System.Int32 left, MyVo right) => right.Value.Equals(left);
+ public static global::System.Boolean operator !=(global::System.Int32 left, MyVo right) => !(left == right);
+ public static global::System.Boolean operator !=(MyVo left, global::System.Int32 right) => !(left == right);
+ 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);
+ ThrowHelper.ThrowArgumentException("Cannot compare to object as it is not of type MyVo", nameof(other));
+ return 0;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(global::System.ReadOnlySpan utf8Text, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(utf8Text, style, provider, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(global::System.ReadOnlySpan utf8Text, global::System.IFormatProvider provider,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(utf8Text, provider, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(global::System.ReadOnlySpan utf8Text,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(utf8Text, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(global::System.ReadOnlySpan s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(s, style, provider, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(global::System.ReadOnlySpan s, global::System.IFormatProvider provider,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(s, provider, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(global::System.ReadOnlySpan s,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(s, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(string s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(s, style, provider, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(string s, global::System.IFormatProvider provider,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(s, provider, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(string s,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(s, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(global::System.ReadOnlySpan utf8Text, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Int32.Parse(utf8Text, style, provider);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(global::System.ReadOnlySpan utf8Text, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Int32.Parse(utf8Text, provider);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(global::System.ReadOnlySpan s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Int32.Parse(s, style, provider);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(global::System.ReadOnlySpan s, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Int32.Parse(s, provider);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(string s)
+ {
+ var r = global::System.Int32.Parse(s);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(string s, global::System.Globalization.NumberStyles style)
+ {
+ var r = global::System.Int32.Parse(s, style);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(string s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Int32.Parse(s, style, provider);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(string s, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Int32.Parse(s, provider);
+ return From(r);
+ }
+
+#nullable disable
+ ///
+ public string ToString([System.Diagnostics.CodeAnalysis.StringSyntaxAttribute("NumericFormat")] string format, global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? Value.ToString(format, provider) : "[UNINITIALIZED]";
+ }
+
+ ///
+ public bool TryFormat(global::System.Span destination, out int charsWritten, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute("NumericFormat")] global::System.ReadOnlySpan format, global::System.IFormatProvider provider)
+ {
+ charsWritten = default;
+ return IsInitialized() ? Value.TryFormat(destination, out charsWritten, format, provider) : true;
+ }
+
+ ///
+ public bool TryFormat(global::System.Span utf8Destination, out int bytesWritten, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute("NumericFormat")] global::System.ReadOnlySpan format, global::System.IFormatProvider provider)
+ {
+ bytesWritten = default;
+ return IsInitialized() ? Value.TryFormat(utf8Destination, out bytesWritten, format, provider) : true;
+ }
+
+#nullable restore
+#nullable disable
+ ///
+ public System.TypeCode GetTypeCode()
+ {
+ return IsInitialized() ? Value.GetTypeCode() : default;
+ }
+
+ ///
+ bool System.IConvertible.ToBoolean(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToBoolean(provider) : default;
+ }
+
+ ///
+ byte System.IConvertible.ToByte(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToByte(provider) : default;
+ }
+
+ ///
+ char System.IConvertible.ToChar(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToChar(provider) : default;
+ }
+
+ ///
+ System.DateTime System.IConvertible.ToDateTime(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToDateTime(provider) : default;
+ }
+
+ ///
+ decimal System.IConvertible.ToDecimal(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToDecimal(provider) : default;
+ }
+
+ ///
+ double System.IConvertible.ToDouble(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToDouble(provider) : default;
+ }
+
+ ///
+ short System.IConvertible.ToInt16(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToInt16(provider) : default;
+ }
+
+ ///
+ int System.IConvertible.ToInt32(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToInt32(provider) : default;
+ }
+
+ ///
+ long System.IConvertible.ToInt64(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToInt64(provider) : default;
+ }
+
+ ///
+ sbyte System.IConvertible.ToSByte(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToSByte(provider) : default;
+ }
+
+ ///
+ float System.IConvertible.ToSingle(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToSingle(provider) : default;
+ }
+
+ ///
+ object System.IConvertible.ToType(global::System.Type @type, global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToType(@type, provider) : default;
+ }
+
+ ///
+ ushort System.IConvertible.ToUInt16(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToUInt16(provider) : default;
+ }
+
+ ///
+ uint System.IConvertible.ToUInt32(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToUInt32(provider) : default;
+ }
+
+ ///
+ ulong System.IConvertible.ToUInt64(global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? (Value as System.IConvertible).ToUInt64(provider) : default;
+ }
+
+#nullable restore
+ public readonly override global::System.Int32 GetHashCode()
+ {
+ return global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value);
+ }
+
+ ///
+ public override global::System.String ToString() => IsInitialized() ? Value.ToString() ?? "" : "[UNINITIALIZED]";
+ ///
+ public global::System.String ToString(global::System.IFormatProvider provider) => IsInitialized() ? Value.ToString(provider) ?? "" : "[UNINITIALIZED]";
+ ///
+ public global::System.String ToString([System.Diagnostics.CodeAnalysis.StringSyntaxAttribute("NumericFormat")] string format) => IsInitialized() ? Value.ToString(format) ?? "" : "[UNINITIALIZED]";
+ [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+ private readonly void EnsureInitialized()
+ {
+ if (!IsInitialized())
+ {
+#if DEBUG
+ ThrowHelper.ThrowWhenNotInitialized(_stackTrace);
+#else
+ ThrowHelper.ThrowWhenNotInitialized();
+#endif
+ }
+ }
+
+#nullable disable
+ ///
+ /// Converts a MyVo to or from JSON.
+ ///
+ public partial class MyVoSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter
+ {
+ public override MyVo Read(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
+ {
+#if NET5_0_OR_GREATER
+ return DeserializeJson(global::System.Text.Json.JsonSerializer.Deserialize(ref reader, (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)options.GetTypeInfo(typeof(global::System.Int32))));
+#else
+ return DeserializeJson(reader.GetInt32());
+#endif
+ }
+
+ public override void Write(global::System.Text.Json.Utf8JsonWriter writer, MyVo value, global::System.Text.Json.JsonSerializerOptions options)
+ {
+#if NET5_0_OR_GREATER
+ global::System.Text.Json.JsonSerializer.Serialize(writer, value.Value, options);
+#else
+ writer.WriteNumberValue(value.Value);
+#endif
+ }
+
+#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 DeserializeJson(global::System.Int32.Parse(reader.GetString(), global::System.Globalization.NumberStyles.Any, global::System.Globalization.CultureInfo.InvariantCulture));
+ }
+
+ public override void WriteAsPropertyName(global::System.Text.Json.Utf8JsonWriter writer, MyVo value, global::System.Text.Json.JsonSerializerOptions options)
+ {
+ writer.WritePropertyName(value.Value.ToString(global::System.Globalization.CultureInfo.InvariantCulture));
+ }
+#endif
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ private static void ThrowJsonExceptionWhenValidationFails(global::Vogen.Validation validation)
+ {
+ var e = ThrowHelper.CreateValidationException(validation);
+ throw new global::System.Text.Json.JsonException(null, e);
+ }
+
+ private static MyVo DeserializeJson(global::System.Int32 value)
+ {
+ return new MyVo(value);
+ }
+ }
+
+#nullable restore
+#nullable disable
+ 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.Int32";
+ 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 => @"SystemTextJson";
+ }
+
+#nullable restore
+ static class ThrowHelper
+ {
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ internal static void ThrowInvalidOperationException(string message) => throw new global::System.InvalidOperationException(message);
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ internal static void ThrowArgumentException(string message, string arg) => throw new global::System.ArgumentException(message, arg);
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ internal static void ThrowWhenCreatedWithNull() => throw CreateCannotBeNullException();
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ internal static void ThrowWhenNotInitialized() => throw CreateValidationException("Use of uninitialized Value Object.");
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ internal static void ThrowWhenNotInitialized(global::System.Diagnostics.StackTrace stackTrace) => throw CreateValidationException("Use of uninitialized Value Object at: " + stackTrace ?? "");
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ internal static void ThrowWhenValidationFails(global::Vogen.Validation validation)
+ {
+ throw CreateValidationException(validation);
+ }
+
+ internal static global::System.Exception CreateValidationException(string message) => new global::Vogen.ValueObjectValidationException(message);
+ internal static global::System.Exception CreateCannotBeNullException() => new global::Vogen.ValueObjectValidationException("Cannot create a value object with null.");
+ internal static global::System.Exception CreateValidationException(global::Vogen.Validation validation)
+ {
+ var ex = CreateValidationException(validation.ErrorMessage);
+ if (validation.Data != null)
+ {
+ foreach (var kvp in validation.Data)
+ {
+ ex.Data[kvp.Key] = kvp.Value;
+ }
+ }
+
+ return ex;
+ }
+ }
+ }
+}
+]
\ No newline at end of file
diff --git a/tests/SnapshotTests/BugFixes/snapshots/snap-v9.0/Bug918_AssemblyNameStartingWithDigit.RootNamespace_overrides_assembly_name.verified.txt b/tests/SnapshotTests/BugFixes/snapshots/snap-v9.0/Bug918_AssemblyNameStartingWithDigit.RootNamespace_overrides_assembly_name.verified.txt
new file mode 100644
index 0000000000..a422946c03
--- /dev/null
+++ b/tests/SnapshotTests/BugFixes/snapshots/snap-v9.0/Bug918_AssemblyNameStartingWithDigit.RootNamespace_overrides_assembly_name.verified.txt
@@ -0,0 +1,793 @@
+[
+// ------------------------------------------------------------------------------
+//
+// 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.
+//
+// ------------------------------------------------------------------------------
+// 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 or IComparable should override comparison operators
+#pragma warning disable MA0097
+// Suppress warning for 'The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source.'
+// The generator copies signatures from the BCL, e.g. for `TryParse`, and some of those have nullable annotations.
+#pragma warning disable CS8669, CS8632
+#pragma warning disable CS8604 // Possible null reference argument.
+
+// Suppress warnings about CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member'
+#pragma warning disable CS1591
+// Suppress warnings about CS8767 : Nullability of reference types in type of parameter doesn't match implicitly implemented member (possibly because of nullability attributes).
+#pragma warning disable CS8767
+namespace OneProject
+{
+ [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
+ public class VogenTypesFactory : global::System.Text.Json.Serialization.JsonConverterFactory
+ {
+ public VogenTypesFactory()
+ {
+ }
+
+ private static readonly global::System.Collections.Generic.Dictionary> _lookup = new global::System.Collections.Generic.Dictionary>
+ {
+ {
+ typeof(global::MyNamespace.MyVo),
+ new global::System.Lazy(() => new global::MyNamespace.MyVo.MyVoSystemTextJsonConverter())
+ }
+ };
+ public override bool CanConvert(global::System.Type typeToConvert) => _lookup.ContainsKey(typeToConvert);
+ public override global::System.Text.Json.Serialization.JsonConverter CreateConverter(global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options) => _lookup[typeToConvert].Value;
+ }
+}
+
+// ------------------------------------------------------------------------------
+//
+// 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.
+//
+// ------------------------------------------------------------------------------
+// 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 or IComparable should override comparison operators
+#pragma warning disable MA0097
+// Suppress warning for 'The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source.'
+// The generator copies signatures from the BCL, e.g. for `TryParse`, and some of those have nullable annotations.
+#pragma warning disable CS8669, CS8632
+#pragma warning disable CS8604 // Possible null reference argument.
+
+// Suppress warnings about CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member'
+#pragma warning disable CS1591
+// Suppress warnings about CS8767 : Nullability of reference types in type of parameter doesn't match implicitly implemented member (possibly because of nullability attributes).
+#pragma warning disable CS8767
+namespace MyNamespace
+{
+ [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.Diagnostics.DebuggerTypeProxyAttribute(typeof(MyVoDebugView))]
+ [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: global::System.Int32, Value = { _value }")]
+ // ReSharper disable once UnusedType.Global
+ public partial struct MyVo : global::System.IEquatable, global::System.IEquatable, global::System.IComparable, global::System.IComparable, global::System.IParsable, global::System.ISpanParsable, global::System.IUtf8SpanParsable, global::System.IFormattable, global::System.ISpanFormattable, global::System.IUtf8SpanFormattable, global::System.IConvertible
+ {
+#if DEBUG
+private readonly global::System.Diagnostics.StackTrace _stackTrace = null!;
+#endif
+#if !VOGEN_NO_VALIDATION
+ private readonly global::System.Boolean _isInitialized;
+#endif
+ private readonly global::System.Int32 _value;
+ ///
+ /// Gets the underlying value if set, otherwise a is thrown.
+ ///
+ public readonly global::System.Int32 Value
+ {
+ [global::System.Diagnostics.DebuggerStepThroughAttribute]
+ [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+ 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
+#if !VOGEN_NO_VALIDATION
+ _isInitialized = false;
+#endif
+ _value = default;
+ }
+
+ [global::System.Diagnostics.DebuggerStepThroughAttribute]
+ private MyVo(global::System.Int32 value)
+ {
+ _value = value;
+#if !VOGEN_NO_VALIDATION
+ _isInitialized = true;
+#endif
+#if DEBUG
+ _stackTrace = null;
+#endif
+ }
+
+ ///
+ /// Builds an instance from the provided underlying type.
+ ///
+ /// The underlying type.
+ /// An instance of this type.
+ [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+ public static MyVo From(global::System.Int32 value)
+ {
+ return new MyVo(value);
+ }
+
+ ///
+ /// Tries to build an instance from the provided underlying type.
+ /// If a normalization method is provided, it will be called.
+ /// If validation is provided, and it fails, false will be returned.
+ ///
+ /// The underlying type.
+ /// An instance of the value object.
+ /// True if the value object can be built, otherwise false.
+ public static bool TryFrom(
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ global::System.Int32 value,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)]
+#endif
+ out MyVo vo)
+ {
+ vo = new MyVo(value);
+ return true;
+ }
+
+ ///
+ /// Tries to build an instance from the provided underlying value.
+ /// If a normalization method is provided, it will be called.
+ /// If validation is provided, and it fails, an error will be returned.
+ ///
+ /// The primitive value.
+ /// A containing either the value object, or an error.
+ public static global::Vogen.ValueObjectOrError TryFrom(global::System.Int32 value)
+ {
+ return new global::Vogen.ValueObjectOrError(new MyVo(value));
+ }
+
+ [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+#if VOGEN_NO_VALIDATION
+#pragma warning disable CS8775
+ public readonly bool IsInitialized() => true;
+#pragma warning restore CS8775
+#else
+ public readonly bool IsInitialized() => _isInitialized;
+#endif
+ public static explicit operator MyVo(global::System.Int32 value) => From(value);
+ public static explicit operator global::System.Int32(MyVo value) => value.Value;
+ // only called internally when something has been deserialized into
+ // its primitive type.
+ private static MyVo __Deserialize(global::System.Int32 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.Default.Equals(Value, other.Value);
+ }
+
+ public global::System.Boolean Equals(MyVo other, global::System.Collections.Generic.IEqualityComparer comparer)
+ {
+ return comparer.Equals(this, other);
+ }
+
+ public readonly global::System.Boolean Equals(global::System.Int32 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) => left.Equals(right);
+ public static global::System.Boolean operator !=(MyVo left, MyVo right) => !(left == right);
+ public static global::System.Boolean operator ==(MyVo left, global::System.Int32 right) => left.Value.Equals(right);
+ public static global::System.Boolean operator ==(global::System.Int32 left, MyVo right) => right.Value.Equals(left);
+ public static global::System.Boolean operator !=(global::System.Int32 left, MyVo right) => !(left == right);
+ public static global::System.Boolean operator !=(MyVo left, global::System.Int32 right) => !(left == right);
+ 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);
+ ThrowHelper.ThrowArgumentException("Cannot compare to object as it is not of type MyVo", nameof(other));
+ return 0;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(global::System.ReadOnlySpan utf8Text, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(utf8Text, style, provider, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(global::System.ReadOnlySpan utf8Text, global::System.IFormatProvider provider,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(utf8Text, provider, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(global::System.ReadOnlySpan utf8Text,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(utf8Text, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(global::System.ReadOnlySpan s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(s, style, provider, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(global::System.ReadOnlySpan s, global::System.IFormatProvider provider,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(s, provider, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(global::System.ReadOnlySpan s,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(s, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(string s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(s, style, provider, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(string s, global::System.IFormatProvider provider,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(s, provider, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// True if the value could a) be parsed by the underlying type, and b) passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(string s,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVo result)
+ {
+ if (global::System.Int32.TryParse(s, out var __v))
+ {
+ result = new MyVo(__v);
+ return true;
+ }
+
+ result = default;
+ return false;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(global::System.ReadOnlySpan utf8Text, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Int32.Parse(utf8Text, style, provider);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(global::System.ReadOnlySpan utf8Text, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Int32.Parse(utf8Text, provider);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(global::System.ReadOnlySpan s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Int32.Parse(s, style, provider);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(global::System.ReadOnlySpan s, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Int32.Parse(s, provider);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(string s)
+ {
+ var r = global::System.Int32.Parse(s);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(string s, global::System.Globalization.NumberStyles style)
+ {
+ var r = global::System.Int32.Parse(s, style);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(string s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Int32.Parse(s, style, provider);
+ return From(r);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ /// The value created by calling the Parse method on the primitive.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVo Parse(string s, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Int32.Parse(s, provider);
+ return From(r);
+ }
+
+#nullable disable
+ ///
+ public string ToString([System.Diagnostics.CodeAnalysis.StringSyntaxAttribute("NumericFormat")] string format, global::System.IFormatProvider provider)
+ {
+ return IsInitialized() ? Value.ToString(format, provider) : "[UNINITIALIZED]";
+ }
+
+ ///
+ public bool TryFormat(global::System.Span destination, out int charsWritten, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute("NumericFormat")] global::System.ReadOnlySpan