Meziantou.Framework.StronglyTypedId
1.0.17
Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Meziantou.Framework.StronglyTypedId --version 1.0.17
NuGet\Install-Package Meziantou.Framework.StronglyTypedId -Version 1.0.17
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Meziantou.Framework.StronglyTypedId" Version="1.0.17"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Meziantou.Framework.StronglyTypedId" Version="1.0.17" />
<PackageReference Include="Meziantou.Framework.StronglyTypedId"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Meziantou.Framework.StronglyTypedId --version 1.0.17
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Meziantou.Framework.StronglyTypedId, 1.0.17"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Meziantou.Framework.StronglyTypedId@1.0.17
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Meziantou.Framework.StronglyTypedId&version=1.0.17
#tool nuget:?package=Meziantou.Framework.StronglyTypedId&version=1.0.17
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Meziantou.Framework.StronglyTypedId
The source generator generates ctor / properties / equality members / JSON converters
[StronglyTypedId(typeof(int))]
public partial struct ProjectId { }
StronglyTypedId generates the following code:
[System.ComponentModel.TypeConverterAttribute(typeof(ProjectIdTypeConverter))]
[System.Text.Json.Serialization.JsonConverterAttribute(typeof(ProjectIdJsonConverter))]
[Newtonsoft.Json.JsonConverterAttribute(typeof(ProjectIdNewtonsoftJsonConverter))]
[MongoDB.Bson.Serialization.Attributes.BsonSerializerAttribute(typeof(ProjectIdMongoDBBsonSerializer))]
public partial struct ProjectId : System.IEquatable<ProjectId>
{
public int Value { get; }
public string ValueAsString { get; }
private ProjectId(int value);
public static ProjectId FromInt32(int value);
public static ProjectId Parse(string value);
public static ProjectId Parse(ReadOnlySpan<char> value);
public static bool TryParse(string value, out ProjectId result);
public static bool TryParse(ReadOnlySpan<char> value, out ProjectId result);
public override int GetHashCode();
public override bool Equals(object? other);
public bool Equals(ProjectId other);
public static bool operator ==(ProjectId a, ProjectId b);
public static bool operator !=(ProjectId a, ProjectId b);
public override string ToString();
private partial class CustomerIdTypeConverter : System.ComponentModel.TypeConverter
{
public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType);
public override object? ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value);
public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType);
public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType);
}
// Generated only when System.Text.Json is accessible
private partial class CustomerIdJsonConverter : System.Text.Json.Serialization.JsonConverter<ProjectId>
{
public override void Write(System.Text.Json.Utf8JsonWriter writer, ProjectId value, System.Text.Json.JsonSerializerOptions options);
public override ProjectId Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options);
}
// Generated only when Newtonsoft.Json is accessible
private partial class CustomerIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter
{
public override bool CanRead { get; }
public override bool CanWrite { get; }
public override bool CanConvert(System.Type type);
public override void WriteJson(Newtonsoft.Json.JsonWriter writer, object? value, Newtonsoft.Json.JsonSerializer serializer);
public override object ReadJson(Newtonsoft.Json.JsonReader reader, System.Type objectType, object? existingValue, Newtonsoft.Json.JsonSerializer serializer);
}
// Generated only when MongoDB.Bson.Serialization.Serializers.SerializerBase is accessible
private partial class ProjectIdMongoDBBsonSerializer : MongoDB.Bson.Serialization.Serializers.SerializerBase<Meziantou.Framework.StronglyTypedId.GeneratorTests.StronglyTypedIdTests.IdBoolean>
{
public override ProjectId Deserialize(MongoDB.Bson.Serialization.BsonDeserializationContext context, MongoDB.Bson.Serialization.BsonDeserializationArgs args);
public override void Serialize(MongoDB.Bson.Serialization.BsonSerializationContext context, MongoDB.Bson.Serialization.BsonSerializationArgs args, ProjectId value);
}
}
Configuration
You can configure the code generation using the [StronglyTypedIdAttribute] attribute:
[StronglyTypedId(idType: typeof(long),
generateSystemTextJsonConverter: true,
generateNewtonsoftJsonConverter: true,
generateSystemComponentModelTypeConverter: true,
generateMongoDBBsonSerialization: true,
addCodeGeneratedAttribute: true
)]
public partial struct ProjectId { }
Additional resources
There are no supported framework assets in this package.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
-
net6.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Meziantou.Framework.StronglyTypedId:
| Package | Downloads |
|---|---|
|
Allegro.Extensions.Identifiers.Abstractions
Contains strongly typed identifiers abstractions. |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on Meziantou.Framework.StronglyTypedId:
| Repository | Stars |
|---|---|
|
StefH/AnyOf
Use the AnyOf<TFirst, TSecond, ...> type to handle multiple defined types as input parameters or return values for methods.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 2.3.11 | 1,304 | 1/25/2026 |
| 2.3.10 | 623 | 1/18/2026 |
| 2.3.9 | 9,896 | 10/27/2025 |
| 2.3.8 | 194 | 10/27/2025 |
| 2.3.7 | 1,818 | 10/19/2025 |
| 2.3.6 | 1,257 | 10/5/2025 |
| 2.3.5 | 1,199 | 9/21/2025 |
| 2.3.4 | 1,906 | 9/3/2025 |
| 2.3.3 | 16,196 | 3/15/2025 |
| 2.3.2 | 8,834 | 11/17/2024 |
| 2.3.1 | 3,743 | 10/10/2024 |
| 2.3.0 | 8,924 | 7/13/2024 |
| 2.2.0 | 7,303 | 3/21/2024 |
| 2.1.0 | 5,665 | 11/26/2023 |
| 2.0.0 | 623 | 11/19/2023 |
| 1.0.35 | 4,220 | 11/15/2023 |
| 1.0.34 | 4,561 | 9/5/2023 |
| 1.0.33 | 822 | 8/7/2023 |
| 1.0.32 | 7,126 | 3/26/2023 |
| 1.0.17 | 936 | 11/10/2021 |
Loading failed