Class GenerateDeserializerAttribute
When using Cesil's Source Generator (see Nuget.org for Cesil.SourceGenerator) marks a class or struct as needing a deserializer generated at compile time.
InstanceProviderType and InstanceProviderMethodName are used to indicate how to obtain an instance of the annotated type from a method. If not set, the type's parameterless constructor is used by default. To use a constructor other than the parameterless, use the [DeserializerInstanceProvider].
When using the AheadOfTimeTypeDescriber, the created I(Async)Readers for this type will do no runtime code generation.
You can customize the behavior of the generated deserializer with [DataMemberAttribute], and [DeserializaerMemberAttribute] attributes.
Default behavior (with no additional attributes) closely follows DefaultTypeDescriver.
Inheritance
Implements
Namespace: Cesil
Assembly: Cesil.dll
Syntax
public sealed class GenerateDeserializerAttribute : Attribute, IEquatable<GenerateDeserializerAttribute>Constructors
GenerateDeserializerAttribute()
Create a GenerateDeserializableAttribute attribute.
Declaration
public GenerateDeserializerAttribute()Properties
InstanceProviderMethodName
Name of InstanceProvider method or constructor, used with InstanceProviderType.
If null, defaults to the parameterless constructor of the annotated type.
If non-null, InstanceProviderType must also be set.
If pointing at a method, it must:
- be static
- return a bool
- have two parameters
- the first must be an in ReadContext
- the second must be an out parameter of the constructed type
If pointing at a constructor, it must either:
- take no parameters or
- each parameter must have a [GenerateDeserializableMember] annotation
Declaration
public string InstanceProviderMethodName { get; set; }Property Value
| Type | Description | 
|---|---|
| System.String | 
InstanceProviderType
Type to lookup an InstanceProvider method or constructor on, used with InstanceProviderMethodName.
If null, defaults to the parameterless constructor of the annotated type.
If non-null, InstanceProviderMethodName must also be set.
The type must be public (or internal, if declared in the same assembly as the annotated type).
Declaration
public Type InstanceProviderType { get; set; }Property Value
| Type | Description | 
|---|---|
| System.Type | 
Methods
Equals(GenerateDeserializerAttribute)
Returns true if the given GenerateDeserializableAttribute is equal to this one.
Declaration
public bool Equals(GenerateDeserializerAttribute attribute)Parameters
| Type | Name | Description | 
|---|---|---|
| GenerateDeserializerAttribute | attribute | 
Returns
| Type | Description | 
|---|---|
| System.Boolean | 
Equals(Object)
Return true if the given object is a GenerateDeserializableAttribute equal to this one.
Declaration
public override bool Equals(object obj)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Object | obj | 
Returns
| Type | Description | 
|---|---|
| System.Boolean | 
GetHashCode()
Returns a stable hash code for this GenerateDeserializableAttribute.
Declaration
public override int GetHashCode()Returns
| Type | Description | 
|---|---|
| System.Int32 | 
ToString()
Returns a representation of this GenerateDeserializableAttribute object.
Only for debugging, this value is not guaranteed to be stable.
Declaration
public override string ToString()Returns
| Type | Description | 
|---|---|
| System.String | 
Operators
Equality(GenerateDeserializerAttribute, GenerateDeserializerAttribute)
Compare two GenerateDeserializableAttribute for equality
Declaration
public static bool operator ==(GenerateDeserializerAttribute a, GenerateDeserializerAttribute b)Parameters
| Type | Name | Description | 
|---|---|---|
| GenerateDeserializerAttribute | a | |
| GenerateDeserializerAttribute | b | 
Returns
| Type | Description | 
|---|---|
| System.Boolean | 
Inequality(GenerateDeserializerAttribute, GenerateDeserializerAttribute)
Compare two GenerateDeserializableAttribute for inequality
Declaration
public static bool operator !=(GenerateDeserializerAttribute a, GenerateDeserializerAttribute b)Parameters
| Type | Name | Description | 
|---|---|---|
| GenerateDeserializerAttribute | a | |
| GenerateDeserializerAttribute | b | 
Returns
| Type | Description | 
|---|---|
| System.Boolean |