Configuration Options for Development Environment
Global Configuration
Intellenum provides several options to configure its behavior globally. These options can be specified through assembly attributes that define the configuration settings for the entire assembly. These configurations are parsed during the compilation process. Below are the available options and their default values.
1. Try From Generation
- Option:
tryFromGeneration
- Description: Specifies what to write for
TryFrom
methods. - Default Value:
TryFromGeneration.GenerateBoolAndErrorOrMethods
[assembly: IntellenumDefaults(tryFromGeneration: TryFromGeneration.UseExistingMethods)]
2. Is Initialized Method Generation
- Option:
isInitializedMethodGeneration
- Description: Specifies whether to generate an
IsInitialized()
method. - Default Value:
IsInitializedMethodGeneration.Generate
[assembly: IntellenumDefaults(isInitializedMethodGeneration: IsInitializedMethodGeneration.Omit)]
3. System Text Json Converter Factory Generation
- Option:
systemTextJsonConverterFactoryGeneration
- Description: Determines whether to write a factory for STJ converters.
- Default Value:
SystemTextJsonConverterFactoryGeneration.Generate
[assembly: IntellenumDefaults(systemTextJsonConverterFactoryGeneration: SystemTextJsonConverterFactoryGeneration.Omit)]
4. Static Abstracts Generation
- Option:
staticAbstractsGeneration
- Description: Determines whether to write static abstract code.
- Default Value:
StaticAbstractsGeneration.Omit
[assembly: IntellenumDefaults(staticAbstractsGeneration: StaticAbstractsGeneration.Generate)]
5. Deserialization Strictness
- Option:
deserializationStrictness
- Description: Specifies how strict deserialization is. Determines if the
Validate
method should be called. - Default Value:
DeserializationStrictness.AllowValidAndKnownInstances
[assembly: IntellenumDefaults(deserializationStrictness: DeserializationStrictness.Strict)]
6. Debugger Attributes Generation
- Option:
debuggerAttributes
- Description: Specifies the level of debug attributes generated.
- Default Value:
DebuggerAttributeGeneration.Full
[assembly: IntellenumDefaults(debuggerAttributes: DebuggerAttributeGeneration.None)]
7. Comparison Generation
- Option:
comparison
- Description: Specifies which comparison code is generated.
- Default Value:
ComparisonGeneration.UseUnderlying
[assembly: IntellenumDefaults(comparison: ComparisonGeneration.Custom)]
8. Open API Schema Customizations
- Option:
openApiSchemaCustomizations
- Description: Determines what is generated to assist in OpenAPI scenarios.
- Default Value:
OpenApiSchemaCustomizations.Omit
[assembly: IntellenumDefaults(openApiSchemaCustomizations: OpenApiSchemaCustomizations.Generate)]
9. Explicitly Specify Type In Value Object
- Option:
explicitlySpecifyTypeInValueObject
- Description: Specifies whether individual value objects should explicitly define the primitive type they wrap.
- Default Value:
false
[assembly: IntellenumDefaults(explicitlySpecifyTypeInValueObject: true)]
Code Analysis Warnings
In addition to the configuration options, several code analysis warnings exist for invalid configurations. Commonly encountered issues include:
- Specifying an exception that does not derive from
System.Exception
. - Specifying an exception that does not have one public constructor taking an
int
. - Combinations of conversions that do not match an entry.
Example Assembly Attribute
Combining several options, a sample assembly-level attribute would look like this:
using Intellenum;
[assembly: IntellenumDefaults(
tryFromGeneration: TryFromGeneration.Omit,
isInitializedMethodGeneration: IsInitializedMethodGeneration.Generate,
systemTextJsonConverterFactoryGeneration: SystemTextJsonConverterFactoryGeneration.Generate,
staticAbstractsGeneration: StaticAbstractsGeneration.Omit,
deserializationStrictness: DeserializationStrictness.AllowValidAndKnownInstances,
debuggerAttributes: DebuggerAttributeGeneration.Full,
comparison: ComparisonGeneration.UseUnderlying,
openApiSchemaCustomizations: OpenApiSchemaCustomizations.Omit,
explicitlySpecifyTypeInValueObject: false
)]
This configuration allows for fine-tuning the behavior of Intellenum during development, optimizing the compilation and runtime characteristics to fit specific requirements.
Source
- Configuration documentation for Intellenum:
docs/site/Writerside/topics/reference/Configuration.md