in src/AutoRest.CSharp/Common/Input/Configuration.cs [80:199]
public static void Initialize(
string outputFolder,
string ns,
string libraryName,
string[] sharedSourceFolders,
bool saveInputs,
bool azureArm,
bool publicClients,
bool modelNamespace,
bool headAsBoolean,
bool skipCSProj,
bool skipCSProjPackageReference,
bool generation1ConvenienceClient,
bool singleTopLevelClient,
bool skipSerializationFormatXml,
bool disablePaginationTopRenaming,
bool generateModelFactory,
bool publicDiscriminatorProperty,
bool deserializeNullCollectionAsNullValue,
bool useCoreDataFactoryReplacements,
bool useModelReaderWriter,
bool useAzurePlugin,
bool enableBicepSerialization,
bool enableInternalRawData,
IReadOnlyList<string> modelFactoryForHlc,
UnreferencedTypesHandlingOption unreferencedTypesHandling,
bool keepNonOverloadableProtocolSignature,
string? projectFolder,
string? existingProjectFolder,
IReadOnlyList<string> protocolMethodList,
IReadOnlyList<string> suppressAbstractBaseClasses,
IReadOnlyList<string> modelsToTreatEmptyStringAsNull,
IReadOnlyList<string> additionalIntrinsicTypesToTreatEmptyStringAsNull,
bool shouldTreatBase64AsBinaryData,
IReadOnlyList<string> methodsToKeepClientDefaultValue,
MgmtConfiguration mgmtConfiguration,
MgmtTestConfiguration? mgmtTestConfiguration,
string? flavor,
bool disableXmlDocs,
bool generateSampleProject,
bool generateTestProject,
string? examplesDirectory,
string? helperNamespace,
string? customHeader)
{
_outputFolder = outputFolder;
_namespace = ns;
_libraryName = libraryName;
_sharedSourceFolders = sharedSourceFolders;
SaveInputs = saveInputs;
AzureArm = azureArm;
PublicClients = publicClients || AzureArm;
ModelNamespace = azureArm || modelNamespace;
HeadAsBoolean = headAsBoolean;
SkipCSProj = skipCSProj;
SkipCSProjPackageReference = skipCSProjPackageReference;
Generation1ConvenienceClient = generation1ConvenienceClient;
PublicRestClientsTemporaryFlag = generation1ConvenienceClient;
GenerateLongRunningOperationTypes = generation1ConvenienceClient;
GenerateResponseHeaderModels = generation1ConvenienceClient;
SingleTopLevelClient = singleTopLevelClient;
GenerateModelFactory = generateModelFactory;
PublicDiscriminatorProperty = publicDiscriminatorProperty;
DeserializeNullCollectionAsNullValue = deserializeNullCollectionAsNullValue;
UnreferencedTypesHandling = unreferencedTypesHandling;
KeepNonOverloadableProtocolSignature = keepNonOverloadableProtocolSignature;
ShouldTreatBase64AsBinaryData = !azureArm && !generation1ConvenienceClient ? shouldTreatBase64AsBinaryData : false;
UseCoreDataFactoryReplacements = useCoreDataFactoryReplacements;
UseModelReaderWriter = useModelReaderWriter;
UseAzurePlugin = useAzurePlugin;
EnableBicepSerialization = enableBicepSerialization;
EnableInternalRawData = enableInternalRawData;
projectFolder ??= ProjectFolderDefault;
(_absoluteProjectFolder, _relativeProjectFolder) = ParseProjectFolders(outputFolder, projectFolder);
ExistingProjectFolder = existingProjectFolder == null ? DownloadLatestContract(_absoluteProjectFolder) : Path.GetFullPath(Path.Combine(_absoluteProjectFolder, existingProjectFolder));
var isAzureProject = ns.StartsWith("Azure.") || ns.StartsWith("Microsoft.Azure");
// we only check the combination for Azure projects whose namespace starts with "Azure." or "Microsoft.Azure."
// issue: https://github.com/Azure/autorest.csharp/issues/3179
if (publicClients && generation1ConvenienceClient && isAzureProject)
{
var binaryLocation = typeof(Configuration).Assembly.Location;
if (!binaryLocation.EndsWith(Path.Combine("artifacts", "bin", "AutoRest.CSharp", "Debug", CurrentDotnetVersion, "AutoRest.CSharp.dll")))
{
if (_absoluteProjectFolder is not null)
{
//TODO Remove after resolving https://github.com/Azure/autorest.csharp/issues/3151
var absoluteProjectFolderSPlit = new HashSet<string>(_absoluteProjectFolder.Split(Path.DirectorySeparatorChar), StringComparer.Ordinal);
if (!absoluteProjectFolderSPlit.Contains("src") ||
!absoluteProjectFolderSPlit.Contains("Azure.Analytics.Synapse.Spark") &&
!absoluteProjectFolderSPlit.Contains("Azure.Analytics.Synapse.Monitoring") &&
!absoluteProjectFolderSPlit.Contains("Azure.Analytics.Synapse.ManagedPrivateEndpoints") &&
!absoluteProjectFolderSPlit.Contains("Azure.Analytics.Synapse.Artifacts") &&
!absoluteProjectFolderSPlit.Contains("Azure.Communication.PhoneNumbers"))
throw new Exception($"Unsupported combination of settings both {Options.PublicClients} and {Options.Generation1ConvenienceClient} cannot be true at the same time.");
}
}
}
_protocolMethodList = protocolMethodList;
SkipSerializationFormatXml = skipSerializationFormatXml;
DisablePaginationTopRenaming = disablePaginationTopRenaming;
_oldModelFactoryEntries = modelFactoryForHlc;
_mgmtConfiguration = mgmtConfiguration;
MgmtTestConfiguration = mgmtTestConfiguration;
_suppressAbstractBaseClasses = suppressAbstractBaseClasses;
_modelsToTreatEmptyStringAsNull = new HashSet<string>(modelsToTreatEmptyStringAsNull);
_intrinsicTypesToTreatEmptyStringAsNull.UnionWith(additionalIntrinsicTypesToTreatEmptyStringAsNull);
_methodsToKeepClientDefaultValue = methodsToKeepClientDefaultValue ?? Array.Empty<string>();
_apiTypes = "azure".Equals(flavor, StringComparison.InvariantCultureIgnoreCase) ? new AzureApiTypes() : new SystemApiTypes();
Flavor = flavor;
DisableXmlDocs = disableXmlDocs;
GenerateSampleProject = DisableXmlDocs ? false : generateSampleProject; // turn off the samples if all xml docs are explicitly disabled
GenerateTestProject = generateTestProject;
ExamplesDirectory = examplesDirectory;
CustomHeader = customHeader;
_helperNamespace = helperNamespace ?? Namespace;
}