diff --git a/samples/WebApplication.Shared/WebApplication.Shared.csproj b/samples/WebApplication.Shared/WebApplication.Shared.csproj
index ecc70e7ec2..4655e6cba9 100644
--- a/samples/WebApplication.Shared/WebApplication.Shared.csproj
+++ b/samples/WebApplication.Shared/WebApplication.Shared.csproj
@@ -2,27 +2,40 @@
Library
- net8.0
enable
enable
- Swashbuckle
+ Swashbuckle-net8
true
+
+ net8.0
+ $(DefineConstants);USE_SWASHBUCKLE;USE_SWASHBUCKLE_NET8
+
+
+
+ net10.0
+ $(DefineConstants);USE_SWASHBUCKLE;USE_SWASHBUCKLE_NET10
+
+
- net9.0
- USE_MICROSOFT_OPENAPI_AND_SCALAR
+ net10.0
+ $(DefineConstants);USE_MICROSOFT_OPENAPI_AND_SCALAR
-
+
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/samples/WebApplication/OrdersController.cs b/samples/WebApplication/OrdersController.cs
index d3c9e890be..a8b254783a 100644
--- a/samples/WebApplication/OrdersController.cs
+++ b/samples/WebApplication/OrdersController.cs
@@ -1,4 +1,4 @@
-using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc;
[Route("api/[controller]")]
public class OrdersController : ControllerBase
@@ -10,21 +10,27 @@ public class OrdersController : ControllerBase
];
[HttpGet]
+ [Produces(typeof(IEnumerable))]
public IActionResult CurrentOrders()
{
return Ok(_orders);
}
[HttpGet, Route("customer/{customerName}")]
+ [Produces(typeof(IEnumerable))]
public IActionResult GetByName(CustomerName customerName)
{
return Ok(_orders.Where(o => o.CustomerName == customerName));
}
[HttpGet, Route("{orderId}")]
+ [Produces(typeof(Order))]
public IActionResult GetByOrderId(OrderId orderId)
{
- return Ok(_orders.Where(o => o.OrderId == orderId));
+ var order = _orders.SingleOrDefault(o => o.OrderId == orderId);
+ if (order == null)
+ return new NotFoundResult();
+ return Ok(order);
}
}
diff --git a/samples/WebApplication/Program.cs b/samples/WebApplication/Program.cs
index d7516e1e33..a800bef6df 100644
--- a/samples/WebApplication/Program.cs
+++ b/samples/WebApplication/Program.cs
@@ -1,16 +1,26 @@
#pragma warning disable ASPDEPR002
-using Microsoft.OpenApi;
using Vogen;
using WebApplication.Shared;
-#if USE_SWASHBUCKLE
- [assembly: VogenDefaults(openApiSchemaCustomizations: OpenApiSchemaCustomizations.GenerateSwashbuckleMappingExtensionMethod)]
+#if USE_SWASHBUCKLE_NET8
+using Microsoft.OpenApi.Any;
+using Microsoft.OpenApi.Models;
+
+[assembly: VogenDefaults(openApiSchemaCustomizations: OpenApiSchemaCustomizations.GenerateSwashbuckleMappingExtensionMethod)]
+#endif
+#if USE_SWASHBUCKLE_NET10
+using System.Text.Json.Nodes;
+using Microsoft.OpenApi;
+
+[assembly: VogenDefaults(openApiSchemaCustomizations: OpenApiSchemaCustomizations.GenerateSwashbuckleMappingExtensionMethod)]
#endif
#if USE_MICROSOFT_OPENAPI_AND_SCALAR
- using Microsoft.AspNetCore.OpenApi;
- using Scalar.AspNetCore;
- [assembly: VogenDefaults(openApiSchemaCustomizations: OpenApiSchemaCustomizations.GenerateOpenApiMappingExtensionMethod)]
+using Microsoft.AspNetCore.OpenApi;
+using Microsoft.OpenApi;
+using Scalar.AspNetCore;
+
+[assembly: VogenDefaults(openApiSchemaCustomizations: OpenApiSchemaCustomizations.GenerateOpenApiMappingExtensionMethod)]
#endif
@@ -116,7 +126,15 @@
{
var parameter = generatedOperation.Parameters?[0];
parameter?.Description = "The ID of the historical weather report (example only - always returns the same weather report)";
+
+#if USE_MICROSOFT_OPENAPI_AND_SCALAR
parameter?.Examples?.Add("example1", new OpenApiExample { Value = Guid.NewGuid().ToString() });
+#elif USE_SWASHBUCKLE_NET8
+ parameter?.Examples?.Add("example1", new OpenApiExample { Value = new OpenApiString(Guid.NewGuid().ToString()) });
+#elif USE_SWASHBUCKLE_NET10
+ parameter?.Examples?.Add("example1", new OpenApiExample() { Value = JsonValue.Create(Guid.NewGuid().ToString()) });
+#endif
+
return generatedOperation;
});
diff --git a/samples/WebApplication/README.md b/samples/WebApplication/README.md
index b442c9a7d8..17cf61fef4 100644
--- a/samples/WebApplication/README.md
+++ b/samples/WebApplication/README.md
@@ -1,4 +1,4 @@
-This is a sample web application. It shows how to use value objects
+This is a sample web application. It shows how to use value objects
in a web app.
In particular, it shows how to get Vogen to generate the necessary code to
@@ -7,9 +7,9 @@ customize the OpenAPI schema types for value object (e.g. `CustomerName` is a `s
The project can also be switched to use `Microsof.OpenApi` and 'Scalar'. This targets .NET9. This is merely here as
a placeholder. It was added to see if there was a way, similiar to Swashbuckle, to customize the schema types of
value objects. I haven't found a way to do that yet though as it's not as customizable as Swashbuckle.
-You can switch by changing `Swashbuckle` in the `.csproj` file. The other mode is
-`MicrosoftAndScalar` (and the other launch-setting is `https openapi and scalar`)
-`
+You can switch by changing `` in the `.csproj` file to `MicrosoftAndScalar`, `Swashbuckle-net8`,
+or `Swashbuckle-net10`.
+The launch settings for `MicrosoftAndScalar` is `https openapi and scalar`.
The companion project to this is `WebApplicationConsumer` which demonstrates how to consume an API that uses value
object as parameters.
\ No newline at end of file
diff --git a/samples/WebApplication/Types.cs b/samples/WebApplication/Types.cs
index 372d6d2961..44a45b3c63 100644
--- a/samples/WebApplication/Types.cs
+++ b/samples/WebApplication/Types.cs
@@ -1,4 +1,5 @@
-using Vogen;
+using Vogen;
+using WebApplication.Shared;
record WeatherForecast(ForecastDate Date, Centigrade TemperatureC, Farenheit TemperatureF, string? Summary, City City);
@@ -35,5 +36,8 @@ public class Order
public OrderId OrderId { get; init; }
public CustomerName CustomerName { get; init; } = CustomerName.From("");
+
+ public SharedStruct SharedStruct { get; init; }
+ public SharedStruct? SharedStructOrNull { get; init; }
}
diff --git a/samples/WebApplication/WebApplication.csproj b/samples/WebApplication/WebApplication.csproj
index aad1be2985..2a89a94da8 100644
--- a/samples/WebApplication/WebApplication.csproj
+++ b/samples/WebApplication/WebApplication.csproj
@@ -1,26 +1,29 @@
-
+
- net8.0
enable
enable
true
- MicrosoftAndScalar
+ Swashbuckle-net8
-
+
net8.0
- USE_SWASHBUCKLE
+ $(DefineConstants);USE_SWASHBUCKLE;USE_SWASHBUCKLE_NET8
+
+
+
+ net10.0
+ $(DefineConstants);USE_SWASHBUCKLE;USE_SWASHBUCKLE_NET10
net10.0
- USE_MICROSOFT_OPENAPI_AND_SCALAR
+ $(DefineConstants);USE_MICROSOFT_OPENAPI_AND_SCALAR
-
@@ -28,11 +31,16 @@
-
+
+
+
+
+
+
diff --git a/src/Vogen/GenerateCodeForAspNetCoreOpenApiSchema.cs b/src/Vogen/GenerateCodeForAspNetCoreOpenApiSchema.cs
index 31dd65a8a3..cba06acb24 100644
--- a/src/Vogen/GenerateCodeForAspNetCoreOpenApiSchema.cs
+++ b/src/Vogen/GenerateCodeForAspNetCoreOpenApiSchema.cs
@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Text;
@@ -17,6 +17,13 @@ internal static void WriteOpenApiExtensionMethodMapping(
VogenKnownSymbols knownSymbols,
string className)
{
+ var openApiVersion = OpenApiSchemaUtils.DetermineOpenApiVersionBeingUsed(knownSymbols);
+
+ if (!OpenApiSchemaUtils.IsOpenApiOptionsReferenced(knownSymbols) || openApiVersion is OpenApiVersionBeingUsed.None)
+ {
+ return;
+ }
+
var items = workItems.Select(eachItem =>
new Item
{
@@ -27,23 +34,14 @@ internal static void WriteOpenApiExtensionMethodMapping(
UnderlyingTypeFullName = eachItem.UnderlyingType.EscapedFullName()
}).ToList();
- OpenApiVersionBeingUsed v = IsOpenApi2xReferenced(knownSymbols) ? OpenApiVersionBeingUsed.TwoPlus :
- IsOpenApi1xReferenced(knownSymbols) ? OpenApiVersionBeingUsed.One : OpenApiVersionBeingUsed.None;
-
- if (v is OpenApiVersionBeingUsed.None)
- {
- return;
- }
-
- WriteOpenApiExtensionMethodMapping(context, items, knownSymbols, className, v);
+ WriteOpenApiExtensionMethodMapping(context, items, className, openApiVersion);
}
private static void WriteOpenApiExtensionMethodMapping(
SourceProductionContext context,
List- workItems,
- VogenKnownSymbols knownSymbols,
string className,
- OpenApiVersionBeingUsed v)
+ OpenApiVersionBeingUsed openApiVersion)
{
var sb = new StringBuilder();
@@ -66,7 +64,7 @@ private static void WriteOpenApiExtensionMethodMapping(
.Append(_indent, 2)
.AppendLine("{");
- MapWorkItemsForOpenApi(workItems, sb, v);
+ MapWorkItemsForOpenApi(workItems, sb, openApiVersion);
sb
.Append(_indent, 3)
@@ -139,21 +137,18 @@ private static void MapWorkItemsForOpenApi(IEnumerable
- workItems, StringBu
}
}
- private static bool IsOpenApi1xReferenced(VogenKnownSymbols vogenKnownSymbols) => vogenKnownSymbols.OpenApiOptions is not null;
- private static bool IsOpenApi2xReferenced(VogenKnownSymbols vogenKnownSymbols) => vogenKnownSymbols.JsonSchemaType is not null;
-
- enum OpenApiVersionBeingUsed
- {
- None,
- One,
- TwoPlus
- }
-
public static void WriteOpenApiSpecForMarkers(SourceProductionContext context,
List workItems,
VogenKnownSymbols knownSymbols,
ImmutableArray markerClasses)
{
+ var openApiVersion = OpenApiSchemaUtils.DetermineOpenApiVersionBeingUsed(knownSymbols);
+
+ if (!OpenApiSchemaUtils.IsOpenApiOptionsReferenced(knownSymbols) || openApiVersion is OpenApiVersionBeingUsed.None)
+ {
+ return;
+ }
+
foreach (MarkerClassDefinition eachMarkerClass in markerClasses)
{
var matchingMarkers = eachMarkerClass.AttributeDefinitions.Where(a => a.Marker?.Kind == ConversionMarkerKind.OpenApi).ToList();
@@ -176,9 +171,8 @@ public static void WriteOpenApiSpecForMarkers(SourceProductionContext context,
WriteOpenApiExtensionMethodMapping(
context,
items,
- knownSymbols,
$"MapVogenTypesIn{eachMarkerClass.MarkerClassSymbol.Name}",
- OpenApiVersionBeingUsed.TwoPlus);
+ openApiVersion);
}
}
}
\ No newline at end of file
diff --git a/src/Vogen/GenerateCodeForOpenApiSchemaCustomization.cs b/src/Vogen/GenerateCodeForOpenApiSchemaCustomization.cs
index 398fd35942..d5b07be7d0 100644
--- a/src/Vogen/GenerateCodeForOpenApiSchemaCustomization.cs
+++ b/src/Vogen/GenerateCodeForOpenApiSchemaCustomization.cs
@@ -1,3 +1,4 @@
+using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
@@ -9,6 +10,8 @@ namespace Vogen;
internal class GenerateCodeForOpenApiSchemaCustomization
{
+ private const char _indent = '\t'; // tab-level
+
public static void WriteIfNeeded(VogenConfiguration? globalConfig,
SourceProductionContext context,
List workItems,
@@ -16,10 +19,10 @@ public static void WriteIfNeeded(VogenConfiguration? globalConfig,
ImmutableArray markerClasses,
Compilation compilation)
{
- GenerateCodeForAspNetCoreOpenApiSchema
- .WriteOpenApiSpecForMarkers(context, workItems, knownSymbols, markerClasses);
+ GenerateCodeForAspNetCoreOpenApiSchema.WriteOpenApiSpecForMarkers(context, workItems, knownSymbols, markerClasses);
- var c = globalConfig?.OpenApiSchemaCustomizations ?? VogenConfiguration.DefaultInstance.OpenApiSchemaCustomizations;
+ var c = globalConfig?.OpenApiSchemaCustomizations ??
+ VogenConfiguration.DefaultInstance.OpenApiSchemaCustomizations;
var projectName = ProjectName.FromAssemblyName(compilation.Assembly.Name);
@@ -44,7 +47,7 @@ public static void WriteIfNeeded(VogenConfiguration? globalConfig,
private static void WriteSchemaFilter(SourceProductionContext context, VogenKnownSymbols knownSymbols, string inAppendage)
{
- if (!IsSwashbuckleReferenced(knownSymbols))
+ if (!OpenApiSchemaUtils.IsSwashbuckleReferenced(knownSymbols))
{
return;
}
@@ -118,9 +121,11 @@ private static void TryCopyPublicProperties(T oldObject, T newObject) where T
private static void WriteSwashbuckleExtensionMethodMapping(SourceProductionContext context,
List workItems,
VogenKnownSymbols knownSymbols,
- string inAppendage)
+ string className)
{
- if (!IsSwashbuckleReferenced(knownSymbols))
+ var openApiVersion = OpenApiSchemaUtils.DetermineOpenApiVersionBeingUsed(knownSymbols);
+
+ if (!OpenApiSchemaUtils.IsSwashbuckleReferenced(knownSymbols) || openApiVersion == OpenApiVersionBeingUsed.None)
{
return;
}
@@ -132,9 +137,9 @@ private static void WriteSwashbuckleExtensionMethodMapping(SourceProductionConte
public static class VogenSwashbuckleExtensions
{
- public static global::Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions MapVogenTypes{{inAppendage}}(this global::Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions o)
+ public static global::Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions {{className}}(this global::Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions o)
{
- {{MapWorkItems(workItems)}}
+ {{MapWorkItems(workItems, openApiVersion)}}
return o;
}
@@ -144,9 +149,7 @@ public static class VogenSwashbuckleExtensions
context.AddSource("SwashbuckleSchemaExtensions_g.cs", source);
}
- private static bool IsSwashbuckleReferenced(VogenKnownSymbols vogenKnownSymbols) => vogenKnownSymbols.SwaggerISchemaFilter is not null;
-
- private static string MapWorkItems(List workItems)
+ private static string MapWorkItems(List workItems, OpenApiVersionBeingUsed openApiVersion)
{
var sb = new StringBuilder();
@@ -160,18 +163,20 @@ private static string MapWorkItems(List workItems)
}).ToArray();
// map everything an non-nullable
- MapWorkItems(items, sb, false);
+ MapWorkItems(items, sb, false, openApiVersion);
// map value types again as nullable, see https://github.com/SteveDunn/Vogen/issues/693
- MapWorkItems(items.Where(i => i.IsTheWrapperAValueType), sb, true);
+ MapWorkItems(items.Where(i => i.IsTheWrapperAValueType), sb, true, openApiVersion);
return sb.ToString();
}
- private static void MapWorkItems(IEnumerable
- workItems, StringBuilder sb, bool nullable)
+ private static void MapWorkItems(IEnumerable
- workItems, StringBuilder sb, bool nullable,
+ OpenApiVersionBeingUsed openApiVersion)
{
foreach (var workItem in workItems)
{
+ sb.Append(_indent, 2);
string voTypeName = workItem.VoTypeName;
var fqn = string.IsNullOrEmpty(workItem.FullAliasedNamespace)
@@ -184,12 +189,32 @@ private static void MapWorkItems(IEnumerable
- workItems, StringBuilder sb,
}
TypeAndFormat typeAndPossibleFormat = MapUnderlyingTypeToJsonSchema(workItem);
- string typeText = $"Type = \"{typeAndPossibleFormat.Type}\"";
string formatText = typeAndPossibleFormat.Format.Length == 0 ? "" : $", Format = \"{typeAndPossibleFormat.Format}\"";
- string nullableText = $", Nullable = {nullable.ToString().ToLower()}";
- sb.AppendLine(
- $$"""global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType<{{fqn}}>(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { {{typeText}}{{formatText}}{{nullableText}} });""");
+ switch (openApiVersion)
+ {
+ case OpenApiVersionBeingUsed.One:
+ {
+ string typeText = $"Type = \"{typeAndPossibleFormat.Type}\"";
+ string nullableText = $", Nullable = {nullable.ToString().ToLower()}";
+
+ sb.AppendLine(
+ $$"""global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType<{{fqn}}>(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { {{typeText}}{{formatText}}{{nullableText}} });""");
+ break;
+ }
+ case OpenApiVersionBeingUsed.TwoPlus:
+ {
+ string typeText = $"Type = global::Microsoft.OpenApi.JsonSchemaType.{typeAndPossibleFormat.JsonSchemaType}";
+ if (nullable)
+ {
+ typeText += " | global::Microsoft.OpenApi.JsonSchemaType.Null";
+ }
+
+ sb.AppendLine(
+ $$"""global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType<{{fqn}}>(o, () => new global::Microsoft.OpenApi.OpenApiSchema { {{typeText}}{{formatText}} });""");
+ break;
+ }
+ }
}
}
@@ -212,9 +237,9 @@ internal static TypeAndFormat MapUnderlyingTypeToJsonSchema(Item workItem)
TypeAndFormat jsonType = primitiveType switch
{
"System.Int32" => new("integer", "Number", "int32"),
- "System.Int64" => new("integer", "Number","int64"),
- "System.Int16" => new("number", "Number",""),
- "System.Single" => new("number", "Number",""),
+ "System.Int64" => new("integer", "Number", "int64"),
+ "System.Int16" => new("number", "Number", ""),
+ "System.Single" => new("number", "Number", ""),
"System.Decimal" => new("number", "Number", "double"),
"System.Double" => new("number", "Number", "double"),
"System.String" => new("string", "String", ""),
diff --git a/src/Vogen/OpenApiSchemaUtils.cs b/src/Vogen/OpenApiSchemaUtils.cs
new file mode 100644
index 0000000000..9e3f9dac96
--- /dev/null
+++ b/src/Vogen/OpenApiSchemaUtils.cs
@@ -0,0 +1,25 @@
+namespace Vogen;
+
+internal static class OpenApiSchemaUtils
+{
+ public static bool IsSwashbuckleReferenced(VogenKnownSymbols vogenKnownSymbols) => vogenKnownSymbols.SwaggerISchemaFilter is not null;
+ public static bool IsOpenApiOptionsReferenced(VogenKnownSymbols vogenKnownSymbols) => vogenKnownSymbols.OpenApiOptions is not null;
+
+ private static bool IsOpenApi1xReferenced(VogenKnownSymbols vogenKnownSymbols) => vogenKnownSymbols.OpenApiSchemaV1 is not null;
+ private static bool IsOpenApi2xReferenced(VogenKnownSymbols vogenKnownSymbols) => vogenKnownSymbols.OpenApiSchemaV2 is not null;
+
+ public static OpenApiVersionBeingUsed DetermineOpenApiVersionBeingUsed(VogenKnownSymbols knownSymbols)
+ {
+ if (IsOpenApi2xReferenced(knownSymbols))
+ {
+ return OpenApiVersionBeingUsed.TwoPlus;
+ }
+
+ if (IsOpenApi1xReferenced(knownSymbols))
+ {
+ return OpenApiVersionBeingUsed.One;
+ }
+
+ return OpenApiVersionBeingUsed.None;
+ }
+}
\ No newline at end of file
diff --git a/src/Vogen/OpenApiVersionBeingUsed.cs b/src/Vogen/OpenApiVersionBeingUsed.cs
new file mode 100644
index 0000000000..c24a51aefb
--- /dev/null
+++ b/src/Vogen/OpenApiVersionBeingUsed.cs
@@ -0,0 +1,8 @@
+namespace Vogen;
+
+internal enum OpenApiVersionBeingUsed
+{
+ None,
+ One,
+ TwoPlus
+}
\ No newline at end of file
diff --git a/src/Vogen/VogenKnownSymbols.cs b/src/Vogen/VogenKnownSymbols.cs
index ac544b6fcd..3368d07082 100644
--- a/src/Vogen/VogenKnownSymbols.cs
+++ b/src/Vogen/VogenKnownSymbols.cs
@@ -1,4 +1,4 @@
-using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis;
// ReSharper disable InconsistentNaming
namespace Vogen;
@@ -20,6 +20,18 @@ public class VogenKnownSymbols(Compilation compilation) : KnownSymbols(compilati
public INamedTypeSymbol? OpenApiOptions => GetOrResolveType("Microsoft.AspNetCore.OpenApi.OpenApiOptions", ref _OpenApiOptions);
private Option _OpenApiOptions;
+ ///
+ /// OpenApiSchema from Microsoft.OpenApi namespace, as used in OpenApi v2+
+ ///
+ public INamedTypeSymbol? OpenApiSchemaV2 => GetOrResolveType("Microsoft.OpenApi.OpenApiSchema", ref _OpenApiSchemaV2Options);
+ private Option _OpenApiSchemaV2Options;
+
+ ///
+ /// OpenApiSchema from Microsoft.OpenApi.Models namespace, as used in OpenApi v1+
+ ///
+ public INamedTypeSymbol? OpenApiSchemaV1 => GetOrResolveType("Microsoft.OpenApi.Models.OpenApiSchema", ref _OpenApiSchemaV1Options);
+ private Option _OpenApiSchemaV1Options;
+
public INamedTypeSymbol? JsonSchemaType => GetOrResolveType("Microsoft.OpenApi.JsonSchemaType", ref _JsonSchemaType);
private Option _JsonSchemaType;
diff --git a/tests/Shared/ProjectBuilder.cs b/tests/Shared/ProjectBuilder.cs
index 69649f453a..acbbd7a32e 100644
--- a/tests/Shared/ProjectBuilder.cs
+++ b/tests/Shared/ProjectBuilder.cs
@@ -176,6 +176,16 @@ private void AddNuGetReferences()
AddNuGetReference("Microsoft.AspNetCore.OpenApi", "9.0.6", "lib/net9.0");
AddNuGetReference("Microsoft.OpenApi", "1.6.17", "lib/netstandard2.0/");
break;
+
+ case TargetFramework.AspNetCore10_0:
+ AddNuGetReference("Microsoft.NETCore.App.Ref", "10.0.0", "ref/net10.0/");
+ AddNuGetReference("Microsoft.AspNetCore.App.Ref", "10.0.0", "ref/net10.0/");
+ AddNuGetReference("Swashbuckle.AspNetCore.SwaggerGen", "10.0.0", "lib/net10.0/");
+ AddNuGetReference("MongoDB.Bson", "2.27.0", "lib/netstandard2.0");
+ AddNuGetReference("Microsoft.AspNetCore.OpenApi", "10.0.0", "lib/net10.0");
+ AddNuGetReference("Microsoft.OpenApi", "3.0.1", "lib/netstandard2.0/");
+ break;
+
case null:
break;
default:
diff --git a/tests/Shared/TargetFramework.cs b/tests/Shared/TargetFramework.cs
index f3dc50d0d1..d395c00c07 100644
--- a/tests/Shared/TargetFramework.cs
+++ b/tests/Shared/TargetFramework.cs
@@ -7,6 +7,7 @@ public enum TargetFramework
AspNetCore8_0,
Net9_0,
AspNetCore9_0,
- Latest = Net9_0
+ AspNetCore10_0,
+ Latest = Net9_0,
}
}
\ No newline at end of file
diff --git a/tests/SnapshotTests/BugFixes/snapshots/snap-vAspNetCore8.0/Bug604_Swashbuckle_has_missing_namespaces_for_the_vo.Test.verified.txt b/tests/SnapshotTests/BugFixes/snapshots/snap-vAspNetCore8.0/Bug604_Swashbuckle_has_missing_namespaces_for_the_vo.Test.verified.txt
index fad9c6a4db..bf347c998e 100644
--- a/tests/SnapshotTests/BugFixes/snapshots/snap-vAspNetCore8.0/Bug604_Swashbuckle_has_missing_namespaces_for_the_vo.Test.verified.txt
+++ b/tests/SnapshotTests/BugFixes/snapshots/snap-vAspNetCore8.0/Bug604_Swashbuckle_has_missing_namespaces_for_the_vo.Test.verified.txt
@@ -30,8 +30,8 @@ public static class VogenSwashbuckleExtensions
{
public static global::Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions MapVogenTypesMapVogenTypesIngenerator(this global::Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions o)
{
- global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "integer", Format = "int32", Nullable = false });
-global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType>(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "integer", Format = "int32", Nullable = true });
+ global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "integer", Format = "int32", Nullable = false });
+ global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType>(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "integer", Format = "int32", Nullable = true });
return o;
diff --git a/tests/SnapshotTests/BugFixes/snapshots/snap-vAspNetCore8.0/Bug608_swashbuckle_mappingTests.Used_to_treat_non_primitives_as_objects_but_now_treats_IParsable_as_strings.verified.txt b/tests/SnapshotTests/BugFixes/snapshots/snap-vAspNetCore8.0/Bug608_swashbuckle_mappingTests.Used_to_treat_non_primitives_as_objects_but_now_treats_IParsable_as_strings.verified.txt
index 8df970bce5..75121001fb 100644
--- a/tests/SnapshotTests/BugFixes/snapshots/snap-vAspNetCore8.0/Bug608_swashbuckle_mappingTests.Used_to_treat_non_primitives_as_objects_but_now_treats_IParsable_as_strings.verified.txt
+++ b/tests/SnapshotTests/BugFixes/snapshots/snap-vAspNetCore8.0/Bug608_swashbuckle_mappingTests.Used_to_treat_non_primitives_as_objects_but_now_treats_IParsable_as_strings.verified.txt
@@ -30,8 +30,8 @@ public static class VogenSwashbuckleExtensions
{
public static global::Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions MapVogenTypesMapVogenTypesIngenerator(this global::Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions o)
{
- global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "string", Format = "uuid", Nullable = false });
-global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType>(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "string", Format = "uuid", Nullable = true });
+ global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "string", Format = "uuid", Nullable = false });
+ global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType>(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "string", Format = "uuid", Nullable = true });
return o;
diff --git a/tests/SnapshotTests/BugFixes/snapshots/snap-vAspNetCore8.0/Bug610_Inconsistent_casting.Setting_implicit_casting_to_primitive_in_global_config_should_not_write_a_primitive_cast_to_wrapper.verified.txt b/tests/SnapshotTests/BugFixes/snapshots/snap-vAspNetCore8.0/Bug610_Inconsistent_casting.Setting_implicit_casting_to_primitive_in_global_config_should_not_write_a_primitive_cast_to_wrapper.verified.txt
index f3e6b44276..981dba18af 100644
--- a/tests/SnapshotTests/BugFixes/snapshots/snap-vAspNetCore8.0/Bug610_Inconsistent_casting.Setting_implicit_casting_to_primitive_in_global_config_should_not_write_a_primitive_cast_to_wrapper.verified.txt
+++ b/tests/SnapshotTests/BugFixes/snapshots/snap-vAspNetCore8.0/Bug610_Inconsistent_casting.Setting_implicit_casting_to_primitive_in_global_config_should_not_write_a_primitive_cast_to_wrapper.verified.txt
@@ -101,8 +101,8 @@ public static class VogenSwashbuckleExtensions
{
public static global::Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions MapVogenTypesMapVogenTypesIngenerator(this global::Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions o)
{
- global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "integer", Format = "int32", Nullable = false });
-global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType>(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "integer", Format = "int32", Nullable = true });
+ global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "integer", Format = "int32", Nullable = false });
+ global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType>(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "integer", Format = "int32", Nullable = true });
return o;
diff --git a/tests/SnapshotTests/BugFixes/snapshots/snap-vAspNetCore8.0/Bug720_Inconsistent_casting_mixed_with_IVogen_generation.Works_when_the_static_abstracts_and_implementation_have_same_casting.verified.txt b/tests/SnapshotTests/BugFixes/snapshots/snap-vAspNetCore8.0/Bug720_Inconsistent_casting_mixed_with_IVogen_generation.Works_when_the_static_abstracts_and_implementation_have_same_casting.verified.txt
index f7b926b96d..5f83476871 100644
--- a/tests/SnapshotTests/BugFixes/snapshots/snap-vAspNetCore8.0/Bug720_Inconsistent_casting_mixed_with_IVogen_generation.Works_when_the_static_abstracts_and_implementation_have_same_casting.verified.txt
+++ b/tests/SnapshotTests/BugFixes/snapshots/snap-vAspNetCore8.0/Bug720_Inconsistent_casting_mixed_with_IVogen_generation.Works_when_the_static_abstracts_and_implementation_have_same_casting.verified.txt
@@ -101,8 +101,8 @@ public static class VogenSwashbuckleExtensions
{
public static global::Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions MapVogenTypesMapVogenTypesIngenerator(this global::Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions o)
{
- global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "integer", Format = "int32", Nullable = false });
-global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType>(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "integer", Format = "int32", Nullable = true });
+ global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "integer", Format = "int32", Nullable = false });
+ global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType>(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "integer", Format = "int32", Nullable = true });
return o;
diff --git a/tests/SnapshotTests/GeneralStuff/snapshots/snap-vAspNetCore8.0/GeneralTests.Can_specify_both_swashbuckle_filter_and_MapType_extension_method_generation_for_openapi.verified.txt b/tests/SnapshotTests/GeneralStuff/snapshots/snap-vAspNetCore8.0/GeneralTests.Can_specify_both_swashbuckle_filter_and_MapType_extension_method_generation_for_openapi.verified.txt
index cbfc2c65e5..b9ac65ce69 100644
--- a/tests/SnapshotTests/GeneralStuff/snapshots/snap-vAspNetCore8.0/GeneralTests.Can_specify_both_swashbuckle_filter_and_MapType_extension_method_generation_for_openapi.verified.txt
+++ b/tests/SnapshotTests/GeneralStuff/snapshots/snap-vAspNetCore8.0/GeneralTests.Can_specify_both_swashbuckle_filter_and_MapType_extension_method_generation_for_openapi.verified.txt
@@ -101,12 +101,12 @@ public static class VogenSwashbuckleExtensions
{
public static global::Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions MapVogenTypesMapVogenTypesIngenerator(this global::Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions o)
{
- global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "integer", Format = "int32", Nullable = false });
-global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "number", Nullable = false });
-global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "number", Format = "double", Nullable = false });
-global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "number", Format = "double", Nullable = false });
-global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "string", Nullable = false });
-global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "boolean", Nullable = false });
+ global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "integer", Format = "int32", Nullable = false });
+ global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "number", Nullable = false });
+ global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "number", Format = "double", Nullable = false });
+ global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "number", Format = "double", Nullable = false });
+ global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "string", Nullable = false });
+ global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "boolean", Nullable = false });
return o;
diff --git a/tests/SnapshotTests/GeneralStuff/snapshots/snap-vAspNetCore8.0/GeneralTests.Can_specify_swashbuckle_MapType_extension_method_generation_for_openapi.verified.txt b/tests/SnapshotTests/GeneralStuff/snapshots/snap-vAspNetCore8.0/GeneralTests.Can_specify_swashbuckle_MapType_extension_method_generation_for_openapi.verified.txt
index 1a62be45e3..ebdf55e903 100644
--- a/tests/SnapshotTests/GeneralStuff/snapshots/snap-vAspNetCore8.0/GeneralTests.Can_specify_swashbuckle_MapType_extension_method_generation_for_openapi.verified.txt
+++ b/tests/SnapshotTests/GeneralStuff/snapshots/snap-vAspNetCore8.0/GeneralTests.Can_specify_swashbuckle_MapType_extension_method_generation_for_openapi.verified.txt
@@ -30,12 +30,12 @@ public static class VogenSwashbuckleExtensions
{
public static global::Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions MapVogenTypesMapVogenTypesIngenerator(this global::Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions o)
{
- global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "integer", Format = "int32", Nullable = false });
-global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "number", Nullable = false });
-global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "number", Format = "double", Nullable = false });
-global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "number", Format = "double", Nullable = false });
-global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "string", Nullable = false });
-global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "boolean", Nullable = false });
+ global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "integer", Format = "int32", Nullable = false });
+ global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "number", Nullable = false });
+ global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "number", Format = "double", Nullable = false });
+ global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "number", Format = "double", Nullable = false });
+ global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "string", Nullable = false });
+ global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.Models.OpenApiSchema { Type = "boolean", Nullable = false });
return o;
diff --git a/tests/SnapshotTests/OpenApi/OpenApiTests.cs b/tests/SnapshotTests/OpenApi/OpenApiTests.cs
index e5d139c727..b811f1726a 100644
--- a/tests/SnapshotTests/OpenApi/OpenApiTests.cs
+++ b/tests/SnapshotTests/OpenApi/OpenApiTests.cs
@@ -53,10 +53,13 @@ public partial class MyVoShort { }
}
[Theory]
- [InlineData("")]
- [InlineData("namespace MyNamespace;")]
- [InlineData("namespace @double;")]
- public async Task Generates_both_OpenApiMappingExtensionMethod_SwaggerMappingExtensionMethod(string @namespace)
+ [InlineData("", TargetFramework.AspNetCore9_0)]
+ [InlineData("namespace MyNamespace;", TargetFramework.AspNetCore9_0)]
+ [InlineData("namespace @double;", TargetFramework.AspNetCore9_0)]
+ [InlineData("", TargetFramework.AspNetCore10_0)]
+ [InlineData("namespace MyNamespace;", TargetFramework.AspNetCore10_0)]
+ [InlineData("namespace @double;", TargetFramework.AspNetCore10_0)]
+ public async Task Generates_both_OpenApiMappingExtensionMethod_SwaggerMappingExtensionMethod(string @namespace, TargetFramework targetFramework)
{
var source =
$$"""
@@ -97,7 +100,7 @@ public partial class MyVoShort { }
await new SnapshotRunner()
.WithSource(source)
.CustomizeSettings(s => s.UseHashedParameters(@namespace))
- .RunOn(TargetFramework.AspNetCore9_0);
+ .RunOn(targetFramework);
}
[Theory]
diff --git a/tests/SnapshotTests/OpenApi/snapshots/snap-vAspNetCore10.0/OpenApiTests.Generates_both_OpenApiMappingExtensionMethod_SwaggerMappingExtensionMethod_32176bb7ed8221dd.verified.txt b/tests/SnapshotTests/OpenApi/snapshots/snap-vAspNetCore10.0/OpenApiTests.Generates_both_OpenApiMappingExtensionMethod_SwaggerMappingExtensionMethod_32176bb7ed8221dd.verified.txt
new file mode 100644
index 0000000000..2c2f6c9ff6
--- /dev/null
+++ b/tests/SnapshotTests/OpenApi/snapshots/snap-vAspNetCore10.0/OpenApiTests.Generates_both_OpenApiMappingExtensionMethod_SwaggerMappingExtensionMethod_32176bb7ed8221dd.verified.txt
@@ -0,0 +1,5094 @@
+[
+// ------------------------------------------------------------------------------
+//
+// 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
+
+public static class VogenSwashbuckleExtensions
+{
+ public static global::Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions MapVogenTypesIngenerator(this global::Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions o)
+ {
+ global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.OpenApiSchema { Type = global::Microsoft.OpenApi.JsonSchemaType.Number, Format = "int32" });
+ global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.OpenApiSchema { Type = global::Microsoft.OpenApi.JsonSchemaType.Number });
+ global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.OpenApiSchema { Type = global::Microsoft.OpenApi.JsonSchemaType.Number, Format = "double" });
+ global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.OpenApiSchema { Type = global::Microsoft.OpenApi.JsonSchemaType.Number, Format = "double" });
+ global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.OpenApiSchema { Type = global::Microsoft.OpenApi.JsonSchemaType.String });
+ global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.OpenApiSchema { Type = global::Microsoft.OpenApi.JsonSchemaType.Boolean });
+ global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.OpenApiSchema { Type = global::Microsoft.OpenApi.JsonSchemaType.Boolean });
+ global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(o, () => new global::Microsoft.OpenApi.OpenApiSchema { Type = global::Microsoft.OpenApi.JsonSchemaType.Number });
+
+
+ return o;
+ }
+}
+
+// ------------------------------------------------------------------------------
+//
+// 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
+
+public static class VogenOpenApiExtensions
+{
+ public static global::Microsoft.AspNetCore.OpenApi.OpenApiOptions MapVogenTypesIngenerator(this global::Microsoft.AspNetCore.OpenApi.OpenApiOptions options)
+ {
+ options.AddSchemaTransformer((schema, context, cancellationToken) =>
+ {
+ if (context.JsonTypeInfo.Type == typeof(global::@double.MyVoInt))
+ {
+ schema.Type = Microsoft.OpenApi.JsonSchemaType.Number;
+ schema.Format = "int32";
+ }
+
+ if (context.JsonTypeInfo.Type == typeof(global::@double.MyVoFloat))
+ {
+ schema.Type = Microsoft.OpenApi.JsonSchemaType.Number;
+ }
+
+ if (context.JsonTypeInfo.Type == typeof(global::@double.MyVoDecimal))
+ {
+ schema.Type = Microsoft.OpenApi.JsonSchemaType.Number;
+ schema.Format = "double";
+ }
+
+ if (context.JsonTypeInfo.Type == typeof(global::@double.MyVoDouble))
+ {
+ schema.Type = Microsoft.OpenApi.JsonSchemaType.Number;
+ schema.Format = "double";
+ }
+
+ if (context.JsonTypeInfo.Type == typeof(global::@double.MyVoString))
+ {
+ schema.Type = Microsoft.OpenApi.JsonSchemaType.String;
+ }
+
+ if (context.JsonTypeInfo.Type == typeof(global::@double.MyVoBool))
+ {
+ schema.Type = Microsoft.OpenApi.JsonSchemaType.Boolean;
+ }
+
+ if (context.JsonTypeInfo.Type == typeof(global::@double.@bool))
+ {
+ schema.Type = Microsoft.OpenApi.JsonSchemaType.Boolean;
+ }
+
+ if (context.JsonTypeInfo.Type == typeof(global::@double.MyVoShort))
+ {
+ schema.Type = Microsoft.OpenApi.JsonSchemaType.Number;
+ }
+
+ return global::System.Threading.Tasks.Task.CompletedTask;
+ });
+
+ return options;
+ }
+}
+
+
+// ------------------------------------------------------------------------------
+//
+// 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
+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(global::@double.MyVoInt),
+ new global::System.Lazy(() => new global::@double.MyVoInt.MyVoIntSystemTextJsonConverter())
+ },
+ {
+ typeof(global::@double.MyVoFloat),
+ new global::System.Lazy(() => new global::@double.MyVoFloat.MyVoFloatSystemTextJsonConverter())
+ },
+ {
+ typeof(global::@double.MyVoDecimal),
+ new global::System.Lazy(() => new global::@double.MyVoDecimal.MyVoDecimalSystemTextJsonConverter())
+ },
+ {
+ typeof(global::@double.MyVoDouble),
+ new global::System.Lazy(() => new global::@double.MyVoDouble.MyVoDoubleSystemTextJsonConverter())
+ },
+ {
+ typeof(global::@double.MyVoString),
+ new global::System.Lazy(() => new global::@double.MyVoString.MyVoStringSystemTextJsonConverter())
+ },
+ {
+ typeof(global::@double.MyVoBool),
+ new global::System.Lazy(() => new global::@double.MyVoBool.MyVoBoolSystemTextJsonConverter())
+ },
+ {
+ typeof(global::@double.@bool),
+ new global::System.Lazy(() => new global::@double.@bool.@boolSystemTextJsonConverter())
+ },
+ {
+ typeof(global::@double.MyVoShort),
+ new global::System.Lazy(() => new global::@double.MyVoShort.MyVoShortSystemTextJsonConverter())
+ }
+ };
+ 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
+namespace @double
+{
+ [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
+ [global::System.Text.Json.Serialization.JsonConverter(typeof(MyVoIntSystemTextJsonConverter))]
+ [global::System.ComponentModel.TypeConverter(typeof(MyVoIntTypeConverter))]
+ [global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(MyVoIntDebugView))]
+ [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.Int32, Value = { _value }")]
+ public partial class MyVoInt : 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
+ {
+#if DEBUG
+private readonly global::System.Diagnostics.StackTrace _stackTrace = null!;
+#endif
+#if !VOGEN_NO_VALIDATION
+ private readonly global::System.Boolean _isInitialized;
+#endif
+ private readonly System.Int32 _value;
+ ///
+ /// Gets the underlying value if set, otherwise a is thrown.
+ ///
+ public 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 MyVoInt()
+ {
+#if DEBUG
+ _stackTrace = new global::System.Diagnostics.StackTrace();
+#endif
+#if !VOGEN_NO_VALIDATION
+ _isInitialized = false;
+#endif
+ _value = default;
+ }
+
+ [global::System.Diagnostics.DebuggerStepThroughAttribute]
+ private MyVoInt(System.Int32 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 MyVoInt From(System.Int32 value)
+ {
+ return new MyVoInt(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.
+
+#pragma warning disable CS8767 // Nullability of reference types in type of parameter doesn't match implicitly implemented member because of nullability attributes.
+
+ public static bool TryFrom(
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ System.Int32 value,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)]
+#endif
+ out MyVoInt vo)
+#pragma warning restore CS8767 // Nullability of reference types in type of parameter doesn't match implicitly implemented member because of nullability attributes.
+
+ {
+ vo = new MyVoInt(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 Vogen.ValueObjectOrError TryFrom(System.Int32 value)
+ {
+ return new Vogen.ValueObjectOrError(new MyVoInt(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 MyVoInt __Deserialize(System.Int32 value)
+ {
+ return new MyVoInt(value);
+ }
+
+ public global::System.Boolean Equals(MyVoInt 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(MyVoInt other, global::System.Collections.Generic.IEqualityComparer comparer)
+ {
+ return comparer.Equals(this, other);
+ }
+
+ public global::System.Boolean Equals(System.Int32 primitive)
+ {
+ return Value.Equals(primitive);
+ }
+
+ public override global::System.Boolean Equals(global::System.Object obj)
+ {
+ return Equals(obj as MyVoInt);
+ }
+
+ public static global::System.Boolean operator ==(MyVoInt left, MyVoInt right) => Equals(left, right);
+ public static global::System.Boolean operator !=(MyVoInt left, MyVoInt right) => !Equals(left, right);
+ public static global::System.Boolean operator ==(MyVoInt left, System.Int32 right) => left.Value.Equals(right);
+ public static global::System.Boolean operator ==(System.Int32 left, MyVoInt right) => right.Value.Equals(left);
+ public static global::System.Boolean operator !=(System.Int32 left, MyVoInt right) => !(left == right);
+ public static global::System.Boolean operator !=(MyVoInt left, System.Int32 right) => !(left == right);
+ public static explicit operator MyVoInt(System.Int32 value) => From(value);
+ public static explicit operator System.Int32(MyVoInt value) => value.Value;
+ public int CompareTo(MyVoInt other)
+ {
+ if (other is null)
+ return 1;
+ return Value.CompareTo(other.Value);
+ }
+
+ public int CompareTo(object other)
+ {
+ if (other is null)
+ return 1;
+ if (other is MyVoInt x)
+ return CompareTo(x);
+ ThrowHelper.ThrowArgumentException("Cannot compare to object as it is not of type MyVoInt", 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 MyVoInt result)
+ {
+ if (global::System.Int32.TryParse(utf8Text, style, provider, out var __v))
+ {
+ result = new MyVoInt(__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 MyVoInt result)
+ {
+ if (global::System.Int32.TryParse(utf8Text, provider, out var __v))
+ {
+ result = new MyVoInt(__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 MyVoInt result)
+ {
+ if (global::System.Int32.TryParse(utf8Text, out var __v))
+ {
+ result = new MyVoInt(__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 MyVoInt result)
+ {
+ if (global::System.Int32.TryParse(s, style, provider, out var __v))
+ {
+ result = new MyVoInt(__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 MyVoInt result)
+ {
+ if (global::System.Int32.TryParse(s, provider, out var __v))
+ {
+ result = new MyVoInt(__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 MyVoInt result)
+ {
+ if (global::System.Int32.TryParse(s, out var __v))
+ {
+ result = new MyVoInt(__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 MyVoInt result)
+ {
+ if (global::System.Int32.TryParse(s, style, provider, out var __v))
+ {
+ result = new MyVoInt(__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 MyVoInt result)
+ {
+ if (global::System.Int32.TryParse(s, provider, out var __v))
+ {
+ result = new MyVoInt(__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 MyVoInt result)
+ {
+ if (global::System.Int32.TryParse(s, out var __v))
+ {
+ result = new MyVoInt(__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 MyVoInt 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 MyVoInt 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 MyVoInt 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 MyVoInt 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 MyVoInt 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 MyVoInt 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 MyVoInt 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 MyVoInt 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
+ 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;
+ }
+ }
+
+ ///
+ 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 void EnsureInitialized()
+ {
+ if (!IsInitialized())
+ {
+#if DEBUG
+ ThrowHelper.ThrowWhenNotInitialized(_stackTrace);
+#else
+ ThrowHelper.ThrowWhenNotInitialized();
+#endif
+ }
+ }
+
+#nullable disable
+ ///
+ /// Converts a MyVoInt to or from JSON.
+ ///
+ public partial class MyVoIntSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter
+ {
+ public override MyVoInt 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(System.Text.Json.Utf8JsonWriter writer, MyVoInt 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 MyVoInt 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(System.Text.Json.Utf8JsonWriter writer, MyVoInt 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(Vogen.Validation validation)
+ {
+ var e = ThrowHelper.CreateValidationException(validation);
+ throw new global::System.Text.Json.JsonException(null, e);
+ }
+
+ private static MyVoInt DeserializeJson(System.Int32 value)
+ {
+ return new MyVoInt(value);
+ }
+ }
+
+#nullable restore
+#nullable disable
+ class MyVoIntTypeConverter : 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 => MyVoInt.__Deserialize(intValue),
+ global::System.String stringValue when !global::System.String.IsNullOrEmpty(stringValue) && global::System.Int32.TryParse(stringValue, out var result) => MyVoInt.__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 MyVoInt 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
+ internal sealed class MyVoIntDebugView
+ {
+ private readonly MyVoInt _t;
+ MyVoIntDebugView(MyVoInt t)
+ {
+ _t = t;
+ }
+
+ public global::System.String UnderlyingType => "System.Int32";
+ public System.Int32 Value => _t.Value;
+ public global::System.String Conversions => @"[global::System.Text.Json.Serialization.JsonConverter(typeof(MyVoIntSystemTextJsonConverter))]
+[global::System.ComponentModel.TypeConverter(typeof(MyVoIntTypeConverter))]
+";
+ }
+
+ 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(Vogen.Validation validation)
+ {
+ throw CreateValidationException(validation);
+ }
+
+ internal static System.Exception CreateValidationException(string message) => new global::Vogen.ValueObjectValidationException(message);
+ internal static System.Exception CreateCannotBeNullException() => new global::Vogen.ValueObjectValidationException("Cannot create a value object with null.");
+ internal static System.Exception CreateValidationException(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;
+ }
+ }
+ }
+}
+
+// ------------------------------------------------------------------------------
+//
+// 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
+namespace @double
+{
+ [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
+ [global::System.Text.Json.Serialization.JsonConverter(typeof(MyVoFloatSystemTextJsonConverter))]
+ [global::System.ComponentModel.TypeConverter(typeof(MyVoFloatTypeConverter))]
+ [global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(MyVoFloatDebugView))]
+ [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.Single, Value = { _value }")]
+ public partial class MyVoFloat : 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
+ {
+#if DEBUG
+private readonly global::System.Diagnostics.StackTrace _stackTrace = null!;
+#endif
+#if !VOGEN_NO_VALIDATION
+ private readonly global::System.Boolean _isInitialized;
+#endif
+ private readonly System.Single _value;
+ ///
+ /// Gets the underlying value if set, otherwise a is thrown.
+ ///
+ public System.Single 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 MyVoFloat()
+ {
+#if DEBUG
+ _stackTrace = new global::System.Diagnostics.StackTrace();
+#endif
+#if !VOGEN_NO_VALIDATION
+ _isInitialized = false;
+#endif
+ _value = default;
+ }
+
+ [global::System.Diagnostics.DebuggerStepThroughAttribute]
+ private MyVoFloat(System.Single 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 MyVoFloat From(System.Single value)
+ {
+ return new MyVoFloat(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.
+
+#pragma warning disable CS8767 // Nullability of reference types in type of parameter doesn't match implicitly implemented member because of nullability attributes.
+
+ public static bool TryFrom(
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ System.Single value,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)]
+#endif
+ out MyVoFloat vo)
+#pragma warning restore CS8767 // Nullability of reference types in type of parameter doesn't match implicitly implemented member because of nullability attributes.
+
+ {
+ vo = new MyVoFloat(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 Vogen.ValueObjectOrError TryFrom(System.Single value)
+ {
+ return new Vogen.ValueObjectOrError(new MyVoFloat(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 MyVoFloat __Deserialize(System.Single value)
+ {
+ return new MyVoFloat(value);
+ }
+
+ public global::System.Boolean Equals(MyVoFloat 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(MyVoFloat other, global::System.Collections.Generic.IEqualityComparer comparer)
+ {
+ return comparer.Equals(this, other);
+ }
+
+ public global::System.Boolean Equals(System.Single primitive)
+ {
+ return Value.Equals(primitive);
+ }
+
+ public override global::System.Boolean Equals(global::System.Object obj)
+ {
+ return Equals(obj as MyVoFloat);
+ }
+
+ public static global::System.Boolean operator ==(MyVoFloat left, MyVoFloat right) => Equals(left, right);
+ public static global::System.Boolean operator !=(MyVoFloat left, MyVoFloat right) => !Equals(left, right);
+ public static global::System.Boolean operator ==(MyVoFloat left, System.Single right) => left.Value.Equals(right);
+ public static global::System.Boolean operator ==(System.Single left, MyVoFloat right) => right.Value.Equals(left);
+ public static global::System.Boolean operator !=(System.Single left, MyVoFloat right) => !(left == right);
+ public static global::System.Boolean operator !=(MyVoFloat left, System.Single right) => !(left == right);
+ public static explicit operator MyVoFloat(System.Single value) => From(value);
+ public static explicit operator System.Single(MyVoFloat value) => value.Value;
+ public int CompareTo(MyVoFloat other)
+ {
+ if (other is null)
+ return 1;
+ return Value.CompareTo(other.Value);
+ }
+
+ public int CompareTo(object other)
+ {
+ if (other is null)
+ return 1;
+ if (other is MyVoFloat x)
+ return CompareTo(x);
+ ThrowHelper.ThrowArgumentException("Cannot compare to object as it is not of type MyVoFloat", 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 MyVoFloat result)
+ {
+ if (global::System.Single.TryParse(utf8Text, style, provider, out var __v))
+ {
+ result = new MyVoFloat(__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 MyVoFloat result)
+ {
+ if (global::System.Single.TryParse(utf8Text, provider, out var __v))
+ {
+ result = new MyVoFloat(__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 MyVoFloat result)
+ {
+ if (global::System.Single.TryParse(utf8Text, out var __v))
+ {
+ result = new MyVoFloat(__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 MyVoFloat result)
+ {
+ if (global::System.Single.TryParse(s, style, provider, out var __v))
+ {
+ result = new MyVoFloat(__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 MyVoFloat result)
+ {
+ if (global::System.Single.TryParse(s, provider, out var __v))
+ {
+ result = new MyVoFloat(__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 MyVoFloat result)
+ {
+ if (global::System.Single.TryParse(s, out var __v))
+ {
+ result = new MyVoFloat(__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 MyVoFloat result)
+ {
+ if (global::System.Single.TryParse(s, style, provider, out var __v))
+ {
+ result = new MyVoFloat(__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 MyVoFloat result)
+ {
+ if (global::System.Single.TryParse(s, provider, out var __v))
+ {
+ result = new MyVoFloat(__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 MyVoFloat result)
+ {
+ if (global::System.Single.TryParse(s, out var __v))
+ {
+ result = new MyVoFloat(__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 MyVoFloat Parse(global::System.ReadOnlySpan utf8Text, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Single.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 MyVoFloat Parse(global::System.ReadOnlySpan utf8Text, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Single.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 MyVoFloat Parse(global::System.ReadOnlySpan s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Single.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 MyVoFloat Parse(global::System.ReadOnlySpan s, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Single.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 MyVoFloat Parse(string s)
+ {
+ var r = global::System.Single.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 MyVoFloat Parse(string s, global::System.Globalization.NumberStyles style)
+ {
+ var r = global::System.Single.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 MyVoFloat Parse(string s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Single.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 MyVoFloat Parse(string s, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Single.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
+ 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;
+ }
+ }
+
+ ///
+ 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 void EnsureInitialized()
+ {
+ if (!IsInitialized())
+ {
+#if DEBUG
+ ThrowHelper.ThrowWhenNotInitialized(_stackTrace);
+#else
+ ThrowHelper.ThrowWhenNotInitialized();
+#endif
+ }
+ }
+
+#nullable disable
+ ///
+ /// Converts a MyVoFloat to or from JSON.
+ ///
+ public partial class MyVoFloatSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter
+ {
+ public override MyVoFloat 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.Single))));
+#else
+ return DeserializeJson(reader.GetSingle());
+#endif
+ }
+
+ public override void Write(System.Text.Json.Utf8JsonWriter writer, MyVoFloat 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 MyVoFloat ReadAsPropertyName(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
+ {
+ return DeserializeJson(global::System.Single.Parse(reader.GetString(), global::System.Globalization.NumberStyles.Any, global::System.Globalization.CultureInfo.InvariantCulture));
+ }
+
+ public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, MyVoFloat 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(Vogen.Validation validation)
+ {
+ var e = ThrowHelper.CreateValidationException(validation);
+ throw new global::System.Text.Json.JsonException(null, e);
+ }
+
+ private static MyVoFloat DeserializeJson(System.Single value)
+ {
+ return new MyVoFloat(value);
+ }
+ }
+
+#nullable restore
+#nullable disable
+ class MyVoFloatTypeConverter : global::System.ComponentModel.TypeConverter
+ {
+ public override global::System.Boolean CanConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType)
+ {
+ return sourceType == typeof(global::System.Single) || 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.Single floatValue => MyVoFloat.__Deserialize(floatValue),
+ global::System.String stringValue when !global::System.String.IsNullOrEmpty(stringValue) && global::System.Single.TryParse(stringValue, global::System.Globalization.NumberStyles.Float | global::System.Globalization.NumberStyles.AllowThousands, culture.NumberFormat, out var result) => MyVoFloat.__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.Single) || 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 MyVoFloat idValue)
+ {
+ if (destinationType == typeof(global::System.Single))
+ {
+ return idValue.Value;
+ }
+
+ if (destinationType == typeof(global::System.String))
+ {
+ return idValue.Value.ToString(culture);
+ }
+ }
+
+ return base.ConvertTo(context, culture, value, destinationType);
+ }
+ }
+
+#nullable restore
+ internal sealed class MyVoFloatDebugView
+ {
+ private readonly MyVoFloat _t;
+ MyVoFloatDebugView(MyVoFloat t)
+ {
+ _t = t;
+ }
+
+ public global::System.String UnderlyingType => "System.Single";
+ public System.Single Value => _t.Value;
+ public global::System.String Conversions => @"[global::System.Text.Json.Serialization.JsonConverter(typeof(MyVoFloatSystemTextJsonConverter))]
+[global::System.ComponentModel.TypeConverter(typeof(MyVoFloatTypeConverter))]
+";
+ }
+
+ 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(Vogen.Validation validation)
+ {
+ throw CreateValidationException(validation);
+ }
+
+ internal static System.Exception CreateValidationException(string message) => new global::Vogen.ValueObjectValidationException(message);
+ internal static System.Exception CreateCannotBeNullException() => new global::Vogen.ValueObjectValidationException("Cannot create a value object with null.");
+ internal static System.Exception CreateValidationException(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;
+ }
+ }
+ }
+}
+
+// ------------------------------------------------------------------------------
+//
+// 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
+namespace @double
+{
+ [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
+ [global::System.Text.Json.Serialization.JsonConverter(typeof(MyVoDecimalSystemTextJsonConverter))]
+ [global::System.ComponentModel.TypeConverter(typeof(MyVoDecimalTypeConverter))]
+ [global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(MyVoDecimalDebugView))]
+ [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.Decimal, Value = { _value }")]
+ public partial class MyVoDecimal : 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
+ {
+#if DEBUG
+private readonly global::System.Diagnostics.StackTrace _stackTrace = null!;
+#endif
+#if !VOGEN_NO_VALIDATION
+ private readonly global::System.Boolean _isInitialized;
+#endif
+ private readonly System.Decimal _value;
+ ///
+ /// Gets the underlying value if set, otherwise a is thrown.
+ ///
+ public System.Decimal 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 MyVoDecimal()
+ {
+#if DEBUG
+ _stackTrace = new global::System.Diagnostics.StackTrace();
+#endif
+#if !VOGEN_NO_VALIDATION
+ _isInitialized = false;
+#endif
+ _value = default;
+ }
+
+ [global::System.Diagnostics.DebuggerStepThroughAttribute]
+ private MyVoDecimal(System.Decimal 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 MyVoDecimal From(System.Decimal value)
+ {
+ return new MyVoDecimal(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.
+
+#pragma warning disable CS8767 // Nullability of reference types in type of parameter doesn't match implicitly implemented member because of nullability attributes.
+
+ public static bool TryFrom(
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ System.Decimal value,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)]
+#endif
+ out MyVoDecimal vo)
+#pragma warning restore CS8767 // Nullability of reference types in type of parameter doesn't match implicitly implemented member because of nullability attributes.
+
+ {
+ vo = new MyVoDecimal(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 Vogen.ValueObjectOrError TryFrom(System.Decimal value)
+ {
+ return new Vogen.ValueObjectOrError(new MyVoDecimal(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 MyVoDecimal __Deserialize(System.Decimal value)
+ {
+ return new MyVoDecimal(value);
+ }
+
+ public global::System.Boolean Equals(MyVoDecimal 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(MyVoDecimal other, global::System.Collections.Generic.IEqualityComparer comparer)
+ {
+ return comparer.Equals(this, other);
+ }
+
+ public global::System.Boolean Equals(System.Decimal primitive)
+ {
+ return Value.Equals(primitive);
+ }
+
+ public override global::System.Boolean Equals(global::System.Object obj)
+ {
+ return Equals(obj as MyVoDecimal);
+ }
+
+ public static global::System.Boolean operator ==(MyVoDecimal left, MyVoDecimal right) => Equals(left, right);
+ public static global::System.Boolean operator !=(MyVoDecimal left, MyVoDecimal right) => !Equals(left, right);
+ public static global::System.Boolean operator ==(MyVoDecimal left, System.Decimal right) => left.Value.Equals(right);
+ public static global::System.Boolean operator ==(System.Decimal left, MyVoDecimal right) => right.Value.Equals(left);
+ public static global::System.Boolean operator !=(System.Decimal left, MyVoDecimal right) => !(left == right);
+ public static global::System.Boolean operator !=(MyVoDecimal left, System.Decimal right) => !(left == right);
+ public static explicit operator MyVoDecimal(System.Decimal value) => From(value);
+ public static explicit operator System.Decimal(MyVoDecimal value) => value.Value;
+ public int CompareTo(MyVoDecimal other)
+ {
+ if (other is null)
+ return 1;
+ return Value.CompareTo(other.Value);
+ }
+
+ public int CompareTo(object other)
+ {
+ if (other is null)
+ return 1;
+ if (other is MyVoDecimal x)
+ return CompareTo(x);
+ ThrowHelper.ThrowArgumentException("Cannot compare to object as it is not of type MyVoDecimal", 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,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVoDecimal result)
+ {
+ if (global::System.Decimal.TryParse(utf8Text, out var __v))
+ {
+ result = new MyVoDecimal(__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.Globalization.NumberStyles style, global::System.IFormatProvider provider,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVoDecimal result)
+ {
+ if (global::System.Decimal.TryParse(utf8Text, style, provider, out var __v))
+ {
+ result = new MyVoDecimal(__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 MyVoDecimal result)
+ {
+ if (global::System.Decimal.TryParse(utf8Text, provider, out var __v))
+ {
+ result = new MyVoDecimal(__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 MyVoDecimal result)
+ {
+ if (global::System.Decimal.TryParse(s, out var __v))
+ {
+ result = new MyVoDecimal(__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 MyVoDecimal result)
+ {
+ if (global::System.Decimal.TryParse(s, style, provider, out var __v))
+ {
+ result = new MyVoDecimal(__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 MyVoDecimal result)
+ {
+ if (global::System.Decimal.TryParse(s, provider, out var __v))
+ {
+ result = new MyVoDecimal(__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 MyVoDecimal result)
+ {
+ if (global::System.Decimal.TryParse(s, out var __v))
+ {
+ result = new MyVoDecimal(__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 MyVoDecimal result)
+ {
+ if (global::System.Decimal.TryParse(s, style, provider, out var __v))
+ {
+ result = new MyVoDecimal(__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 MyVoDecimal result)
+ {
+ if (global::System.Decimal.TryParse(s, provider, out var __v))
+ {
+ result = new MyVoDecimal(__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 MyVoDecimal Parse(global::System.ReadOnlySpan utf8Text, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Decimal.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 MyVoDecimal Parse(global::System.ReadOnlySpan utf8Text, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Decimal.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 MyVoDecimal Parse(global::System.ReadOnlySpan s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Decimal.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 MyVoDecimal Parse(global::System.ReadOnlySpan s, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Decimal.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 MyVoDecimal Parse(string s)
+ {
+ var r = global::System.Decimal.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 MyVoDecimal Parse(string s, global::System.Globalization.NumberStyles style)
+ {
+ var r = global::System.Decimal.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 MyVoDecimal Parse(string s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Decimal.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 MyVoDecimal Parse(string s, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Decimal.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
+ 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;
+ }
+ }
+
+ ///
+ 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 void EnsureInitialized()
+ {
+ if (!IsInitialized())
+ {
+#if DEBUG
+ ThrowHelper.ThrowWhenNotInitialized(_stackTrace);
+#else
+ ThrowHelper.ThrowWhenNotInitialized();
+#endif
+ }
+ }
+
+#nullable disable
+ ///
+ /// Converts a MyVoDecimal to or from JSON.
+ ///
+ public partial class MyVoDecimalSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter
+ {
+ public override MyVoDecimal Read(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
+ {
+#if NET5_0_OR_GREATER
+ return __DeserializeSystemTextJson(global::System.Text.Json.JsonSerializer.Deserialize(ref reader, (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)options.GetTypeInfo(typeof(global::System.Decimal))));
+#else
+ return __DeserializeSystemTextJson(reader.GetDecimal());
+#endif
+ }
+
+ public override void Write(System.Text.Json.Utf8JsonWriter writer, MyVoDecimal 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 MyVoDecimal ReadAsPropertyName(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
+ {
+ return __DeserializeSystemTextJson(global::System.Decimal.Parse(reader.GetString(), global::System.Globalization.NumberStyles.Any, global::System.Globalization.CultureInfo.InvariantCulture));
+ }
+
+ public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, MyVoDecimal value, global::System.Text.Json.JsonSerializerOptions options)
+ {
+ writer.WritePropertyName(value.Value.ToString(global::System.Globalization.CultureInfo.InvariantCulture));
+ }
+#endif
+ private static MyVoDecimal __DeserializeSystemTextJson(System.Decimal value)
+ {
+ try
+ {
+ return MyVoDecimal.__Deserialize(value);
+ }
+ catch (System.Exception e)
+ {
+ throw new global::System.Text.Json.JsonException(null, e);
+ }
+ }
+ }
+
+#nullable restore
+#nullable disable
+ class MyVoDecimalTypeConverter : global::System.ComponentModel.TypeConverter
+ {
+ public override global::System.Boolean CanConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType)
+ {
+ return sourceType == typeof(global::System.Decimal) || 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.Decimal decimalValue => MyVoDecimal.__Deserialize(decimalValue),
+ global::System.String stringValue when !global::System.String.IsNullOrEmpty(stringValue) && global::System.Decimal.TryParse(stringValue, global::System.Globalization.NumberStyles.Number, culture.NumberFormat, out var result) => MyVoDecimal.__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.Decimal) || 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, System.Type destinationType)
+ {
+ if (value is MyVoDecimal idValue)
+ {
+ if (destinationType == typeof(global::System.Decimal))
+ {
+ return idValue.Value;
+ }
+
+ if (destinationType == typeof(global::System.String))
+ {
+ return idValue.Value.ToString(culture);
+ }
+ }
+
+ return base.ConvertTo(context, culture, value, destinationType);
+ }
+ }
+
+#nullable restore
+ internal sealed class MyVoDecimalDebugView
+ {
+ private readonly MyVoDecimal _t;
+ MyVoDecimalDebugView(MyVoDecimal t)
+ {
+ _t = t;
+ }
+
+ public global::System.String UnderlyingType => "System.Decimal";
+ public System.Decimal Value => _t.Value;
+ public global::System.String Conversions => @"[global::System.Text.Json.Serialization.JsonConverter(typeof(MyVoDecimalSystemTextJsonConverter))]
+[global::System.ComponentModel.TypeConverter(typeof(MyVoDecimalTypeConverter))]
+";
+ }
+
+ 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(Vogen.Validation validation)
+ {
+ throw CreateValidationException(validation);
+ }
+
+ internal static System.Exception CreateValidationException(string message) => new global::Vogen.ValueObjectValidationException(message);
+ internal static System.Exception CreateCannotBeNullException() => new global::Vogen.ValueObjectValidationException("Cannot create a value object with null.");
+ internal static System.Exception CreateValidationException(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;
+ }
+ }
+ }
+}
+
+// ------------------------------------------------------------------------------
+//
+// 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
+namespace @double
+{
+ [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
+ [global::System.Text.Json.Serialization.JsonConverter(typeof(MyVoDoubleSystemTextJsonConverter))]
+ [global::System.ComponentModel.TypeConverter(typeof(MyVoDoubleTypeConverter))]
+ [global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(MyVoDoubleDebugView))]
+ [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.Double, Value = { _value }")]
+ public partial class MyVoDouble : 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
+ {
+#if DEBUG
+private readonly global::System.Diagnostics.StackTrace _stackTrace = null!;
+#endif
+#if !VOGEN_NO_VALIDATION
+ private readonly global::System.Boolean _isInitialized;
+#endif
+ private readonly System.Double _value;
+ ///
+ /// Gets the underlying value if set, otherwise a is thrown.
+ ///
+ public System.Double 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 MyVoDouble()
+ {
+#if DEBUG
+ _stackTrace = new global::System.Diagnostics.StackTrace();
+#endif
+#if !VOGEN_NO_VALIDATION
+ _isInitialized = false;
+#endif
+ _value = default;
+ }
+
+ [global::System.Diagnostics.DebuggerStepThroughAttribute]
+ private MyVoDouble(System.Double 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 MyVoDouble From(System.Double value)
+ {
+ return new MyVoDouble(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.
+
+#pragma warning disable CS8767 // Nullability of reference types in type of parameter doesn't match implicitly implemented member because of nullability attributes.
+
+ public static bool TryFrom(
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ System.Double value,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)]
+#endif
+ out MyVoDouble vo)
+#pragma warning restore CS8767 // Nullability of reference types in type of parameter doesn't match implicitly implemented member because of nullability attributes.
+
+ {
+ vo = new MyVoDouble(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 Vogen.ValueObjectOrError TryFrom(System.Double value)
+ {
+ return new Vogen.ValueObjectOrError(new MyVoDouble(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 MyVoDouble __Deserialize(System.Double value)
+ {
+ return new MyVoDouble(value);
+ }
+
+ public global::System.Boolean Equals(MyVoDouble 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(MyVoDouble other, global::System.Collections.Generic.IEqualityComparer comparer)
+ {
+ return comparer.Equals(this, other);
+ }
+
+ public global::System.Boolean Equals(System.Double primitive)
+ {
+ return Value.Equals(primitive);
+ }
+
+ public override global::System.Boolean Equals(global::System.Object obj)
+ {
+ return Equals(obj as MyVoDouble);
+ }
+
+ public static global::System.Boolean operator ==(MyVoDouble left, MyVoDouble right) => Equals(left, right);
+ public static global::System.Boolean operator !=(MyVoDouble left, MyVoDouble right) => !Equals(left, right);
+ public static global::System.Boolean operator ==(MyVoDouble left, System.Double right) => left.Value.Equals(right);
+ public static global::System.Boolean operator ==(System.Double left, MyVoDouble right) => right.Value.Equals(left);
+ public static global::System.Boolean operator !=(System.Double left, MyVoDouble right) => !(left == right);
+ public static global::System.Boolean operator !=(MyVoDouble left, System.Double right) => !(left == right);
+ public static explicit operator MyVoDouble(System.Double value) => From(value);
+ public static explicit operator System.Double(MyVoDouble value) => value.Value;
+ public int CompareTo(MyVoDouble other)
+ {
+ if (other is null)
+ return 1;
+ return Value.CompareTo(other.Value);
+ }
+
+ public int CompareTo(object other)
+ {
+ if (other is null)
+ return 1;
+ if (other is MyVoDouble x)
+ return CompareTo(x);
+ ThrowHelper.ThrowArgumentException("Cannot compare to object as it is not of type MyVoDouble", 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,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVoDouble result)
+ {
+ if (global::System.Double.TryParse(utf8Text, out var __v))
+ {
+ result = new MyVoDouble(__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.Globalization.NumberStyles style, global::System.IFormatProvider provider,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVoDouble result)
+ {
+ if (global::System.Double.TryParse(utf8Text, style, provider, out var __v))
+ {
+ result = new MyVoDouble(__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 MyVoDouble result)
+ {
+ if (global::System.Double.TryParse(utf8Text, provider, out var __v))
+ {
+ result = new MyVoDouble(__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 MyVoDouble result)
+ {
+ if (global::System.Double.TryParse(s, out var __v))
+ {
+ result = new MyVoDouble(__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 MyVoDouble result)
+ {
+ if (global::System.Double.TryParse(s, style, provider, out var __v))
+ {
+ result = new MyVoDouble(__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 MyVoDouble result)
+ {
+ if (global::System.Double.TryParse(s, provider, out var __v))
+ {
+ result = new MyVoDouble(__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 MyVoDouble result)
+ {
+ if (global::System.Double.TryParse(s, out var __v))
+ {
+ result = new MyVoDouble(__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 MyVoDouble result)
+ {
+ if (global::System.Double.TryParse(s, style, provider, out var __v))
+ {
+ result = new MyVoDouble(__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 MyVoDouble result)
+ {
+ if (global::System.Double.TryParse(s, provider, out var __v))
+ {
+ result = new MyVoDouble(__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 MyVoDouble Parse(global::System.ReadOnlySpan utf8Text, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Double.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 MyVoDouble Parse(global::System.ReadOnlySpan utf8Text, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Double.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 MyVoDouble Parse(global::System.ReadOnlySpan s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Double.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 MyVoDouble Parse(global::System.ReadOnlySpan s, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Double.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 MyVoDouble Parse(string s)
+ {
+ var r = global::System.Double.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 MyVoDouble Parse(string s, global::System.Globalization.NumberStyles style)
+ {
+ var r = global::System.Double.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 MyVoDouble Parse(string s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Double.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 MyVoDouble Parse(string s, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Double.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
+ 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;
+ }
+ }
+
+ ///
+ 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 void EnsureInitialized()
+ {
+ if (!IsInitialized())
+ {
+#if DEBUG
+ ThrowHelper.ThrowWhenNotInitialized(_stackTrace);
+#else
+ ThrowHelper.ThrowWhenNotInitialized();
+#endif
+ }
+ }
+
+#nullable disable
+ ///
+ /// Converts a MyVoDouble to or from JSON.
+ ///
+ public partial class MyVoDoubleSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter
+ {
+ public override MyVoDouble Read(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
+ {
+#if NET5_0_OR_GREATER
+ return __DeserializeSystemTextJson(global::System.Text.Json.JsonSerializer.Deserialize(ref reader, (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)options.GetTypeInfo(typeof(global::System.Double))));
+#else
+ return __DeserializeSystemTextJson(reader.GetDouble());
+#endif
+ }
+
+ public override void Write(System.Text.Json.Utf8JsonWriter writer, MyVoDouble 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 MyVoDouble ReadAsPropertyName(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
+ {
+ return __DeserializeSystemTextJson(global::System.Double.Parse(reader.GetString(), global::System.Globalization.NumberStyles.Any, global::System.Globalization.CultureInfo.InvariantCulture));
+ }
+
+ public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, MyVoDouble value, global::System.Text.Json.JsonSerializerOptions options)
+ {
+ writer.WritePropertyName(value.Value.ToString(global::System.Globalization.CultureInfo.InvariantCulture));
+ }
+#endif
+ private static MyVoDouble __DeserializeSystemTextJson(System.Double value)
+ {
+ try
+ {
+ return MyVoDouble.__Deserialize(value);
+ }
+ catch (System.Exception e)
+ {
+ throw new global::System.Text.Json.JsonException(null, e);
+ }
+ }
+ }
+
+#nullable restore
+#nullable disable
+ class MyVoDoubleTypeConverter : global::System.ComponentModel.TypeConverter
+ {
+ public override global::System.Boolean CanConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType)
+ {
+ return sourceType == typeof(global::System.Double) || 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.Double doubleValue => MyVoDouble.__Deserialize(doubleValue),
+ global::System.Int64 longValue => MyVoDouble.__Deserialize((global::System.Double)longValue),
+ global::System.String stringValue when !global::System.String.IsNullOrEmpty(stringValue) && global::System.Double.TryParse(stringValue, global::System.Globalization.NumberStyles.Float | global::System.Globalization.NumberStyles.AllowThousands, culture.NumberFormat, out var result) => MyVoDouble.__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.Double) || 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 MyVoDouble idValue)
+ {
+ if (destinationType == typeof(global::System.Double))
+ {
+ return idValue.Value;
+ }
+
+ if (destinationType == typeof(global::System.String))
+ {
+ return idValue.Value.ToString(culture);
+ }
+ }
+
+ return base.ConvertTo(context, culture, value, destinationType);
+ }
+ }
+
+#nullable restore
+ internal sealed class MyVoDoubleDebugView
+ {
+ private readonly MyVoDouble _t;
+ MyVoDoubleDebugView(MyVoDouble t)
+ {
+ _t = t;
+ }
+
+ public global::System.String UnderlyingType => "System.Double";
+ public System.Double Value => _t.Value;
+ public global::System.String Conversions => @"[global::System.Text.Json.Serialization.JsonConverter(typeof(MyVoDoubleSystemTextJsonConverter))]
+[global::System.ComponentModel.TypeConverter(typeof(MyVoDoubleTypeConverter))]
+";
+ }
+
+ 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(Vogen.Validation validation)
+ {
+ throw CreateValidationException(validation);
+ }
+
+ internal static System.Exception CreateValidationException(string message) => new global::Vogen.ValueObjectValidationException(message);
+ internal static System.Exception CreateCannotBeNullException() => new global::Vogen.ValueObjectValidationException("Cannot create a value object with null.");
+ internal static System.Exception CreateValidationException(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;
+ }
+ }
+ }
+}
+
+// ------------------------------------------------------------------------------
+//
+// 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
+namespace @double
+{
+ [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
+ [global::System.Text.Json.Serialization.JsonConverter(typeof(MyVoStringSystemTextJsonConverter))]
+ [global::System.ComponentModel.TypeConverter(typeof(MyVoStringTypeConverter))]
+ [global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(MyVoStringDebugView))]
+ [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.String, Value = { _value }")]
+ public partial class MyVoString : global::System.IEquatable, global::System.IEquatable, global::System.IComparable, global::System.IComparable, 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 System.String _value;
+ ///
+ /// Gets the underlying value if set, otherwise a is thrown.
+ ///
+ public System.String 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 MyVoString()
+ {
+#if DEBUG
+ _stackTrace = new global::System.Diagnostics.StackTrace();
+#endif
+#if !VOGEN_NO_VALIDATION
+ _isInitialized = false;
+#endif
+ _value = default;
+ }
+
+ [global::System.Diagnostics.DebuggerStepThroughAttribute]
+ private MyVoString(System.String 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 MyVoString From(System.String value)
+ {
+ if (value is null)
+ {
+ ThrowHelper.ThrowWhenCreatedWithNull();
+ return default !;
+ }
+
+ return new MyVoString(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.
+
+#pragma warning disable CS8767 // Nullability of reference types in type of parameter doesn't match implicitly implemented member because of nullability attributes.
+
+ public static bool TryFrom(
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ System.String value,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)]
+#endif
+ out MyVoString vo)
+#pragma warning restore CS8767 // Nullability of reference types in type of parameter doesn't match implicitly implemented member because of nullability attributes.
+
+ {
+ if (value is null)
+ {
+ vo = default;
+ return false;
+ }
+
+ vo = new MyVoString(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 Vogen.ValueObjectOrError TryFrom(System.String value)
+ {
+ if (value is null)
+ {
+ return new Vogen.ValueObjectOrError(Vogen.Validation.Invalid("The value provided was null"));
+ }
+
+ return new Vogen.ValueObjectOrError(new MyVoString(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 MyVoString __Deserialize(System.String value)
+ {
+ if (value is null)
+ {
+ ThrowHelper.ThrowWhenCreatedWithNull();
+ return default !;
+ }
+
+ return new MyVoString(value);
+ }
+
+ public global::System.Boolean Equals(MyVoString 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(MyVoString other, global::System.Collections.Generic.IEqualityComparer comparer)
+ {
+ return comparer.Equals(this, other);
+ }
+
+ public global::System.Boolean Equals(System.String primitive)
+ {
+ return Value.Equals(primitive);
+ }
+
+ public global::System.Boolean Equals(System.String primitive, global::System.StringComparer comparer)
+ {
+ return comparer.Equals(Value, primitive);
+ }
+
+ public override global::System.Boolean Equals(global::System.Object obj)
+ {
+ return Equals(obj as MyVoString);
+ }
+
+ public static global::System.Boolean operator ==(MyVoString left, MyVoString right) => Equals(left, right);
+ public static global::System.Boolean operator !=(MyVoString left, MyVoString right) => !Equals(left, right);
+ public static global::System.Boolean operator ==(MyVoString left, System.String right) => left.Value.Equals(right);
+ public static global::System.Boolean operator ==(System.String left, MyVoString right) => right.Value.Equals(left);
+ public static global::System.Boolean operator !=(System.String left, MyVoString right) => !(left == right);
+ public static global::System.Boolean operator !=(MyVoString left, System.String right) => !(left == right);
+ public static explicit operator MyVoString(System.String value) => From(value);
+ public static explicit operator System.String(MyVoString value) => value.Value;
+ public int CompareTo(MyVoString other)
+ {
+ if (other is null)
+ return 1;
+ return Value.CompareTo(other.Value);
+ }
+
+ public int CompareTo(object other)
+ {
+ if (other is null)
+ return 1;
+ if (other is MyVoString x)
+ return CompareTo(x);
+ ThrowHelper.ThrowArgumentException("Cannot compare to object as it is not of type MyVoString", nameof(other));
+ return 0;
+ }
+
+ ///
+ ///
+ ///
+ /// True if the value passes any validation (after running any optional normalization).
+ ///
+ public static global::System.Boolean TryParse(
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ global::System.String s, global::System.IFormatProvider provider,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)]
+#endif
+ out MyVoString result)
+ {
+ if (s is null)
+ {
+ result = default;
+ return false;
+ }
+
+ result = new MyVoString(s);
+ return true;
+ }
+
+ ///
+ ///
+ ///
+ /// The value created via the method.
+ ///
+ /// Thrown when the value can be parsed, but is not valid.
+ public static MyVoString Parse(global::System.String s, global::System.IFormatProvider provider)
+ {
+ return From(s);
+ }
+
+#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;
+ }
+ }
+
+ ///
+ public override global::System.String ToString() => IsInitialized() ? Value.ToString() ?? "" : "[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 void EnsureInitialized()
+ {
+ if (!IsInitialized())
+ {
+#if DEBUG
+ ThrowHelper.ThrowWhenNotInitialized(_stackTrace);
+#else
+ ThrowHelper.ThrowWhenNotInitialized();
+#endif
+ }
+ }
+
+#nullable disable
+ ///
+ /// Converts a MyVoString to or from JSON.
+ ///
+ public partial class MyVoStringSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter
+ {
+ public override MyVoString 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(System.Text.Json.Utf8JsonWriter writer, MyVoString value, global::System.Text.Json.JsonSerializerOptions options)
+ {
+ writer.WriteStringValue(value.Value);
+ }
+
+#if NET6_0_OR_GREATER
+ public override MyVoString 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(System.Text.Json.Utf8JsonWriter writer, MyVoString 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(Vogen.Validation validation)
+ {
+ var e = ThrowHelper.CreateValidationException(validation);
+ throw new global::System.Text.Json.JsonException(null, e);
+ }
+
+ private static void ThrowJsonExceptionWhenNull(System.String value)
+ {
+ if (value == null)
+ {
+ var e = ThrowHelper.CreateCannotBeNullException();
+ throw new global::System.Text.Json.JsonException(null, e);
+ }
+ }
+
+ private static MyVoString DeserializeJson(System.String value)
+ {
+ ThrowJsonExceptionWhenNull(value);
+ return new MyVoString(value);
+ }
+ }
+
+#nullable restore
+#nullable disable
+ class MyVoStringTypeConverter : 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 MyVoString.__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 MyVoString idValue)
+ {
+ if (destinationType == typeof(global::System.String))
+ {
+ return idValue.Value;
+ }
+ }
+
+ return base.ConvertTo(context, culture, value, destinationType);
+ }
+ }
+
+#nullable restore
+ internal sealed class MyVoStringDebugView
+ {
+ private readonly MyVoString _t;
+ MyVoStringDebugView(MyVoString t)
+ {
+ _t = t;
+ }
+
+ public global::System.String UnderlyingType => "System.String";
+ public System.String Value => _t.Value;
+ public global::System.String Conversions => @"[global::System.Text.Json.Serialization.JsonConverter(typeof(MyVoStringSystemTextJsonConverter))]
+[global::System.ComponentModel.TypeConverter(typeof(MyVoStringTypeConverter))]
+";
+ }
+
+ 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(Vogen.Validation validation)
+ {
+ throw CreateValidationException(validation);
+ }
+
+ internal static System.Exception CreateValidationException(string message) => new global::Vogen.ValueObjectValidationException(message);
+ internal static System.Exception CreateCannotBeNullException() => new global::Vogen.ValueObjectValidationException("Cannot create a value object with null.");
+ internal static System.Exception CreateValidationException(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;
+ }
+ }
+ }
+}
+
+// ------------------------------------------------------------------------------
+//
+// 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
+namespace @double
+{
+ [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
+ [global::System.Text.Json.Serialization.JsonConverter(typeof(MyVoBoolSystemTextJsonConverter))]
+ [global::System.ComponentModel.TypeConverter(typeof(MyVoBoolTypeConverter))]
+ [global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(MyVoBoolDebugView))]
+ [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.Boolean, Value = { _value }")]
+ public partial class MyVoBool : global::System.IEquatable, global::System.IEquatable, global::System.IComparable, global::System.IComparable
+ {
+#if DEBUG
+private readonly global::System.Diagnostics.StackTrace _stackTrace = null!;
+#endif
+#if !VOGEN_NO_VALIDATION
+ private readonly global::System.Boolean _isInitialized;
+#endif
+ private readonly System.Boolean _value;
+ ///
+ /// Gets the underlying value if set, otherwise a is thrown.
+ ///
+ public System.Boolean 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 MyVoBool()
+ {
+#if DEBUG
+ _stackTrace = new global::System.Diagnostics.StackTrace();
+#endif
+#if !VOGEN_NO_VALIDATION
+ _isInitialized = false;
+#endif
+ _value = default;
+ }
+
+ [global::System.Diagnostics.DebuggerStepThroughAttribute]
+ private MyVoBool(System.Boolean 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 MyVoBool From(System.Boolean value)
+ {
+ return new MyVoBool(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.
+
+#pragma warning disable CS8767 // Nullability of reference types in type of parameter doesn't match implicitly implemented member because of nullability attributes.
+
+ public static bool TryFrom(
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ System.Boolean value,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)]
+#endif
+ out MyVoBool vo)
+#pragma warning restore CS8767 // Nullability of reference types in type of parameter doesn't match implicitly implemented member because of nullability attributes.
+
+ {
+ vo = new MyVoBool(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 Vogen.ValueObjectOrError TryFrom(System.Boolean value)
+ {
+ return new Vogen.ValueObjectOrError(new MyVoBool(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 MyVoBool __Deserialize(System.Boolean value)
+ {
+ return new MyVoBool(value);
+ }
+
+ public global::System.Boolean Equals(MyVoBool 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(MyVoBool other, global::System.Collections.Generic.IEqualityComparer comparer)
+ {
+ return comparer.Equals(this, other);
+ }
+
+ public global::System.Boolean Equals(System.Boolean primitive)
+ {
+ return Value.Equals(primitive);
+ }
+
+ public override global::System.Boolean Equals(global::System.Object obj)
+ {
+ return Equals(obj as MyVoBool);
+ }
+
+ public static global::System.Boolean operator ==(MyVoBool left, MyVoBool right) => Equals(left, right);
+ public static global::System.Boolean operator !=(MyVoBool left, MyVoBool right) => !Equals(left, right);
+ public static global::System.Boolean operator ==(MyVoBool left, System.Boolean right) => left.Value.Equals(right);
+ public static global::System.Boolean operator ==(System.Boolean left, MyVoBool right) => right.Value.Equals(left);
+ public static global::System.Boolean operator !=(System.Boolean left, MyVoBool right) => !(left == right);
+ public static global::System.Boolean operator !=(MyVoBool left, System.Boolean right) => !(left == right);
+ public static explicit operator MyVoBool(System.Boolean value) => From(value);
+ public static explicit operator System.Boolean(MyVoBool value) => value.Value;
+ public int CompareTo(MyVoBool other)
+ {
+ if (other is null)
+ return 1;
+ return Value.CompareTo(other.Value);
+ }
+
+ public int CompareTo(object other)
+ {
+ if (other is null)
+ return 1;
+ if (other is MyVoBool x)
+ return CompareTo(x);
+ ThrowHelper.ThrowArgumentException("Cannot compare to object as it is not of type MyVoBool", 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 value,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVoBool result)
+ {
+ if (global::System.Boolean.TryParse(value, out var __v))
+ {
+ result = new MyVoBool(__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 value,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out MyVoBool result)
+ {
+ if (global::System.Boolean.TryParse(value, out var __v))
+ {
+ result = new MyVoBool(__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 MyVoBool Parse(global::System.ReadOnlySpan value)
+ {
+ var r = global::System.Boolean.Parse(value);
+ 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 MyVoBool Parse(string value)
+ {
+ var r = global::System.Boolean.Parse(value);
+ 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;
+ }
+ }
+
+ ///
+ public override global::System.String ToString() => IsInitialized() ? Value.ToString() ?? "" : "[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 void EnsureInitialized()
+ {
+ if (!IsInitialized())
+ {
+#if DEBUG
+ ThrowHelper.ThrowWhenNotInitialized(_stackTrace);
+#else
+ ThrowHelper.ThrowWhenNotInitialized();
+#endif
+ }
+ }
+
+#nullable disable
+ ///
+ /// Converts a MyVoBool to or from JSON.
+ ///
+ public partial class MyVoBoolSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter
+ {
+ public override MyVoBool Read(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
+ {
+ return DeserializeJson(reader.GetBoolean());
+ }
+
+ public override void Write(global::System.Text.Json.Utf8JsonWriter writer, MyVoBool value, global::System.Text.Json.JsonSerializerOptions options)
+ {
+ writer.WriteBooleanValue(value.Value);
+ }
+
+#if NET6_0_OR_GREATER
+ public override MyVoBool ReadAsPropertyName(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
+ {
+ return DeserializeJson(bool.Parse(reader.GetString()));
+ }
+
+ public override void WriteAsPropertyName(global::System.Text.Json.Utf8JsonWriter writer, MyVoBool value, global::System.Text.Json.JsonSerializerOptions options)
+ {
+ writer.WritePropertyName(value.Value.ToString());
+ }
+#endif
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ private static void ThrowJsonExceptionWhenValidationFails(Vogen.Validation validation)
+ {
+ var e = ThrowHelper.CreateValidationException(validation);
+ throw new global::System.Text.Json.JsonException(null, e);
+ }
+
+ private static MyVoBool DeserializeJson(System.Boolean value)
+ {
+ return new MyVoBool(value);
+ }
+ }
+
+#nullable restore
+#nullable disable
+ class MyVoBoolTypeConverter : global::System.ComponentModel.TypeConverter
+ {
+ public override global::System.Boolean CanConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType)
+ {
+ return sourceType == typeof(global::System.Boolean) || 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.Boolean boolValue => MyVoBool.__Deserialize(boolValue),
+ global::System.String stringValue when !global::System.String.IsNullOrEmpty(stringValue) && global::System.Boolean.TryParse(stringValue, out var result) => MyVoBool.__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.Boolean) || 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 MyVoBool idValue)
+ {
+ if (destinationType == typeof(global::System.Boolean))
+ {
+ return idValue.Value;
+ }
+
+ if (destinationType == typeof(global::System.String))
+ {
+ return idValue.Value.ToString();
+ }
+ }
+
+ return base.ConvertTo(context, culture, value, destinationType);
+ }
+ }
+
+#nullable restore
+ internal sealed class MyVoBoolDebugView
+ {
+ private readonly MyVoBool _t;
+ MyVoBoolDebugView(MyVoBool t)
+ {
+ _t = t;
+ }
+
+ public global::System.String UnderlyingType => "System.Boolean";
+ public System.Boolean Value => _t.Value;
+ public global::System.String Conversions => @"[global::System.Text.Json.Serialization.JsonConverter(typeof(MyVoBoolSystemTextJsonConverter))]
+[global::System.ComponentModel.TypeConverter(typeof(MyVoBoolTypeConverter))]
+";
+ }
+
+ 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(Vogen.Validation validation)
+ {
+ throw CreateValidationException(validation);
+ }
+
+ internal static System.Exception CreateValidationException(string message) => new global::Vogen.ValueObjectValidationException(message);
+ internal static System.Exception CreateCannotBeNullException() => new global::Vogen.ValueObjectValidationException("Cannot create a value object with null.");
+ internal static System.Exception CreateValidationException(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;
+ }
+ }
+ }
+}
+
+// ------------------------------------------------------------------------------
+//
+// 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
+namespace @double
+{
+ [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
+ [global::System.Text.Json.Serialization.JsonConverter(typeof(@boolSystemTextJsonConverter))]
+ [global::System.ComponentModel.TypeConverter(typeof(@boolTypeConverter))]
+ [global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(@boolDebugView))]
+ [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.Boolean, Value = { _value }")]
+ public partial class @bool : global::System.IEquatable<@bool>, global::System.IEquatable, global::System.IComparable<@bool>, global::System.IComparable
+ {
+#if DEBUG
+private readonly global::System.Diagnostics.StackTrace _stackTrace = null!;
+#endif
+#if !VOGEN_NO_VALIDATION
+ private readonly global::System.Boolean _isInitialized;
+#endif
+ private readonly System.Boolean _value;
+ ///
+ /// Gets the underlying value if set, otherwise a is thrown.
+ ///
+ public System.Boolean 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 @bool()
+ {
+#if DEBUG
+ _stackTrace = new global::System.Diagnostics.StackTrace();
+#endif
+#if !VOGEN_NO_VALIDATION
+ _isInitialized = false;
+#endif
+ _value = default;
+ }
+
+ [global::System.Diagnostics.DebuggerStepThroughAttribute]
+ private @bool(System.Boolean 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 @bool From(System.Boolean value)
+ {
+ return new @bool(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.
+
+#pragma warning disable CS8767 // Nullability of reference types in type of parameter doesn't match implicitly implemented member because of nullability attributes.
+
+ public static bool TryFrom(
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ System.Boolean value,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)]
+#endif
+ out @bool vo)
+#pragma warning restore CS8767 // Nullability of reference types in type of parameter doesn't match implicitly implemented member because of nullability attributes.
+
+ {
+ vo = new @bool(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 Vogen.ValueObjectOrError<@bool> TryFrom(System.Boolean value)
+ {
+ return new Vogen.ValueObjectOrError<@bool>(new @bool(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 @bool __Deserialize(System.Boolean value)
+ {
+ return new @bool(value);
+ }
+
+ public global::System.Boolean Equals(@bool 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(@bool other, global::System.Collections.Generic.IEqualityComparer<@bool> comparer)
+ {
+ return comparer.Equals(this, other);
+ }
+
+ public global::System.Boolean Equals(System.Boolean primitive)
+ {
+ return Value.Equals(primitive);
+ }
+
+ public override global::System.Boolean Equals(global::System.Object obj)
+ {
+ return Equals(obj as @bool);
+ }
+
+ public static global::System.Boolean operator ==(@bool left, @bool right) => Equals(left, right);
+ public static global::System.Boolean operator !=(@bool left, @bool right) => !Equals(left, right);
+ public static global::System.Boolean operator ==(@bool left, System.Boolean right) => left.Value.Equals(right);
+ public static global::System.Boolean operator ==(System.Boolean left, @bool right) => right.Value.Equals(left);
+ public static global::System.Boolean operator !=(System.Boolean left, @bool right) => !(left == right);
+ public static global::System.Boolean operator !=(@bool left, System.Boolean right) => !(left == right);
+ public static explicit operator @bool(System.Boolean value) => From(value);
+ public static explicit operator System.Boolean(@bool value) => value.Value;
+ public int CompareTo(@bool other)
+ {
+ if (other is null)
+ return 1;
+ return Value.CompareTo(other.Value);
+ }
+
+ public int CompareTo(object other)
+ {
+ if (other is null)
+ return 1;
+ if (other is @bool x)
+ return CompareTo(x);
+ ThrowHelper.ThrowArgumentException("Cannot compare to object as it is not of type @bool", 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 value,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out @bool result)
+ {
+ if (global::System.Boolean.TryParse(value, out var __v))
+ {
+ result = new @bool(__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 value,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out @bool result)
+ {
+ if (global::System.Boolean.TryParse(value, out var __v))
+ {
+ result = new @bool(__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 @bool Parse(global::System.ReadOnlySpan value)
+ {
+ var r = global::System.Boolean.Parse(value);
+ 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 @bool Parse(string value)
+ {
+ var r = global::System.Boolean.Parse(value);
+ 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;
+ }
+ }
+
+ ///
+ public override global::System.String ToString() => IsInitialized() ? Value.ToString() ?? "" : "[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 void EnsureInitialized()
+ {
+ if (!IsInitialized())
+ {
+#if DEBUG
+ ThrowHelper.ThrowWhenNotInitialized(_stackTrace);
+#else
+ ThrowHelper.ThrowWhenNotInitialized();
+#endif
+ }
+ }
+
+#nullable disable
+ ///
+ /// Converts a @bool to or from JSON.
+ ///
+ public partial class @boolSystemTextJsonConverter : global::System.Text.Json.Serialization.JsonConverter<@bool>
+ {
+ public override @bool Read(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
+ {
+ return DeserializeJson(reader.GetBoolean());
+ }
+
+ public override void Write(global::System.Text.Json.Utf8JsonWriter writer, @bool value, global::System.Text.Json.JsonSerializerOptions options)
+ {
+ writer.WriteBooleanValue(value.Value);
+ }
+
+#if NET6_0_OR_GREATER
+ public override @bool ReadAsPropertyName(ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options)
+ {
+ return DeserializeJson(bool.Parse(reader.GetString()));
+ }
+
+ public override void WriteAsPropertyName(global::System.Text.Json.Utf8JsonWriter writer, @bool value, global::System.Text.Json.JsonSerializerOptions options)
+ {
+ writer.WritePropertyName(value.Value.ToString());
+ }
+#endif
+#if NETCOREAPP3_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute]
+#endif
+ private static void ThrowJsonExceptionWhenValidationFails(Vogen.Validation validation)
+ {
+ var e = ThrowHelper.CreateValidationException(validation);
+ throw new global::System.Text.Json.JsonException(null, e);
+ }
+
+ private static @bool DeserializeJson(System.Boolean value)
+ {
+ return new @bool(value);
+ }
+ }
+
+#nullable restore
+#nullable disable
+ class @boolTypeConverter : global::System.ComponentModel.TypeConverter
+ {
+ public override global::System.Boolean CanConvertFrom(global::System.ComponentModel.ITypeDescriptorContext context, global::System.Type sourceType)
+ {
+ return sourceType == typeof(global::System.Boolean) || 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.Boolean boolValue => @bool.__Deserialize(boolValue),
+ global::System.String stringValue when !global::System.String.IsNullOrEmpty(stringValue) && global::System.Boolean.TryParse(stringValue, out var result) => @bool.__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.Boolean) || 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 @bool idValue)
+ {
+ if (destinationType == typeof(global::System.Boolean))
+ {
+ return idValue.Value;
+ }
+
+ if (destinationType == typeof(global::System.String))
+ {
+ return idValue.Value.ToString();
+ }
+ }
+
+ return base.ConvertTo(context, culture, value, destinationType);
+ }
+ }
+
+#nullable restore
+ internal sealed class @boolDebugView
+ {
+ private readonly @bool _t;
+ @boolDebugView(@bool t)
+ {
+ _t = t;
+ }
+
+ public global::System.String UnderlyingType => "System.Boolean";
+ public System.Boolean Value => _t.Value;
+ public global::System.String Conversions => @"[global::System.Text.Json.Serialization.JsonConverter(typeof(@boolSystemTextJsonConverter))]
+[global::System.ComponentModel.TypeConverter(typeof(@boolTypeConverter))]
+";
+ }
+
+ 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(Vogen.Validation validation)
+ {
+ throw CreateValidationException(validation);
+ }
+
+ internal static System.Exception CreateValidationException(string message) => new global::Vogen.ValueObjectValidationException(message);
+ internal static System.Exception CreateCannotBeNullException() => new global::Vogen.ValueObjectValidationException("Cannot create a value object with null.");
+ internal static System.Exception CreateValidationException(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;
+ }
+ }
+ }
+}
+
+// ------------------------------------------------------------------------------
+//
+// 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
+namespace @double
+{
+ [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Vogen", "1.0.0.0")]
+ [global::System.Text.Json.Serialization.JsonConverter(typeof(MyVoShortSystemTextJsonConverter))]
+ [global::System.ComponentModel.TypeConverter(typeof(MyVoShortTypeConverter))]
+ [global::System.Diagnostics.DebuggerTypeProxyAttribute(typeof(MyVoShortDebugView))]
+ [global::System.Diagnostics.DebuggerDisplayAttribute("Underlying type: System.Int16, Value = { _value }")]
+ public partial class MyVoShort : 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
+ {
+#if DEBUG
+private readonly global::System.Diagnostics.StackTrace _stackTrace = null!;
+#endif
+#if !VOGEN_NO_VALIDATION
+ private readonly global::System.Boolean _isInitialized;
+#endif
+ private readonly System.Int16 _value;
+ ///
+ /// Gets the underlying value if set, otherwise a is thrown.
+ ///
+ public System.Int16 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 MyVoShort()
+ {
+#if DEBUG
+ _stackTrace = new global::System.Diagnostics.StackTrace();
+#endif
+#if !VOGEN_NO_VALIDATION
+ _isInitialized = false;
+#endif
+ _value = default;
+ }
+
+ [global::System.Diagnostics.DebuggerStepThroughAttribute]
+ private MyVoShort(System.Int16 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 MyVoShort From(System.Int16 value)
+ {
+ return new MyVoShort(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.
+
+#pragma warning disable CS8767 // Nullability of reference types in type of parameter doesn't match implicitly implemented member because of nullability attributes.
+
+ public static bool TryFrom(
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ System.Int16 value,
+#if NETCOREAPP3_0_OR_GREATER
+[global::System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)]
+#endif
+ out MyVoShort vo)
+#pragma warning restore CS8767 // Nullability of reference types in type of parameter doesn't match implicitly implemented member because of nullability attributes.
+
+ {
+ vo = new MyVoShort(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 Vogen.ValueObjectOrError TryFrom(System.Int16 value)
+ {
+ return new Vogen.ValueObjectOrError(new MyVoShort(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 MyVoShort __Deserialize(System.Int16 value)
+ {
+ return new MyVoShort(value);
+ }
+
+ public global::System.Boolean Equals(MyVoShort 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(MyVoShort other, global::System.Collections.Generic.IEqualityComparer comparer)
+ {
+ return comparer.Equals(this, other);
+ }
+
+ public global::System.Boolean Equals(System.Int16 primitive)
+ {
+ return Value.Equals(primitive);
+ }
+
+ public override global::System.Boolean Equals(global::System.Object obj)
+ {
+ return Equals(obj as MyVoShort);
+ }
+
+ public static global::System.Boolean operator ==(MyVoShort left, MyVoShort right) => Equals(left, right);
+ public static global::System.Boolean operator !=(MyVoShort left, MyVoShort right) => !Equals(left, right);
+ public static global::System.Boolean operator ==(MyVoShort left, System.Int16 right) => left.Value.Equals(right);
+ public static global::System.Boolean operator ==(System.Int16 left, MyVoShort right) => right.Value.Equals(left);
+ public static global::System.Boolean operator !=(System.Int16 left, MyVoShort right) => !(left == right);
+ public static global::System.Boolean operator !=(MyVoShort left, System.Int16 right) => !(left == right);
+ public static explicit operator MyVoShort(System.Int16 value) => From(value);
+ public static explicit operator System.Int16(MyVoShort value) => value.Value;
+ public int CompareTo(MyVoShort other)
+ {
+ if (other is null)
+ return 1;
+ return Value.CompareTo(other.Value);
+ }
+
+ public int CompareTo(object other)
+ {
+ if (other is null)
+ return 1;
+ if (other is MyVoShort x)
+ return CompareTo(x);
+ ThrowHelper.ThrowArgumentException("Cannot compare to object as it is not of type MyVoShort", 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 MyVoShort result)
+ {
+ if (global::System.Int16.TryParse(utf8Text, style, provider, out var __v))
+ {
+ result = new MyVoShort(__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 MyVoShort result)
+ {
+ if (global::System.Int16.TryParse(utf8Text, provider, out var __v))
+ {
+ result = new MyVoShort(__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 MyVoShort result)
+ {
+ if (global::System.Int16.TryParse(utf8Text, out var __v))
+ {
+ result = new MyVoShort(__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 MyVoShort result)
+ {
+ if (global::System.Int16.TryParse(s, style, provider, out var __v))
+ {
+ result = new MyVoShort(__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 MyVoShort result)
+ {
+ if (global::System.Int16.TryParse(s, provider, out var __v))
+ {
+ result = new MyVoShort(__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 MyVoShort result)
+ {
+ if (global::System.Int16.TryParse(s, out var __v))
+ {
+ result = new MyVoShort(__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 MyVoShort result)
+ {
+ if (global::System.Int16.TryParse(s, style, provider, out var __v))
+ {
+ result = new MyVoShort(__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 MyVoShort result)
+ {
+ if (global::System.Int16.TryParse(s, provider, out var __v))
+ {
+ result = new MyVoShort(__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 MyVoShort result)
+ {
+ if (global::System.Int16.TryParse(s, out var __v))
+ {
+ result = new MyVoShort(__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 MyVoShort Parse(global::System.ReadOnlySpan utf8Text, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Int16.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 MyVoShort Parse(global::System.ReadOnlySpan utf8Text, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Int16.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 MyVoShort Parse(global::System.ReadOnlySpan s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Int16.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 MyVoShort Parse(global::System.ReadOnlySpan s, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Int16.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 MyVoShort Parse(string s)
+ {
+ var r = global::System.Int16.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 MyVoShort Parse(string s, global::System.Globalization.NumberStyles style)
+ {
+ var r = global::System.Int16.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 MyVoShort Parse(string s, global::System.Globalization.NumberStyles style, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Int16.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 MyVoShort Parse(string s, global::System.IFormatProvider provider)
+ {
+ var r = global::System.Int16.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