/* ========================================================================
* Copyright (c) 2005-2025 The OPC Foundation, Inc. All rights reserved.
*
* OPC Foundation MIT License 1.00
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* The complete license agreement can be found here:
* http://opcfoundation.org/License/MIT/1.00/
* ======================================================================*/
using System.Collections.Generic;
using System.Threading;
namespace Opc.Ua.SourceGeneration
{
///
/// Generator options
///
public sealed class GeneratorOptions
{
///
/// Optimize generated code for compile speed.
///
public bool OptimizeForCompileSpeed { get; set; }
///
/// Exclusions to apply on the input
///
public IReadOnlyList Exclusions { get; set; } = [];
///
/// Generation should be cancelled
///
public CancellationToken Cancellation { get; set; }
///
/// Write utf8 string literals when needed
///
public bool UseUtf8StringLiterals { get; set; } = true;
///
/// When set to true, the
/// is suppressed and no
/// *TypeClient proxy classes are emitted. Off by default —
/// proxies are emitted for every ObjectType in the model
/// alongside the standard model output.
///
public bool OmitObjectTypeProxies { get; set; }
///
/// When set to true, the
/// is suppressed and no
/// {TypeName}Ids classes (nested StateIds /
/// StateNumbers / TransitionIds /
/// TransitionNumbers) are emitted. Off by default — IDs
/// are emitted for every concrete FiniteStateMachineType
/// subtype declared in the model.
///
public bool OmitStateMachineIds { get; set; }
///
/// When set to true, suppresses emission of the
/// per-ObjectType IComponentAccessor<TState> /
/// IPropertyAccessor<TState> typed-accessor
/// extension classes by .
/// Defaults to false — accessors are emitted unless
/// explicitly suppressed. Model-only assemblies that don't
/// reference Opc.Ua.Server must set this to true
/// because the emitted method bodies call into server-side
/// fluent builders even though the
/// /
/// marker interfaces
/// themselves now live in Opc.Ua.Types.
///
public bool OmitFluentApi { get; set; }
///
/// When set to true, generation is limited to the
/// per-ObjectType typed fluent accessor extension classes emitted
/// by . The target model must
/// already be supplied by a referenced assembly under the same
/// model URI and C# prefix so the emitted accessors can reference
/// that assembly's state types. Its model dependency payload must
/// explicitly declare that the producer omitted fluent accessors;
/// missing capability metadata and producers that already emitted
/// accessors are rejected.
///
public bool FluentAccessorsOnly { get; set; }
///
/// Emits only typed variable accessors and placeholder enumerators over client proxies
/// supplied by a referenced model assembly. Disabled by default.
///
public bool ClientAccessorsOnly { get; set; }
///
/// Overrides the namespace of client accessor extensions. Defaults to the model prefix plus Client.
///
public string? ClientAccessorNamespace { get; set; }
///
/// Overrides the partial extension class name. Defaults to the model name plus ClientMembers.
///
public string? ClientAccessorClassName { get; set; }
///
/// Optional override for the C# namespace used by classes emitted
/// by the . When unset,
/// the model's target namespace prefix is used.
///
public string? ObjectTypeProxyNamespace { get; set; }
///
/// When set to true, the
/// uses the modelling rules from the referenced type definition
/// unconditionally, rather than the overridden rules on instance
/// definitions, for all structural code generation decisions
/// (child inclusion, optional vs mandatory classification),
/// for factory-method child emission (mandatory list versus
/// on-demand CreateOrReplace* initialisation) and for
/// the emitted runtime ModellingRuleId.
///
/// Off by default. When off, the generator still enforces OPC UA
/// modelling rule promotion semantics — instances may only
/// promote the type definition's rule:
/// Optional → Mandatory,
/// OptionalPlaceholder → Mandatory | MandatoryPlaceholder,
/// MandatoryPlaceholder → Mandatory.
/// Any demotion is silently rejected and the type definition's
/// rule is used instead.
///
///
public bool UseTypeDefinitionModellingRules { get; set; }
///
/// When set to true, the predefined nodes generated for a
/// NodeSet2 input are exactly the nodes the NodeSet2 declares. A
/// subtype in the NodeSet2 does not get copies of the Mandatory
/// InstanceDeclarations of its supertypes, and an instance does not
/// get children its NodeSet2 does not declare or references to them,
/// so the address space holds no node with an identifier the NodeSet2
/// does not assign.
///
/// The typed state classes and the CreateInstanceOf* factories
/// are not affected: inherited members still resolve through the
/// state classes of the supertypes, and an instance created at run
/// time still gets every Mandatory descendant of its type.
///
///
/// Off by default. A ModelDesign input is not affected.
///
///
public bool EmitNodeSetNodesOnly { get; set; }
///
/// Maps an OPC UA namespace URI (key) to the C# namespace (value)
/// in which the corresponding source-generated *TypeClient
/// proxies live. Used by the
/// when a generated
/// proxy must derive from a base proxy that is defined in a
/// different (referenced) assembly.
///
///
/// The standard mapping
/// http://opcfoundation.org/UA/ -> Opc.Ua.Client is
/// always added by the generator and does not need to be
/// configured explicitly.
///
public IDictionary ObjectTypeProxyExternalNamespaces { get; }
= new Dictionary();
///
/// Optional override for the C# namespace used by classes
/// emitted by the . When
/// unset, the model's target namespace prefix is used.
///
public string? EventRecordNamespace { get; set; }
///
/// Suppresses source-generated event record classes.
///
public bool OmitEventRecords { get; set; }
///
/// Maps an OPC UA namespace URI (key) to the C# namespace
/// (value) in which the corresponding source-generated
/// *Record classes live. Used by the
/// when a record must
/// derive from a parent record defined in a different
/// (referenced) assembly.
///
///
/// The standard mapping
/// http://opcfoundation.org/UA/ -> Opc.Ua.Client.Alarms
/// is always added by the generator and does not need to be
/// configured explicitly.
///
public IDictionary EventRecordExternalNamespaces { get; }
= new Dictionary();
///
/// When false, suppress the emission of the
/// {prefix}.ModelDependencies.g.cs and
/// {prefix}.ModelSnapshot.g.cs files. The consuming
/// generator decides whether emission is appropriate
/// (typically only for assemblies that will be referenced as
/// libraries). Default true preserves existing
/// behaviour for direct invokers of the Core API (tests, the
/// model-compiler CLI).
///
public bool EmitDependencyMetadata { get; set; } = true;
}
}