StronglyTypedIdDefaultsAttribute Class
Configures the default values used by the strongly-typed identifier source generator for all the types of the assembly. Options set on StronglyTypedIdAttribute or StronglyTypedIdAttribute<T> take precedence over the values defined by this attribute.
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]
public sealed class StronglyTypedIdDefaultsAttribute : AttributeExample
[assembly: StronglyTypedIdDefaults(GuidGenerationStrategy = GuidGenerationStrategy.Version7, GenerateNewtonsoftJsonConverter = false)]
// Usage:
var productId = ProductId.New(); // Uses Guid.CreateVersion7()
Console.WriteLine(productId.Value.Version); // 7
[StronglyTypedId<Guid>]
public partial struct ProductId
{
}- Inheritance
AttributeStronglyTypedIdDefaultsAttribute
Constructors
| Name | Description |
|---|---|
| StronglyTypedIdDefaultsAttribute() |
StronglyTypedIdDefaultsAttribute()
public StronglyTypedIdDefaultsAttribute()No documentation is available.
Properties
| Name | Description |
|---|---|
| AddCodeGeneratedAttribute | Gets or sets the default value indicating whether generated members are marked with GeneratedCodeAttribute. When the property is not set, the attribute is added. |
| GenerateMongoDBBsonSerialization | Gets or sets the default value indicating whether a MongoDB.Bson.Serialization.Serializers.SerializerBase{T} is generated. When the property is not set, the serializer is generated. |
| GenerateNewtonsoftJsonConverter | Gets or sets the default value indicating whether a Newtonsoft.Json.JsonConverter is generated. When the property is not set, the converter is generated. |
| GenerateSystemComponentModelTypeConverter | Gets or sets the default value indicating whether a System.ComponentModel.TypeConverter is generated. When the property is not set, the converter is generated. |
| GenerateSystemTextJsonConverter | Gets or sets the default value indicating whether a System.Text.Json.Serialization.JsonConverter is generated. When the property is not set, the converter is generated. |
| GenerateToStringAsRecord | Gets or sets the default value indicating whether the ToString() method generates output in record format. When the property is not set, the record format is used. |
| GuidGenerationStrategy | Gets or sets the default strategy used by the generated New() method when the underlying type is Guid. When the property is not set, GuidGenerationStrategy.Version4 is used. |
| StringComparison | Gets or sets the default string comparison method to use when the underlying type is String. When the property is not set, StringComparison.Ordinal is used. |
AddCodeGeneratedAttribute
StronglyTypedIdDefaultsAttribute.csGets or sets the default value indicating whether generated members are marked with GeneratedCodeAttribute. When the property is not set, the attribute is added.
public bool AddCodeGeneratedAttribute { get; set; }Property value
GenerateMongoDBBsonSerialization
StronglyTypedIdDefaultsAttribute.csGenerateNewtonsoftJsonConverter
StronglyTypedIdDefaultsAttribute.csGenerateSystemComponentModelTypeConverter
StronglyTypedIdDefaultsAttribute.csGenerateSystemTextJsonConverter
StronglyTypedIdDefaultsAttribute.csGenerateToStringAsRecord
StronglyTypedIdDefaultsAttribute.csGuidGenerationStrategy
StronglyTypedIdDefaultsAttribute.csGets or sets the default strategy used by the generated New() method when the underlying type is Guid. When the property is not set, GuidGenerationStrategy.Version4 is used.
public GuidGenerationStrategy GuidGenerationStrategy { get; set; }Property value
StringComparison
StronglyTypedIdDefaultsAttribute.csGets or sets the default string comparison method to use when the underlying type is String. When the property is not set, StringComparison.Ordinal is used.
public StringComparison StringComparison { get; set; }