1517 references to Enum
aspire (6)
Commands\PipelineCommandBase.cs (1)
800if (!Enum.TryParse<InputType>(input.InputType, ignoreCase: true, out var inputType))
Packaging\PackagingService.cs (1)
158if (Enum.TryParse<PackageChannelQuality>(overrideQuality, ignoreCase: true, out var quality))
Program.cs (1)
108if (Enum.TryParse<LogLevel>(args[i + 1], ignoreCase: true, out var parsedLevel))
src\Shared\IConfigurationExtensions.cs (3)
185else if (Enum.TryParse<T>(value, ignoreCase: true, out var e)) 190throw new InvalidOperationException($"Unknown {typeof(T).Name} value \"{value}\". Valid values are {string.Join(", ", Enum.GetNames(typeof(T)))}."); 210throw new InvalidOperationException($"Missing required configuration for {key}. Valid values are {string.Join(", ", Enum.GetNames(typeof(T)))}.");
Aspire.Dashboard (17)
Api\TelemetryApiService.cs (2)
227if (!string.IsNullOrEmpty(severity) && Enum.TryParse<LogLevel>(severity, ignoreCase: true, out var logLevel)) 356if (!string.IsNullOrEmpty(severity) && Enum.TryParse<LogLevel>(severity, ignoreCase: true, out var parsedLevel))
Components\Controls\Chart\ChartContainer.razor.cs (1)
292|| !Enum.TryParse(typeof(Pages.Metrics.MetricViewKind), id, out var o)
Components\Dialogs\GenAIVisualizerDialog.razor.cs (2)
202|| !Enum.TryParse(typeof(OverviewViewKind), id, out var o) 221|| !Enum.TryParse(typeof(ItemViewKind), id, out var o)
Components\Dialogs\McpServerDialog.razor.cs (1)
201|| !Enum.TryParse(typeof(McpToolView), id, out var o)
Components\Pages\Metrics.razor.cs (1)
157viewModel.SelectedViewKind = Enum.TryParse(typeof(MetricViewKind), ViewKindName, out var view) && view is MetricViewKind vk ? vk : null;
Components\Pages\Resources.razor.cs (2)
885|| !Enum.TryParse(typeof(ResourceViewKind), id, out var o) 948if (!_hideResourceGraph && Enum.TryParse(typeof(ResourceViewKind), ViewKindName, out var view) && view is ResourceViewKind vk)
Components\Pages\StructuredLogs.razor.cs (1)
515if (LogLevelText is not null && Enum.TryParse<LogLevel>(LogLevelText, ignoreCase: true, out var logLevel))
Model\Assistant\OtelAttributeHelpers.cs (1)
13if (Enum.IsDefined(typeof(HttpStatusCode), statusCode))
Model\Otlp\TelemetryFilter.cs (1)
124if (Enum.TryParse<LogLevel>(Value, ignoreCase: true, out var value))
Otlp\Model\OtlpSpan.cs (1)
204if (!string.IsNullOrEmpty(grpcStatusCode) && Enum.TryParse<StatusCode>(grpcStatusCode, out var statusCode))
ServiceClient\Partials.cs (1)
39KnownState = HasState ? Enum.TryParse(State, out KnownResourceState knownState) ? knownState : null : null,
src\Shared\IConfigurationExtensions.cs (3)
185else if (Enum.TryParse<T>(value, ignoreCase: true, out var e)) 190throw new InvalidOperationException($"Unknown {typeof(T).Name} value \"{value}\". Valid values are {string.Join(", ", Enum.GetNames(typeof(T)))}."); 210throw new InvalidOperationException($"Missing required configuration for {key}. Valid values are {string.Join(", ", Enum.GetNames(typeof(T)))}.");
Aspire.Dashboard.Components.Tests (1)
Pages\ResourcesTests.cs (1)
372KnownState = state is not null && Enum.TryParse<KnownResourceState>(state, out var knownState) ? knownState : null,
Aspire.Dashboard.Tests (3)
Model\ResourceStateViewModelTests.cs (2)
11using Enum = System.Enum; 71HealthStatus? healthStatus = string.IsNullOrEmpty(healthStatusString) ? null : Enum.Parse<HealthStatus>(healthStatusString);
Model\ResourceViewModelTests.cs (1)
29var reports = healthStatusStrings?.Select<string?, HealthReportViewModel>((h, i) => new HealthReportViewModel(i.ToString(), h is null ? null : System.Enum.Parse<DiagnosticsHealthStatus>(h), null, null)).ToImmutableArray() ?? [];
Aspire.EndToEnd.Tests (4)
IntegrationServicesFixture.cs (2)
97if (resource == TestResourceNames.All || !Enum.IsDefined<TestResourceNames>(resource)) 122foreach (var ename in Enum.GetValues<TestResourceNames>())
tests\testproject\Common\TestResourceNames.cs (2)
24if (Enum.TryParse<TestResourceNames>(resourceName, ignoreCase: true, out var name)) 39return string.Join(',', Enum.GetValues<TestResourceNames>()
Aspire.Hosting (6)
ApplicationModel\CertificateTrustExecutionConfigurationGatherer.cs (1)
123resourceLogger.LogInformation("Resource '{ResourceName}' has a certificate trust scope of '{Scope}'. Automatically including system root certificates in the trusted configuration.", resource.Name, Enum.GetName(additionalData.Scope));
Dcp\DcpExecutor.cs (1)
1999_ => throw new InvalidOperationException($"Unknown pull policy '{Enum.GetName(typeof(ImagePullPolicy), pullPolicy)}' for container '{container.Name}'")
ProjectResourceBuilderExtensions.cs (1)
450logger.LogWarning("Certificate trust scope is set to '{Scope}', but the feature is not supported for .NET projects on Windows. No certificate trust customization will be applied. Set the certificate trust scope to 'None' to disable this warning.", Enum.GetName(ctx.Scope));
src\Shared\IConfigurationExtensions.cs (3)
185else if (Enum.TryParse<T>(value, ignoreCase: true, out var e)) 190throw new InvalidOperationException($"Unknown {typeof(T).Name} value \"{value}\". Valid values are {string.Join(", ", Enum.GetNames(typeof(T)))}."); 210throw new InvalidOperationException($"Missing required configuration for {key}. Valid values are {string.Join(", ", Enum.GetNames(typeof(T)))}.");
Aspire.Hosting.Azure.Tests (2)
AzureServiceBusExtensionsTests.cs (1)
850roles.SetValue(Enum.Parse(roleType, "AzureServiceBusDataSender"), 0);
AzureStorageExtensionsTests.cs (1)
978roles.SetValue(Enum.Parse(roleType, "StorageBlobDataContributor"), 0);
Aspire.Hosting.CodeGeneration.Go (1)
AtsGoCodeGenerator.cs (1)
132foreach (var member in Enum.GetNames(enumType.ClrType))
Aspire.Hosting.CodeGeneration.Java (1)
AtsJavaCodeGenerator.cs (1)
133var members = Enum.GetNames(enumType.ClrType);
Aspire.Hosting.CodeGeneration.Python (1)
AtsPythonCodeGenerator.cs (1)
131foreach (var member in Enum.GetNames(enumType.ClrType))
Aspire.Hosting.CodeGeneration.Rust (2)
AtsRustCodeGenerator.cs (2)
151foreach (var member in Enum.GetNames(enumType.ClrType)) 169foreach (var member in Enum.GetNames(enumType.ClrType))
Aspire.Hosting.DevTunnels (1)
DevTunnelLoginManager.cs (1)
43if (Enum.TryParse<LoginProvider>(preferredProvider, ignoreCase: true, out var provider))
Aspire.Hosting.GitHub.Models (3)
src\Shared\IConfigurationExtensions.cs (3)
185else if (Enum.TryParse<T>(value, ignoreCase: true, out var e)) 190throw new InvalidOperationException($"Unknown {typeof(T).Name} value \"{value}\". Valid values are {string.Join(", ", Enum.GetNames(typeof(T)))}."); 210throw new InvalidOperationException($"Missing required configuration for {key}. Valid values are {string.Join(", ", Enum.GetNames(typeof(T)))}.");
Aspire.Hosting.Maui (3)
src\Shared\IConfigurationExtensions.cs (3)
185else if (Enum.TryParse<T>(value, ignoreCase: true, out var e)) 190throw new InvalidOperationException($"Unknown {typeof(T).Name} value \"{value}\". Valid values are {string.Join(", ", Enum.GetNames(typeof(T)))}."); 210throw new InvalidOperationException($"Missing required configuration for {key}. Valid values are {string.Join(", ", Enum.GetNames(typeof(T)))}.");
Aspire.Hosting.OpenAI (3)
src\Shared\IConfigurationExtensions.cs (3)
185else if (Enum.TryParse<T>(value, ignoreCase: true, out var e)) 190throw new InvalidOperationException($"Unknown {typeof(T).Name} value \"{value}\". Valid values are {string.Join(", ", Enum.GetNames(typeof(T)))}."); 210throw new InvalidOperationException($"Missing required configuration for {key}. Valid values are {string.Join(", ", Enum.GetNames(typeof(T)))}.");
Aspire.Hosting.RemoteHost (4)
Ats\AtsMarshaller.cs (2)
488return Enum.Parse(underlyingType, enumName, ignoreCase: true); 493return Enum.ToObject(underlyingType, enumValue);
AtsCapabilityScanner.cs (2)
90var values = Enum.GetNames(enumType).ToList(); 530Values = Enum.GetNames(enumType).ToList()
Aspire.Hosting.RemoteHost.Tests (1)
CapabilityDispatcherTests.cs (1)
1751return Enum.Parse<TestDispatchEnum>(name);
Aspire.Hosting.Testing.Tests (2)
tests\testproject\Common\TestResourceNames.cs (2)
24if (Enum.TryParse<TestResourceNames>(resourceName, ignoreCase: true, out var name)) 39return string.Join(',', Enum.GetValues<TestResourceNames>()
Aspire.Hosting.Tests (1)
Health\HealthStatusTests.cs (1)
26var reports = healthStatusStrings?.Select<string?, HealthReportSnapshot>((h, i) => new HealthReportSnapshot(i.ToString(), h is null ? null : Enum.Parse<HealthStatus>(h), null, null)).ToImmutableArray() ?? [];
Aspire.Hosting.Yarp (2)
YarpEnvConfigGenerator.cs (1)
74foreach (var protocol in Enum.GetValues<SslProtocols>())
YarpJsonConfigGeneratorBuilder.cs (1)
136foreach (var protocol in Enum.GetValues<SslProtocols>())
Binding.Http.IntegrationTests (9)
BasicHttpBindingTests.4.0.0.cs (6)
37serviceProxy = factory.CreateChannel(new EndpointAddress(Endpoints.HttpBaseAddress_Basic + Enum.GetName(typeof(WSMessageEncoding), messageEncoding))); 76factory = new ChannelFactory<IWcfService>(customBinding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic + Enum.GetName(typeof(WSMessageEncoding), messageEncoding))); 112factory = new ChannelFactory<IWcfService>(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic + Enum.GetName(typeof(WSMessageEncoding), messageEncoding))); 158factory = new ChannelFactory<IWcfService>(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic + Enum.GetName(typeof(WSMessageEncoding), messageEncoding))); 214factory = new ChannelFactory<IWcfService>(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic + Enum.GetName(typeof(WSMessageEncoding), messageEncoding))); 254factory = new ChannelFactory<IWcfService>(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic + Enum.GetName(typeof(WSMessageEncoding), messageEncoding)));
NetHttpBindingTests.4.0.0.cs (1)
28factory = new ChannelFactory<IWcfService>(binding, new EndpointAddress(Endpoints.HttpBaseAddress_NetHttp + Enum.GetName(typeof(NetHttpMessageEncoding), messageEncoding)));
NetHttpsBindingTests.4.1.0.cs (1)
31factory = new ChannelFactory<IWcfService>(netHttpsBinding, new EndpointAddress(Endpoints.HttpBaseAddress_NetHttps + Enum.GetName(typeof(NetHttpMessageEncoding), messageEncoding)));
WSHttpBindingTests.cs (1)
27factory = new ChannelFactory<IWcfService>(binding, new EndpointAddress(Endpoints.WSHttpBindingBaseAddress + Enum.GetName(typeof(WSMessageEncoding), messageEncoding)));
Binding.WS.FederationHttp.IntegrationTests (2)
WSFederationHttpBindingTests.cs (2)
39tokenTargetAddress = Endpoints.Https_SecModeTransWithMessCred_ClientCredTypeIssuedTokenSaml2 + endpointSuffix + (useSecureConversation ? "/sc" : string.Empty) + "/" + Enum.GetName(typeof(WSMessageEncoding), encoding); 185foreach (WSMessageEncoding messageEncoding in Enum.GetValues(typeof(WSMessageEncoding)))
CodeStyleConfigFileGenerator (5)
Program.cs (1)
69foreach (var analysisMode in Enum.GetValues<AnalysisMode>())
src\roslyn\src\Dependencies\Contracts\EnumExtensions.cs (4)
12public static TEnum[] GetValues<TEnum>() where TEnum : struct, Enum 13=> Enum.GetValues<TEnum>(); 15public static string[] GetNames<TEnum>() where TEnum : struct, Enum 16=> Enum.GetNames<TEnum>();
ConfigurationSchemaGenerator (1)
RuntimeSource\Configuration.Binder\Specs\TypeIndex.cs (1)
86public static string GetGenericTypeDisplayString(CollectionWithCtorInitSpec type, Enum genericProxyTypeName)
ConfigurationSchemaGenerator.Tests (1)
VariousTypes.cs (1)
61/// A value of type <see cref="Enum"/>.
crossgen2 (3)
Crossgen2RootCommand.cs (3)
318Console.WriteLine(String.Format(SR.SwitchWithDefaultHelp, "--type-validation", String.Join("', '", Enum.GetNames<TypeValidationRule>()), nameof(TypeValidationRule.Automatic))); 323Console.WriteLine(String.Format(SR.LayoutOptionExtraHelp, "--method-layout", String.Join("', '", Enum.GetNames<MethodLayoutAlgorithm>()))); 325Console.WriteLine(String.Format(SR.LayoutOptionExtraHelp, "--file-layout", String.Join("', '", Enum.GetNames<FileLayoutAlgorithm>())));
CSharpSyntaxGenerator (8)
Grammar\GrammarGenerator.cs (2)
362private static IEnumerable<TEnum> GetMembers<TEnum>() where TEnum : struct, Enum 363=> (IEnumerable<TEnum>)Enum.GetValues(typeof(TEnum));
src\roslyn\src\Compilers\CSharp\Portable\Syntax\SyntaxKindFacts.cs (6)
22Debug.Assert(Enum.IsDefined(typeof(SyntaxKind), (SyntaxKind)i)); 151Debug.Assert(Enum.IsDefined(typeof(SyntaxKind), (SyntaxKind)i)); 181Debug.Assert(Enum.IsDefined(typeof(SyntaxKind), (SyntaxKind)i)); 187Debug.Assert(Enum.IsDefined(typeof(SyntaxKind), (SyntaxKind)i)); 193Debug.Assert(Enum.IsDefined(typeof(SyntaxKind), (SyntaxKind)i)); 1245Debug.Assert(Enum.IsDefined(typeof(SyntaxKind), (SyntaxKind)i));
datacollector (1)
DataCollectorMain.cs (1)
85var isTraceLevelArgValid = Enum.IsDefined(typeof(PlatformTraceLevel), traceLevelInt);
datacollector.arm64 (1)
src\vstest\src\datacollector\DataCollectorMain.cs (1)
85var isTraceLevelArgValid = Enum.IsDefined(typeof(PlatformTraceLevel), traceLevelInt);
dotnet (3)
CliSchema.cs (1)
205VerbosityOptions o => Enum.GetName(o),
src\sdk\src\Common\EnvironmentVariableNames.cs (1)
105return Enum.TryParse(span, ignoreCase: true, out architecture);
Telemetry\TelemetryFilter.cs (1)
65{ "verbosity", Enum.GetName(verbosity)}
dotnet-dev-certs (1)
Program.cs (1)
426if (exportFormat.HasValue() && !Enum.TryParse(exportFormat.Value(), ignoreCase: true, out format))
dotnet-svcutil-lib (31)
FrameworkFork\Microsoft.Xml\Xml\schema\GenerateConverter.cs (1)
982return (XmlTypeCode)Enum.Parse(typeof(XmlTypeCode), name, true);
FrameworkFork\Microsoft.Xml\Xml\Serialization\CodeGenerator.cs (3)
1131Ldc(((IConvertible)o).ToType(Enum.GetUnderlyingType(valueType), null)); 1524Ldelem(Enum.GetUnderlyingType(arrayElementType)); 1605Stelem(Enum.GetUnderlyingType(arrayElementType));
FrameworkFork\Microsoft.Xml\Xml\Serialization\SoapReflectionImporter.cs (2)
777string strValue = Enum.Format(a.SoapDefaultValue.GetType(), a.SoapDefaultValue, "G").Replace(",", " "); 778string numValue = Enum.Format(a.SoapDefaultValue.GetType(), a.SoapDefaultValue, "D");
FrameworkFork\Microsoft.Xml\Xml\Serialization\XmlCodeExporter.cs (1)
912attribute.Arguments.Add(new CodeAttributeArgument("Form", new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(typeof(XmlSchemaForm).FullName), Enum.Format(typeof(XmlSchemaForm), form, "G"))));
FrameworkFork\Microsoft.Xml\Xml\Serialization\XmlReflectionImporter.cs (2)
2145string strValue = Enum.Format(t, a.XmlDefaultValue, "G").Replace(",", " "); 2146string numValue = Enum.Format(t, a.XmlDefaultValue, "D");
FrameworkFork\Microsoft.Xml\Xml\Serialization\XmlSerializationWriterILGen.cs (5)
225ilg.Ldc(Enum.Parse(mapping.TypeDesc.Type, enumDefaultValue, false)); 649ilg.Ldc(Enum.ToObject(mapping.TypeDesc.Type, c.Value)); 2388eValue = Enum.ToObject(choiceMapping.TypeDesc.Type, choiceMapping.Constants[i].Value); 2402eValue = Enum.ToObject(choiceMapping.TypeDesc.Type, choiceMapping.Constants[i].Value); 2494ilg.Ldc(Enum.Parse(type, memberName, false));
FrameworkFork\System.Runtime.Serialization\System\Runtime\Serialization\CodeGenerator.cs (3)
981Ldc(Convert.ChangeType(o, Enum.GetUnderlyingType(valueType), null)); 1270Ldelem(Enum.GetUnderlyingType(arrayElementType)); 1333Stelem(Enum.GetUnderlyingType(arrayElementType));
FrameworkFork\System.Runtime.Serialization\System\Runtime\Serialization\DataContract.cs (1)
930else if (type == typeof(Enum) || type == typeof(ValueType))
FrameworkFork\System.Runtime.Serialization\System\Runtime\Serialization\EnumDataContract.cs (3)
194Type baseType = Enum.GetUnderlyingType(type); 422return Enum.ToObject(UnderlyingType, (object)(ulong)longValue); 423return Enum.ToObject(UnderlyingType, (object)longValue);
FrameworkFork\System.ServiceModel\Extensions\ReflectionExtensions.cs (1)
165return GetTypeCode(Enum.GetUnderlyingType(type));
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\HttpTransportBindingElement.cs (1)
550if (!Enum.TryParse<TransferMode>(transferMode, true, out result) || !TransferModeHelper.IsDefined(result) || result == TransferMode.Buffered)
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\SecurityAttributeGenerationHelper.cs (1)
43else if (value is Enum)
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\WindowsStreamSecurityBindingElement.cs (1)
121windowsBindingElement.ProtectionLevel = (ProtectionLevel)Enum.Parse(typeof(ProtectionLevel), protectionLevelString);
FrameworkFork\System.ServiceModel\System\ServiceModel\Description\OperationGenerator.cs (1)
1028return new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(type), Enum.Format(type, val, "G"));
FrameworkFork\System.ServiceModel\System\ServiceModel\Description\PrincipalPermissionMode.cs (1)
20return Enum.IsDefined(typeof(PrincipalPermissionMode), principalPermissionMode);
FrameworkFork\System.ServiceModel\System\ServiceModel\Description\ServiceContractGenerator.cs (1)
181return new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(typeof(EnumType)), Enum.Format(typeof(EnumType), value, "G"));
FrameworkFork\System.ServiceModel\System\ServiceModel\Security\SecurityUtils.cs (1)
89foreach (var protocol in Enum.GetValues(typeof(SslProtocols)))
HelpGenerator.cs (1)
51ArgumentInfo.CreateParameterHelpInfo(CommandProcessorOptions.Switches.Verbosity.Name, SR.ParametersVerbosity, string.Format(SR.HelpVerbosityFormat, string.Join(", ", System.Enum.GetNames(typeof(Verbosity))), CommandProcessorOptions.Switches.Verbosity.Abbreviation)),
Shared\Options\OptionValueParser.cs (1)
239var supportedValues = string.Format(CultureInfo.CurrentCulture, Shared.Resources.ErrorOnInvalidEnumSupportedValuesFormat, string.Join(", ", Enum.GetNames(typeof(TValue))));
Extensibility.WebSockets.IntegrationTests (10)
WebSocketTests.4.1.0.cs (10)
48endpointAddress = Endpoints.WebSocketHttpDuplexStreamed_Address + Enum.GetName(typeof(NetHttpMessageEncoding), messageEncoding); 142endpointAddress = new EndpointAddress(Endpoints.WebSocketHttpDuplexBuffered_Address + Enum.GetName(typeof(NetHttpMessageEncoding), messageEncoding)); 214endpointAddress = new EndpointAddress(Endpoints.WebSocketHttpDuplexBuffered_Address + Enum.GetName(typeof(NetHttpMessageEncoding), messageEncoding)); 289endpointAddress = Endpoints.WebSocketHttpsDuplexStreamed_Address + Enum.GetName(typeof(NetHttpMessageEncoding), messageEncoding); 387endpointAddress = new EndpointAddress(Endpoints.WebSocketHttpsDuplexBuffered_Address + Enum.GetName(typeof(NetHttpMessageEncoding), messageEncoding)); 451endpointAddress = new EndpointAddress(Endpoints.WebSocketHttpRequestReplyStreamed_Address + Enum.GetName(typeof(NetHttpMessageEncoding), messageEncoding)); 520endpointAddress = new EndpointAddress(Endpoints.WebSocketHttpRequestReplyBuffered_Address + Enum.GetName(typeof(NetHttpMessageEncoding), messageEncoding)); 578endpointAddress = new EndpointAddress(Endpoints.WebSocketHttpRequestReplyBuffered_Address + Enum.GetName(typeof(NetHttpMessageEncoding), messageEncoding)); 638endpointAddress = new EndpointAddress(Endpoints.WebSocketHttpsRequestReplyBuffered_Address + Enum.GetName(typeof(NetHttpMessageEncoding), messageEncoding)); 698endpointAddress = new EndpointAddress(Endpoints.WebSocketHttpsRequestReplyBuffered_Address + Enum.GetName(typeof(NetHttpMessageEncoding), messageEncoding));
GenerateDocumentationAndConfigFiles (35)
Program.cs (1)
997foreach (var analysisMode in Enum.GetValues<AnalysisMode>())
src\roslyn\src\Compilers\Core\Portable\InternalUtilities\EnumUtilties.cs (3)
16return (T[])Enum.GetValues(typeof(T)); 20internal static bool ContainsAllValues<T>(int mask) where T : struct, Enum, IConvertible 33internal static bool ContainsValue<T>(T value) where T : struct, Enum
src\roslyn\src\Dependencies\Contracts\EnumExtensions.cs (4)
12public static TEnum[] GetValues<TEnum>() where TEnum : struct, Enum 13=> Enum.GetValues<TEnum>(); 15public static string[] GetNames<TEnum>() where TEnum : struct, Enum 16=> Enum.GetNames<TEnum>();
src\roslyn\src\RoslynAnalyzers\Microsoft.CodeAnalysis.Analyzers\Core\MetaAnalyzers\ReleaseTrackingHelper.cs (1)
296if (Enum.TryParse(severityPart, ignoreCase: true, out DiagnosticSeverity parsedSeverity))
src\roslyn\src\RoslynAnalyzers\Utilities\Compiler\Options\AnalyzerOptionsExtensions.cs (3)
27ImmutableHashSet.CreateRange(Enum.GetValues<OutputKind>()); 144tryParseValue: static (value, out result) => Enum.TryParse(value, ignoreCase: true, result: out result), 164if (Enum.TryParse(kindStr, ignoreCase: true, result: out TEnum kind))
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CodeStyle\CodeStyleOption2`1.cs (1)
180var severity = (DiagnosticSeverity)Enum.Parse(typeof(DiagnosticSeverity), severityAttribute.Value);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\NamingStyles\NamingStyle.cs (1)
480capitalizationScheme: (Capitalization)Enum.Parse(typeof(Capitalization), namingStyleElement.Attribute(nameof(CapitalizationScheme)).Value));
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\NamingStyles\Serialization\SerializableNamingRule.cs (1)
38EnforcementLevel = ((DiagnosticSeverity)Enum.Parse(typeof(DiagnosticSeverity), namingRuleElement.Attribute(nameof(EnforcementLevel))!.Value)).ToReportDiagnostic(),
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\NamingStyles\Serialization\SymbolSpecification.cs (5)
310=> (Accessibility)Enum.Parse(typeof(Accessibility), accessibilityElement.Value); 421var symbolKind = (SymbolKind)Enum.Parse(typeof(SymbolKind), symbolKindElement.Value); 433=> new((TypeKind)Enum.Parse(typeof(TypeKind), typeKindElement.Value)); 436=> new((MethodKind)Enum.Parse(typeof(MethodKind), methodKindElement.Value)); 536=> new((ModifierKindEnum)Enum.Parse(typeof(ModifierKindEnum), modifierElement.Value));
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Options\EditorConfigValueSerializer.cs (9)
104public static EditorConfigValueSerializer<T> CreateSerializerForEnum<T>() where T : struct, Enum 112public static EditorConfigValueSerializer<T> CreateSerializerForEnum<T>(BidirectionalMap<string, T> map) where T : struct, Enum 119public static EditorConfigValueSerializer<T> CreateSerializerForEnum<T>(BidirectionalMap<string, T> map, ImmutableDictionary<string, T> alternative) where T : struct, Enum 127public static EditorConfigValueSerializer<T> CreateSerializerForEnum<T>(IEnumerable<(string name, T value)> entries, IEnumerable<(string name, T value)> alternativeEntries) where T : struct, Enum 136public static EditorConfigValueSerializer<T?> CreateSerializerForNullableEnum<T>() where T : struct, Enum 158private static bool TryParseEnum<T>(string str, out T result) where T : struct, Enum 173return Enum.TryParse(str, ignoreCase: true, out result); 209where TFromEnum : struct, Enum 210where TToEnum : struct, Enum
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Simplification\SpecialTypeAnnotation.cs (1)
27=> (SpecialType)Enum.Parse(typeof(SpecialType), arg);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EnumValueUtilities.cs (2)
144where TFromEnum : struct, Enum 145where TToEnum : struct, Enum
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\OptionalExtensions.cs (2)
17where TFromEnum : struct, Enum 18where TToEnum : struct, Enum
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\TypeInferenceService\AbstractTypeInferenceService.AbstractTypeInferrer.cs (1)
119symbol.Name == nameof(Enum.HasFlag) &&
ILAssembler (3)
GrammarVisitor.cs (3)
49where T : struct, Enum 983return new((new((TypeAttributes)Enum.Parse(typeof(TypeAttributes), context.GetText(), true)), null, false)); 3279return (ILOpCode)Enum.Parse(typeof(ILOpCode), token.Text.Replace('.', '_'), ignoreCase: true);
ilc (1)
Program.cs (1)
617: Enum.Parse<MethodBodyFoldingMode>(Get(_command.MethodBodyFolding), ignoreCase: true);
ILCompiler.Compiler (6)
Compiler\DescriptorMarker.cs (1)
231if (Enum.TryParse(attribute, true, out TypePreserve result))
src\runtime\src\coreclr\tools\Common\Compiler\DependencyAnalysis\Target_Wasm\WasmTypes.cs (1)
51if (Enum.IsDefined(typeof(WasmValueType), (byte)ty))
src\runtime\src\coreclr\tools\Common\Compiler\InstructionSetSupport.cs (2)
177foreach (TargetArchitecture arch in Enum.GetValues<TargetArchitecture>()) 188foreach (TargetArchitecture arch in Enum.GetValues<TargetArchitecture>())
src\runtime\src\tools\illink\src\ILLink.Shared\Annotations.cs (1)
81Enum.GetValues(typeof(DynamicallyAccessedMemberTypes))
src\runtime\src\tools\illink\src\ILLink.Shared\TrimAnalysis\IntrinsicId.cs (1)
216/// <see cref="System.Enum.GetValues(System.Type)"/>
ILCompiler.MetadataTransform (3)
Internal\Metadata\NativeFormat\Writer\NativeMetadataWriter.cs (2)
870string str = Enum.GetName(Attributes); 898return string.Join(" ", Enum.GetName(CallingConvention),
src\runtime\src\coreclr\tools\Common\Internal\Metadata\NativeFormat\NativeMetadataReader.cs (1)
127return string.Format("{1} : {0,8:X8}", _value, Enum.GetName(typeof(HandleType), this.HandleType));
ILCompiler.ReadyToRun (5)
Compiler\DependencyAnalysis\ReadyToRun\ReadyToRunInstructionSetSupportSignature.cs (1)
72return Enum.Parse<ReadyToRunInstructionSet>(instructionSetString);
Compiler\ReadyToRunXmlRootProvider.cs (1)
212if (Enum.TryParse(attribute, true, out TypePreserve result))
src\runtime\src\coreclr\tools\Common\Compiler\DependencyAnalysis\Target_Wasm\WasmTypes.cs (1)
51if (Enum.IsDefined(typeof(WasmValueType), (byte)ty))
src\runtime\src\coreclr\tools\Common\Compiler\InstructionSetSupport.cs (2)
177foreach (TargetArchitecture arch in Enum.GetValues<TargetArchitecture>()) 188foreach (TargetArchitecture arch in Enum.GetValues<TargetArchitecture>())
illink (5)
ILLink.RoslynAnalyzer (3)
COMAnalyzer.cs (1)
79if (Enum.IsDefined(typeof(UnmanagedType), unmanagedType))
src\runtime\src\tools\illink\src\ILLink.Shared\Annotations.cs (1)
81Enum.GetValues(typeof(DynamicallyAccessedMemberTypes))
src\runtime\src\tools\illink\src\ILLink.Shared\TrimAnalysis\IntrinsicId.cs (1)
216/// <see cref="System.Enum.GetValues(System.Type)"/>
Microsoft.Analyzers.Local (4)
ApiLifecycle\Model\Field.cs (1)
20_ = Enum.TryParse<Stage>(enumString, out var stage);
ApiLifecycle\Model\Method.cs (1)
20if (Enum.TryParse<Stage>(enumString, out var stage))
ApiLifecycle\Model\Prop.cs (1)
20_ = Enum.TryParse<Stage>(stageString, out var stage);
ApiLifecycle\Model\TypeDef.cs (1)
24_ = Enum.TryParse<Stage>(value[nameof(Stage)].AsString, out var stage);
Microsoft.Analyzers.Local.Tests (2)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 226if (!Enum.IsDefined<T>(argument))
Microsoft.AspNetCore.App.Analyzers (1)
RouteEmbeddedLanguage\Infrastructure\EmbeddedLanguageCommentOptions.cs (1)
22internal static class EmbeddedLanguageCommentOptions<TOptions> where TOptions : struct, Enum
Microsoft.AspNetCore.AsyncState (2)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 226if (!Enum.IsDefined<T>(argument))
Microsoft.AspNetCore.Components (6)
BindConverter.cs (6)
1604private static bool ConvertToEnum<T>(object? obj, CultureInfo? _, out T value) where T : struct, Enum 1613if (!Enum.TryParse<T>(text, out var converted)) 1619if (!Enum.IsDefined(typeof(T), converted)) 1629private static bool ConvertToNullableEnum<T>(object? obj, CultureInfo? _, out T? value) where T : struct, Enum 1638if (!Enum.TryParse<T>(text, out var converted)) 1644if (!Enum.IsDefined(typeof(T), converted))
Microsoft.AspNetCore.Components.Endpoints (4)
FormMapping\Converters\EnumConverter.cs (2)
9internal class EnumConverter<TEnum> : FormDataConverter<TEnum>, ISingleValueConverter<TEnum> where TEnum : struct, Enum 15if (Enum.TryParse(value, ignoreCase: true, out result))
TempData\JsonTempDataSerializer.cs (1)
147normalizedData[kvp.Key] = kvp.Value is Enum enumValue
TempData\TempDataCascadingValueSupplier.cs (1)
153return Enum.ToObject(_underlyingType, intValue);
Microsoft.AspNetCore.Connections.Abstractions (1)
src\aspnetcore\src\Shared\ParameterDefaultValue\ParameterDefaultValue.cs (1)
50defaultValue = Enum.ToObject(underlyingType, defaultValue);
Microsoft.AspNetCore.DataProtection (2)
AuthenticatedEncryption\ConfigurationModel\AuthenticatedEncryptorDescriptorDeserializer.cs (2)
34configuration.EncryptionAlgorithm = (EncryptionAlgorithm)Enum.Parse(typeof(EncryptionAlgorithm), (string)encryptionElement.Attribute("algorithm")!); 40configuration.ValidationAlgorithm = (ValidationAlgorithm)Enum.Parse(typeof(ValidationAlgorithm), (string)validationElement.Attribute("algorithm")!);
Microsoft.AspNetCore.Diagnostics.HealthChecks (1)
HealthCheckOptions.cs (1)
52var missingHealthStatus = Enum.GetValues<HealthStatus>().Except(mapping.Keys).ToList();
Microsoft.AspNetCore.HeaderParsing (2)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 226if (!Enum.IsDefined<T>(argument))
Microsoft.AspNetCore.Http.Abstractions (1)
src\aspnetcore\src\Shared\ParameterDefaultValue\ParameterDefaultValue.cs (1)
50defaultValue = Enum.ToObject(underlyingType, defaultValue);
Microsoft.AspNetCore.Http.Extensions (7)
RequestDelegateFactory.cs (1)
2032converted = Enum.ToObject(targetType, defaultValue);
src\aspnetcore\src\Components\Endpoints\src\FormMapping\Converters\EnumConverter.cs (2)
9internal class EnumConverter<TEnum> : FormDataConverter<TEnum>, ISingleValueConverter<TEnum> where TEnum : struct, Enum 15if (Enum.TryParse(value, ignoreCase: true, out result))
src\aspnetcore\src\Shared\ParameterBindingMethodCache.cs (4)
510methodInfo = typeof(Enum).GetMethod( 511nameof(Enum.TryParse), 517methodInfo = typeof(Enum).GetMethod( 518nameof(Enum.TryParse),
Microsoft.AspNetCore.Mvc.Abstractions (10)
ModelBinding\ModelMetadata.cs (6)
263/// Gets the ordered and grouped display names and values of all <see cref="Enum"/> values in 268/// <see cref="Enum"/> field groups, names and values. <c>null</c> if <see cref="IsEnum"/> is <c>false</c>. 273/// Gets the names and values of all <see cref="Enum"/> values in <see cref="UnderlyingOrModelType"/>. 276/// An <see cref="IReadOnlyDictionary{String, String}"/> of mappings between <see cref="Enum"/> field names 327/// Gets a value indicating whether <see cref="UnderlyingOrModelType"/> is for an <see cref="Enum"/>. 336/// Gets a value indicating whether <see cref="UnderlyingOrModelType"/> is for an <see cref="Enum"/> with an
src\aspnetcore\src\Shared\ParameterBindingMethodCache.cs (4)
510methodInfo = typeof(Enum).GetMethod( 511nameof(Enum.TryParse), 517methodInfo = typeof(Enum).GetMethod( 518nameof(Enum.TryParse),
Microsoft.AspNetCore.Mvc.Core (10)
ModelBinding\Binders\EnumTypeModelBinder.cs (3)
12/// <see cref="IModelBinder"/> implementation to bind models for types deriving from <see cref="Enum"/>. 82Enum.GetUnderlyingType(modelType), 87return Enum.IsDefined(modelType, model);
ModelBinding\Binders\EnumTypeModelBinderProvider.cs (1)
12/// A <see cref="IModelBinderProvider"/> for types deriving from <see cref="Enum"/>.
ModelBinding\Metadata\DisplayMetadata.cs (4)
141/// Gets the ordered and grouped display names and values of all <see cref="System.Enum"/> values in 148/// Gets the names and values of all <see cref="System.Enum"/> values in 174/// <see cref="System.Enum"/>. See <see cref="ModelMetadata.IsEnum"/>. 181/// <see cref="System.Enum"/> with an associated <see cref="System.FlagsAttribute"/>. See
ModelBinding\ModelBindingHelper.cs (1)
711return Enum.ToObject(destinationType, value);
src\aspnetcore\src\Shared\ParameterDefaultValue\ParameterDefaultValue.cs (1)
50defaultValue = Enum.ToObject(underlyingType, defaultValue);
Microsoft.AspNetCore.Mvc.DataAnnotations (2)
DataAnnotationsMetadataProvider.cs (2)
184var enumFields = Enum.GetNames(underlyingType) 191var value = ((Enum)field.GetValue(obj: null)!).ToString("d");
Microsoft.AspNetCore.Mvc.ViewFeatures (19)
DefaultHtmlGenerator.cs (7)
986var enumValue = value as Enum; 999enumValue = (Enum)methodInfo.Invoke(obj: null, parameters: new[] { stringValue }); 1383private static Enum ConvertEnumFromInteger(object value, Type targetType) 1387return (Enum)Enum.ToObject(targetType, value); 1399if (Enum.TryParse(value, out TEnum enumValue))
HtmlHelper.cs (4)
374nameof(Enum).ToLowerInvariant(), 392nameof(Enum).ToLowerInvariant(), 1365/// Thrown if <paramref name="metadata"/>'s <see cref="ModelMetadata.ModelType"/> is not an <see cref="Enum"/> 1376nameof(Enum).ToLowerInvariant(),
IHtmlGenerator.cs (3)
585/// If the <paramref name="expression"/> result or the element type is an <see cref="System.Enum"/>, returns a 586/// <see cref="string"/> containing the integer representation of the <see cref="System.Enum"/> value as well 587/// as all <see cref="System.Enum"/> names for that value. Otherwise returns the default <see cref="string"/>
Infrastructure\DefaultTempDataSerializer.cs (1)
158case Enum _:
ModelExplorerExtensions.cs (1)
48if (modelExplorer.Metadata.IsEnum && modelExplorer.Model is Enum modelEnum)
Rendering\IHtmlHelper.cs (2)
380/// Thrown if <typeparamref name="TEnum"/> is not an <see cref="Enum"/> or if it has a 394/// Thrown if <paramref name="enumType"/> is not an <see cref="Enum"/> or if it has a
TemplateBuilder.cs (1)
102else if (viewData.ModelMetadata.IsEnum && _model is Enum modelEnum)
Microsoft.AspNetCore.Razor.Utilities.Shared (5)
src\roslyn\src\Razor\src\Shared\Microsoft.AspNetCore.Razor.SharedUtilities\EnumExtensions.cs (5)
15where T : unmanaged, Enum 44where T : unmanaged, Enum 72where T : unmanaged, Enum 88where T : unmanaged, Enum 118where T : unmanaged, Enum
Microsoft.AspNetCore.Rewrite (1)
IISUrlRewrite\UrlRewriteFileParser.cs (1)
277else if (!Enum.TryParse(attribute.Value, ignoreCase: true, result: out enumResult))
Microsoft.AspNetCore.Server.Kestrel.Core (6)
Internal\Certificates\CertificateConfigLoader.cs (1)
332storeLocation = (StoreLocation)Enum.Parse(typeof(StoreLocation), location, ignoreCase: true);
Internal\ConfigurationReader.cs (3)
168if (Enum.TryParse<ClientCertificateMode>(clientCertificateMode, ignoreCase: true, out var result)) 178if (Enum.TryParse<HttpProtocols>(protocols, ignoreCase: true, out var result)) 202if (Enum.TryParse(current, ignoreCase: true, out SslProtocols parsed))
Internal\ThrowHelper.cs (1)
24Debug.Assert(Enum.IsDefined(typeof(ExceptionArgument), argument), "The enum value is not defined, please check the ExceptionArgument Enum.");
src\aspnetcore\src\Shared\Buffers.MemoryPool\MemoryPoolThrowHelper.cs (1)
111Debug.Assert(Enum.IsDefined(typeof(ExceptionArgument), argument), "The enum value is not defined, please check the ExceptionArgument Enum.");
Microsoft.AspNetCore.Server.Kestrel.Transport.Quic (1)
src\aspnetcore\src\Shared\Buffers.MemoryPool\MemoryPoolThrowHelper.cs (1)
111Debug.Assert(Enum.IsDefined(typeof(ExceptionArgument), argument), "The enum value is not defined, please check the ExceptionArgument Enum.");
Microsoft.AspNetCore.Testing (2)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 226if (!Enum.IsDefined<T>(argument))
Microsoft.Build (10)
BackEnd\Client\MSBuildClientPacketPump.cs (1)
267NodePacketType packetType = (NodePacketType)Enum.ToObject(typeof(NodePacketType), headerByte[0]);
BackEnd\Components\Logging\BuildErrorTelemetryTracker.cs (1)
42private readonly int[] _errorCounts = new int[Enum.GetValues(typeof(ErrorCategory)).Length];
BackEnd\Components\RequestBuilder\IntrinsicTasks\ItemGroupIntrinsicTask.cs (1)
111Enum.TryParse(child.MatchOnMetadataOptions, out matchOnMetadataOptions);
Evaluation\Expander.cs (1)
4647coercedArguments[n] = Enum.Parse(enumType, argument);
Evaluation\Expander\ArgumentParser.cs (1)
303return Enum.TryParse(comparisonTypeName, out arg1);
Evaluation\Expander\WellKnownFunctions.cs (1)
652else if (ParseArgs.TryGetArgs(args, out string? arg1, out string? arg2) && Enum.TryParse<IntrinsicFunctions.StringHashingAlgorithm>(arg2, true, out var hashAlgorithm) && arg1 != null && arg2 != null)
Evaluation\IntrinsicFunctions.cs (1)
286RegistryView view = (RegistryView)Enum.Parse(typeof(RegistryView), viewAsString, true);
Evaluation\LazyItemEvaluator.cs (1)
607if (Enum.TryParse(itemElement.MatchOnMetadataOptions, out MatchOnMetadataOptions options))
Logging\TerminalLogger\TerminalLogger.cs (1)
344if (Enum.TryParse(verbosityArg, true, out LoggerVerbosity parsedVerbosity))
Resources\Constants.cs (1)
295availableStaticMethods.TryAdd("System.Enum", new Tuple<string, Type>(null, typeof(Enum)));
Microsoft.Build.Framework (11)
AssemblyUtilities.cs (2)
136Enum.IsDefined(cultureTypesType, "AllCultures"), "GetCulture is expected to accept CultureTypes.AllCultures"); 138var allCulturesEnumValue = Enum.Parse(cultureTypesType, "AllCultures", true);
BinaryTranslator.cs (3)
515where T : struct, Enum 519value = (T)Enum.ToObject(enumType, numericValue); 1332where T : struct, Enum
DotnetHostEnvironmentHelper.cs (1)
31private static readonly string[] _archSpecificRootVars = Array.ConvertAll(Enum.GetNames<Architecture>(), name => $"{DotnetRootEnvVarName}_{name.ToUpperInvariant()}");
ITranslator.cs (1)
292where T : struct, Enum;
NodeMode.cs (3)
100if (Enum.IsDefined(typeof(NodeMode), intValue)) 110if (Enum.TryParse(value, ignoreCase: true, out NodeMode enumValue) && Enum.IsDefined(typeof(NodeMode), enumValue))
Utilities\ProcessExtensions.cs (1)
81return Enum.TryParse(value, ignoreCase: true, out CommandLineSource parsed)
Microsoft.Build.Tasks.CodeAnalysis (4)
src\roslyn\src\Dependencies\Contracts\EnumExtensions.cs (4)
12public static TEnum[] GetValues<TEnum>() where TEnum : struct, Enum 13=> Enum.GetValues<TEnum>(); 15public static string[] GetNames<TEnum>() where TEnum : struct, Enum 16=> Enum.GetNames<TEnum>();
Microsoft.Build.Tasks.Core (19)
AssemblyDependency\ResolveAssemblyReference.cs (1)
272if (!Enum.TryParse<WarnOrErrorOnTargetArchitectureMismatchBehavior>(value, /*ignoreCase*/true, out _warnOrErrorOnTargetArchitectureMismatch))
FileIO\GetFileHash.cs (1)
144=> Enum.TryParse<HashEncoding>(value, /*ignoreCase:*/ true, out encoding);
FormatVersion.cs (1)
78_formatType = (_FormatType)Enum.Parse(typeof(_FormatType), FormatType, true);
GenerateApplicationManifest.cs (1)
346_manifestType = (_ManifestType)Enum.Parse(typeof(_ManifestType), ManifestType, true);
GenerateDeploymentManifest.cs (2)
279_updateMode = (UpdateMode)Enum.Parse(typeof(UpdateMode), UpdateMode, true); 296_updateUnit = (UpdateUnit)Enum.Parse(typeof(UpdateUnit), UpdateUnit, true);
GenerateManifestBase.cs (2)
372return (AssemblyType)Enum.Parse(typeof(AssemblyType), value, true); 403return (DependencyType)Enum.Parse(typeof(DependencyType), value, true);
ManifestUtil\DeployManifest.cs (2)
527try { return (UpdateMode)Enum.Parse(typeof(UpdateMode), _updateMode, true); } 543try { return (UpdateUnit)Enum.Parse(typeof(UpdateUnit), _updateUnit, true); }
Message.cs (1)
62messageImportance = (MessageImportance)Enum.Parse(typeof(MessageImportance), Importance, true /* case-insensitive */);
MSBuildInternalMessage.cs (2)
58if (Enum.TryParse(Severity, ignoreCase: true, out BuildMessageSeverity severity)) 71MessageImportance importance = (MessageImportance)Enum.Parse(typeof(MessageImportance), MessageImportance, true);
ResolveManifestFiles.cs (1)
1029return (PublishState)Enum.Parse(typeof(PublishState), value, false);
ResolveSDKReference.cs (2)
1126Enum.TryParse<SDKType>(sdkTypeFromMetadata, out SDKType sdkType); 1165return !String.IsNullOrEmpty(multipleVersionsValue) && Enum.TryParse<MultipleVersionSupport>(multipleVersionsValue, /*ignoreCase*/true, out _supportsMultipleVersions);
RoslynCodeTaskFactory\RoslynCodeTaskFactory.cs (2)
489if (!Enum.TryParse(typeAttribute.Value.Trim(), ignoreCase: true, result: out RoslynCodeTaskFactoryCodeType codeType)) 491log.LogErrorWithCodeFromResources("CodeTaskFactory.InvalidCodeType", typeAttribute.Value, String.Join(", ", Enum.GetNames(typeof(RoslynCodeTaskFactoryCodeType))));
Touch.cs (1)
159if (!Enum.TryParse(Importance, ignoreCase: true, out messageImportance))
Microsoft.Build.Utilities.Core (4)
SDKManifest.cs (2)
430Enum.TryParse(value, out _sdkType); 459=> !string.IsNullOrEmpty(multipleVersionsValue) && Enum.TryParse(multipleVersionsValue, /*ignoreCase*/true, out MultipleVersionSupport supportsMultipleVersions)
ToolTask.cs (2)
1380_standardErrorImportanceToUse = (MessageImportance)Enum.Parse(typeof(MessageImportance), StandardErrorImportance, true /* case-insensitive */); 1400_standardOutputImportanceToUse = (MessageImportance)Enum.Parse(typeof(MessageImportance), StandardOutputImportance, true /* case-insensitive */);
Microsoft.CodeAnalysis (11)
InternalUtilities\EnumUtilties.cs (3)
16return (T[])Enum.GetValues(typeof(T)); 20internal static bool ContainsAllValues<T>(int mask) where T : struct, Enum, IConvertible 33internal static bool ContainsValue<T>(T value) where T : struct, Enum
InternalUtilities\JsonWriter.cs (3)
109public void Write<T>(string key, T value) where T : struct, Enum 195public void Write<T>(T value) where T : struct, Enum 200public void Write<T>(T? value) where T : struct, Enum
SpecialType.cs (1)
36/// Indicates that the type is <see cref="Enum"/>.
src\roslyn\src\Dependencies\Contracts\EnumExtensions.cs (4)
12public static TEnum[] GetValues<TEnum>() where TEnum : struct, Enum 13=> Enum.GetValues<TEnum>(); 15public static string[] GetNames<TEnum>() where TEnum : struct, Enum 16=> Enum.GetNames<TEnum>();
Microsoft.CodeAnalysis.Analyzers (37)
MetaAnalyzers\DiagnosticDescriptorCreationAnalyzer.cs (2)
1131Enum.TryParse(fieldReference.Field.Name, out DiagnosticSeverity parsedSeverity)) 1142Enum.TryParse(fieldReference2.Field.Name, out RuleLevel parsedRuleLevel))
MetaAnalyzers\ReleaseTrackingHelper.cs (1)
296if (Enum.TryParse(severityPart, ignoreCase: true, out DiagnosticSeverity parsedSeverity))
src\roslyn\src\Compilers\Core\Portable\InternalUtilities\EnumUtilties.cs (3)
16return (T[])Enum.GetValues(typeof(T)); 20internal static bool ContainsAllValues<T>(int mask) where T : struct, Enum, IConvertible 33internal static bool ContainsValue<T>(T value) where T : struct, Enum
src\roslyn\src\Dependencies\Contracts\EnumExtensions.cs (5)
18extension(Enum) 20public static TEnum[] GetValues<TEnum>() where TEnum : struct, Enum 21=> (TEnum[])Enum.GetValues(typeof(TEnum)); 23public static string[] GetNames<TEnum>() where TEnum : struct, Enum 24=> Enum.GetNames(typeof(TEnum));
src\roslyn\src\RoslynAnalyzers\Utilities\Compiler\Options\AnalyzerOptionsExtensions.cs (3)
27ImmutableHashSet.CreateRange(Enum.GetValues<OutputKind>()); 144tryParseValue: static (value, out result) => Enum.TryParse(value, ignoreCase: true, result: out result), 164if (Enum.TryParse(kindStr, ignoreCase: true, result: out TEnum kind))
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CodeStyle\CodeStyleOption2`1.cs (1)
180var severity = (DiagnosticSeverity)Enum.Parse(typeof(DiagnosticSeverity), severityAttribute.Value);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\NamingStyles\NamingStyle.cs (1)
480capitalizationScheme: (Capitalization)Enum.Parse(typeof(Capitalization), namingStyleElement.Attribute(nameof(CapitalizationScheme)).Value));
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\NamingStyles\Serialization\SerializableNamingRule.cs (1)
38EnforcementLevel = ((DiagnosticSeverity)Enum.Parse(typeof(DiagnosticSeverity), namingRuleElement.Attribute(nameof(EnforcementLevel))!.Value)).ToReportDiagnostic(),
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\NamingStyles\Serialization\SymbolSpecification.cs (5)
310=> (Accessibility)Enum.Parse(typeof(Accessibility), accessibilityElement.Value); 421var symbolKind = (SymbolKind)Enum.Parse(typeof(SymbolKind), symbolKindElement.Value); 433=> new((TypeKind)Enum.Parse(typeof(TypeKind), typeKindElement.Value)); 436=> new((MethodKind)Enum.Parse(typeof(MethodKind), methodKindElement.Value)); 536=> new((ModifierKindEnum)Enum.Parse(typeof(ModifierKindEnum), modifierElement.Value));
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Options\EditorConfigValueSerializer.cs (9)
104public static EditorConfigValueSerializer<T> CreateSerializerForEnum<T>() where T : struct, Enum 112public static EditorConfigValueSerializer<T> CreateSerializerForEnum<T>(BidirectionalMap<string, T> map) where T : struct, Enum 119public static EditorConfigValueSerializer<T> CreateSerializerForEnum<T>(BidirectionalMap<string, T> map, ImmutableDictionary<string, T> alternative) where T : struct, Enum 127public static EditorConfigValueSerializer<T> CreateSerializerForEnum<T>(IEnumerable<(string name, T value)> entries, IEnumerable<(string name, T value)> alternativeEntries) where T : struct, Enum 136public static EditorConfigValueSerializer<T?> CreateSerializerForNullableEnum<T>() where T : struct, Enum 158private static bool TryParseEnum<T>(string str, out T result) where T : struct, Enum 173return Enum.TryParse(str, ignoreCase: true, out result); 209where TFromEnum : struct, Enum 210where TToEnum : struct, Enum
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Simplification\SpecialTypeAnnotation.cs (1)
27=> (SpecialType)Enum.Parse(typeof(SpecialType), arg);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EnumValueUtilities.cs (2)
144where TFromEnum : struct, Enum 145where TToEnum : struct, Enum
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\OptionalExtensions.cs (2)
17where TFromEnum : struct, Enum 18where TToEnum : struct, Enum
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\TypeInferenceService\AbstractTypeInferenceService.AbstractTypeInferrer.cs (1)
119symbol.Name == nameof(Enum.HasFlag) &&
Microsoft.CodeAnalysis.AnalyzerUtilities (35)
src\roslyn\src\Compilers\Core\Portable\InternalUtilities\EnumUtilties.cs (3)
16return (T[])Enum.GetValues(typeof(T)); 20internal static bool ContainsAllValues<T>(int mask) where T : struct, Enum, IConvertible 33internal static bool ContainsValue<T>(T value) where T : struct, Enum
src\roslyn\src\Dependencies\Contracts\EnumExtensions.cs (5)
18extension(Enum) 20public static TEnum[] GetValues<TEnum>() where TEnum : struct, Enum 21=> (TEnum[])Enum.GetValues(typeof(TEnum)); 23public static string[] GetNames<TEnum>() where TEnum : struct, Enum 24=> Enum.GetNames(typeof(TEnum));
src\roslyn\src\RoslynAnalyzers\Utilities\Compiler\Options\AnalyzerOptionsExtensions.cs (3)
27ImmutableHashSet.CreateRange(Enum.GetValues<OutputKind>()); 144tryParseValue: static (value, out result) => Enum.TryParse(value, ignoreCase: true, result: out result), 164if (Enum.TryParse(kindStr, ignoreCase: true, result: out TEnum kind))
src\roslyn\src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\PropertySetAnalysis\PropertySetAbstractValue.ValuePool.cs (1)
29int[] values = Enum.GetValues<PropertySetAbstractValueKind>().Cast<int>().ToArray();
src\roslyn\src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\TaintedDataAnalysis\TaintedDataConfig.cs (1)
114foreach (var sinkKind in Enum.GetValues<SinkKind>())
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CodeStyle\CodeStyleOption2`1.cs (1)
180var severity = (DiagnosticSeverity)Enum.Parse(typeof(DiagnosticSeverity), severityAttribute.Value);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\NamingStyles\NamingStyle.cs (1)
480capitalizationScheme: (Capitalization)Enum.Parse(typeof(Capitalization), namingStyleElement.Attribute(nameof(CapitalizationScheme)).Value));
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\NamingStyles\Serialization\SerializableNamingRule.cs (1)
38EnforcementLevel = ((DiagnosticSeverity)Enum.Parse(typeof(DiagnosticSeverity), namingRuleElement.Attribute(nameof(EnforcementLevel))!.Value)).ToReportDiagnostic(),
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\NamingStyles\Serialization\SymbolSpecification.cs (5)
310=> (Accessibility)Enum.Parse(typeof(Accessibility), accessibilityElement.Value); 421var symbolKind = (SymbolKind)Enum.Parse(typeof(SymbolKind), symbolKindElement.Value); 433=> new((TypeKind)Enum.Parse(typeof(TypeKind), typeKindElement.Value)); 436=> new((MethodKind)Enum.Parse(typeof(MethodKind), methodKindElement.Value)); 536=> new((ModifierKindEnum)Enum.Parse(typeof(ModifierKindEnum), modifierElement.Value));
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Options\EditorConfigValueSerializer.cs (9)
104public static EditorConfigValueSerializer<T> CreateSerializerForEnum<T>() where T : struct, Enum 112public static EditorConfigValueSerializer<T> CreateSerializerForEnum<T>(BidirectionalMap<string, T> map) where T : struct, Enum 119public static EditorConfigValueSerializer<T> CreateSerializerForEnum<T>(BidirectionalMap<string, T> map, ImmutableDictionary<string, T> alternative) where T : struct, Enum 127public static EditorConfigValueSerializer<T> CreateSerializerForEnum<T>(IEnumerable<(string name, T value)> entries, IEnumerable<(string name, T value)> alternativeEntries) where T : struct, Enum 136public static EditorConfigValueSerializer<T?> CreateSerializerForNullableEnum<T>() where T : struct, Enum 158private static bool TryParseEnum<T>(string str, out T result) where T : struct, Enum 173return Enum.TryParse(str, ignoreCase: true, out result); 209where TFromEnum : struct, Enum 210where TToEnum : struct, Enum
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Simplification\SpecialTypeAnnotation.cs (1)
27=> (SpecialType)Enum.Parse(typeof(SpecialType), arg);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EnumValueUtilities.cs (2)
144where TFromEnum : struct, Enum 145where TToEnum : struct, Enum
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\OptionalExtensions.cs (2)
17where TFromEnum : struct, Enum 18where TToEnum : struct, Enum
Microsoft.CodeAnalysis.CodeStyle (34)
src\roslyn\src\Analyzers\Core\Analyzers\ForEachCast\AbstractForEachCastDiagnosticAnalyzer.cs (1)
22where TSyntaxKind : struct, Enum
src\roslyn\src\Analyzers\Core\Analyzers\MakeFieldReadonly\AbstractMakeFieldReadonlyDiagnosticAnalyzer.cs (1)
24where TSyntaxKind : struct, Enum
src\roslyn\src\Analyzers\Core\Analyzers\RemoveUnnecessarySuppressions\SuppressMessageAttributeState.cs (1)
29foreach (var targetScope in Enum.GetValues<TargetScope>())
src\roslyn\src\Analyzers\Core\Analyzers\UseAutoProperty\AbstractUseAutoPropertyAnalyzer.cs (1)
37where TSyntaxKind : struct, Enum
src\roslyn\src\Compilers\Core\Portable\InternalUtilities\EnumUtilties.cs (3)
16return (T[])Enum.GetValues(typeof(T)); 20internal static bool ContainsAllValues<T>(int mask) where T : struct, Enum, IConvertible 33internal static bool ContainsValue<T>(T value) where T : struct, Enum
src\roslyn\src\Dependencies\Contracts\EnumExtensions.cs (5)
18extension(Enum) 20public static TEnum[] GetValues<TEnum>() where TEnum : struct, Enum 21=> (TEnum[])Enum.GetValues(typeof(TEnum)); 23public static string[] GetNames<TEnum>() where TEnum : struct, Enum 24=> Enum.GetNames(typeof(TEnum));
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CodeStyle\CodeStyleOption2`1.cs (1)
180var severity = (DiagnosticSeverity)Enum.Parse(typeof(DiagnosticSeverity), severityAttribute.Value);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\NamingStyles\NamingStyle.cs (1)
480capitalizationScheme: (Capitalization)Enum.Parse(typeof(Capitalization), namingStyleElement.Attribute(nameof(CapitalizationScheme)).Value));
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\NamingStyles\Serialization\SerializableNamingRule.cs (1)
38EnforcementLevel = ((DiagnosticSeverity)Enum.Parse(typeof(DiagnosticSeverity), namingRuleElement.Attribute(nameof(EnforcementLevel))!.Value)).ToReportDiagnostic(),
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\NamingStyles\Serialization\SymbolSpecification.cs (5)
310=> (Accessibility)Enum.Parse(typeof(Accessibility), accessibilityElement.Value); 421var symbolKind = (SymbolKind)Enum.Parse(typeof(SymbolKind), symbolKindElement.Value); 433=> new((TypeKind)Enum.Parse(typeof(TypeKind), typeKindElement.Value)); 436=> new((MethodKind)Enum.Parse(typeof(MethodKind), methodKindElement.Value)); 536=> new((ModifierKindEnum)Enum.Parse(typeof(ModifierKindEnum), modifierElement.Value));
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Options\EditorConfigValueSerializer.cs (9)
104public static EditorConfigValueSerializer<T> CreateSerializerForEnum<T>() where T : struct, Enum 112public static EditorConfigValueSerializer<T> CreateSerializerForEnum<T>(BidirectionalMap<string, T> map) where T : struct, Enum 119public static EditorConfigValueSerializer<T> CreateSerializerForEnum<T>(BidirectionalMap<string, T> map, ImmutableDictionary<string, T> alternative) where T : struct, Enum 127public static EditorConfigValueSerializer<T> CreateSerializerForEnum<T>(IEnumerable<(string name, T value)> entries, IEnumerable<(string name, T value)> alternativeEntries) where T : struct, Enum 136public static EditorConfigValueSerializer<T?> CreateSerializerForNullableEnum<T>() where T : struct, Enum 158private static bool TryParseEnum<T>(string str, out T result) where T : struct, Enum 173return Enum.TryParse(str, ignoreCase: true, out result); 209where TFromEnum : struct, Enum 210where TToEnum : struct, Enum
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Simplification\SpecialTypeAnnotation.cs (1)
27=> (SpecialType)Enum.Parse(typeof(SpecialType), arg);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EnumValueUtilities.cs (2)
144where TFromEnum : struct, Enum 145where TToEnum : struct, Enum
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\OptionalExtensions.cs (2)
17where TFromEnum : struct, Enum 18where TToEnum : struct, Enum
Microsoft.CodeAnalysis.CodeStyle.Fixes (1)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\TypeInferenceService\AbstractTypeInferenceService.AbstractTypeInferrer.cs (1)
119symbol.Name == nameof(Enum.HasFlag) &&
Microsoft.CodeAnalysis.CSharp (9)
CommandLine\CSharpCompiler.cs (1)
287foreach (var v in (LanguageVersion[])Enum.GetValues(typeof(LanguageVersion)))
Compilation\CSharpCompilerDiagnosticAnalyzer.cs (1)
23var errorCodes = Enum.GetValues(typeof(ErrorCode));
SymbolDisplay\ObjectDisplay.cs (1)
47type = Enum.GetUnderlyingType(type);
Syntax\SyntaxKindFacts.cs (6)
22Debug.Assert(Enum.IsDefined(typeof(SyntaxKind), (SyntaxKind)i)); 151Debug.Assert(Enum.IsDefined(typeof(SyntaxKind), (SyntaxKind)i)); 181Debug.Assert(Enum.IsDefined(typeof(SyntaxKind), (SyntaxKind)i)); 187Debug.Assert(Enum.IsDefined(typeof(SyntaxKind), (SyntaxKind)i)); 193Debug.Assert(Enum.IsDefined(typeof(SyntaxKind), (SyntaxKind)i)); 1245Debug.Assert(Enum.IsDefined(typeof(SyntaxKind), (SyntaxKind)i));
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (1)
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseUtf8StringLiteral\UseUtf8StringLiteralCodeFixProvider.cs (1)
100if (!Enum.TryParse(operationLocationString, out UseUtf8StringLiteralDiagnosticAnalyzer.ArrayCreationOperationLocation operationLocation))
Microsoft.CodeAnalysis.CSharp.Features (1)
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseUtf8StringLiteral\UseUtf8StringLiteralCodeFixProvider.cs (1)
100if (!Enum.TryParse(operationLocationString, out UseUtf8StringLiteralDiagnosticAnalyzer.ArrayCreationOperationLocation operationLocation))
Microsoft.CodeAnalysis.CSharp.NetAnalyzers (1)
src\sdk\src\Microsoft.CodeAnalysis.NetAnalyzers\src\Utilities\Compiler.CSharp\Extensions\SyntaxGeneratorExtensions.cs (1)
34if (!Enum.IsDefined(typeof(SyntaxKind), SyntaxKindEx.UnsignedRightShiftExpression))
Microsoft.CodeAnalysis.CSharp.Workspaces (1)
Workspace\LanguageServices\CSharpCompilationFactoryService.cs (1)
48!Enum.TryParse<OutputKind>(outputKindString, out var outputKind))
Microsoft.CodeAnalysis.Extensions.Package (5)
src\roslyn\src\Dependencies\Contracts\EnumExtensions.cs (5)
18extension(Enum) 20public static TEnum[] GetValues<TEnum>() where TEnum : struct, Enum 21=> (TEnum[])Enum.GetValues(typeof(TEnum)); 23public static string[] GetNames<TEnum>() where TEnum : struct, Enum 24=> Enum.GetNames(typeof(TEnum));
Microsoft.CodeAnalysis.Features (18)
CodeFixes\Configuration\ConfigureCodeStyle\ConfigureCodeStyleOptionCodeFixProvider.cs (1)
122foreach (var enumValue in Enum.GetValues(t))
CodeRefactorings\CodeRefactoringService.cs (1)
55var kind = (TextDocumentKind)Enum.Parse(typeof(TextDocumentKind), documentKind, ignoreCase: true);
EditAndContinue\EditAndContinueDiagnosticDescriptors.cs (1)
208foreach (var value in Enum.GetValues<ProjectSettingKind>())
EmbeddedLanguages\AbstractLanguageDetector.cs (2)
20where TOptions : struct, Enum 177where TOptions : struct, Enum
EmbeddedLanguages\EmbeddedLanguageCommentOptions.cs (1)
21internal static class EmbeddedLanguageCommentOptions<TOptions> where TOptions : struct, Enum
ExtractMethod\AbstractSyntaxTriviaService.cs (1)
30Debug.Assert(Enum.GetNames(typeof(TriviaLocation)).Length == TriviaLocationsCount);
InitializeParameter\AbstractAddParameterCheckCodeRefactoringProvider.cs (3)
423var enumIsDefinedMembers = enumType.GetMembers(nameof(Enum.IsDefined)); 643var enumIsDefinedGenericMethod = enumType.GetMembers(nameof(Enum.IsDefined)).FirstOrDefault(m => m is IMethodSymbol { IsStatic: true, Arity: 1, Parameters.Length: 1 }); 665nameof(Enum.IsDefined)),
InvertIf\AbstractInvertIfCodeRefactoringProvider.cs (1)
32where TSyntaxKind : struct, Enum
NavigateTo\AbstractNavigateToSearchService.InProcess.cs (2)
323Debug.Assert(Enum.GetUnderlyingType(typeof(DeclaredSymbolInfoKind)) == typeof(byte)); 325var lookupTable = new bool[Enum.GetValues<DeclaredSymbolInfoKind>().Length];
QuickInfo\Presentation\QuickInfoContentBuilder.cs (1)
22var glyphs = Enum.GetValues<Glyph>();
src\roslyn\src\Analyzers\Core\Analyzers\ForEachCast\AbstractForEachCastDiagnosticAnalyzer.cs (1)
22where TSyntaxKind : struct, Enum
src\roslyn\src\Analyzers\Core\Analyzers\MakeFieldReadonly\AbstractMakeFieldReadonlyDiagnosticAnalyzer.cs (1)
24where TSyntaxKind : struct, Enum
src\roslyn\src\Analyzers\Core\Analyzers\RemoveUnnecessarySuppressions\SuppressMessageAttributeState.cs (1)
29foreach (var targetScope in Enum.GetValues<TargetScope>())
src\roslyn\src\Analyzers\Core\Analyzers\UseAutoProperty\AbstractUseAutoPropertyAnalyzer.cs (1)
37where TSyntaxKind : struct, Enum
Microsoft.CodeAnalysis.Razor.Compiler (1)
Language\RazorDiagnostic.cs (1)
72var underlyingType = Enum.GetUnderlyingType(enumType);
Microsoft.CodeAnalysis.Rebuild (3)
CompilationFactory.cs (1)
211: (Platform)Enum.Parse(typeof(Platform), platform);
CSharpCompilationFactory.cs (1)
85: (NullableContextOptions)Enum.Parse(typeof(NullableContextOptions), nullable);
MetadataCompilationOptions.cs (1)
64public static T? ToEnum<T>(string value) where T : struct => Enum.TryParse<T>(value, out var enumValue) ? enumValue : null;
Microsoft.CodeAnalysis.ResxSourceGenerator (33)
src\roslyn\src\Compilers\Core\Portable\InternalUtilities\EnumUtilties.cs (3)
16return (T[])Enum.GetValues(typeof(T)); 20internal static bool ContainsAllValues<T>(int mask) where T : struct, Enum, IConvertible 33internal static bool ContainsValue<T>(T value) where T : struct, Enum
src\roslyn\src\Dependencies\Contracts\EnumExtensions.cs (5)
18extension(Enum) 20public static TEnum[] GetValues<TEnum>() where TEnum : struct, Enum 21=> (TEnum[])Enum.GetValues(typeof(TEnum)); 23public static string[] GetNames<TEnum>() where TEnum : struct, Enum 24=> Enum.GetNames(typeof(TEnum));
src\roslyn\src\RoslynAnalyzers\Utilities\Compiler\Options\AnalyzerOptionsExtensions.cs (3)
27ImmutableHashSet.CreateRange(Enum.GetValues<OutputKind>()); 144tryParseValue: static (value, out result) => Enum.TryParse(value, ignoreCase: true, result: out result), 164if (Enum.TryParse(kindStr, ignoreCase: true, result: out TEnum kind))
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CodeStyle\CodeStyleOption2`1.cs (1)
180var severity = (DiagnosticSeverity)Enum.Parse(typeof(DiagnosticSeverity), severityAttribute.Value);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\NamingStyles\NamingStyle.cs (1)
480capitalizationScheme: (Capitalization)Enum.Parse(typeof(Capitalization), namingStyleElement.Attribute(nameof(CapitalizationScheme)).Value));
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\NamingStyles\Serialization\SerializableNamingRule.cs (1)
38EnforcementLevel = ((DiagnosticSeverity)Enum.Parse(typeof(DiagnosticSeverity), namingRuleElement.Attribute(nameof(EnforcementLevel))!.Value)).ToReportDiagnostic(),
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\NamingStyles\Serialization\SymbolSpecification.cs (5)
310=> (Accessibility)Enum.Parse(typeof(Accessibility), accessibilityElement.Value); 421var symbolKind = (SymbolKind)Enum.Parse(typeof(SymbolKind), symbolKindElement.Value); 433=> new((TypeKind)Enum.Parse(typeof(TypeKind), typeKindElement.Value)); 436=> new((MethodKind)Enum.Parse(typeof(MethodKind), methodKindElement.Value)); 536=> new((ModifierKindEnum)Enum.Parse(typeof(ModifierKindEnum), modifierElement.Value));
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Options\EditorConfigValueSerializer.cs (9)
104public static EditorConfigValueSerializer<T> CreateSerializerForEnum<T>() where T : struct, Enum 112public static EditorConfigValueSerializer<T> CreateSerializerForEnum<T>(BidirectionalMap<string, T> map) where T : struct, Enum 119public static EditorConfigValueSerializer<T> CreateSerializerForEnum<T>(BidirectionalMap<string, T> map, ImmutableDictionary<string, T> alternative) where T : struct, Enum 127public static EditorConfigValueSerializer<T> CreateSerializerForEnum<T>(IEnumerable<(string name, T value)> entries, IEnumerable<(string name, T value)> alternativeEntries) where T : struct, Enum 136public static EditorConfigValueSerializer<T?> CreateSerializerForNullableEnum<T>() where T : struct, Enum 158private static bool TryParseEnum<T>(string str, out T result) where T : struct, Enum 173return Enum.TryParse(str, ignoreCase: true, out result); 209where TFromEnum : struct, Enum 210where TToEnum : struct, Enum
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Simplification\SpecialTypeAnnotation.cs (1)
27=> (SpecialType)Enum.Parse(typeof(SpecialType), arg);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EnumValueUtilities.cs (2)
144where TFromEnum : struct, Enum 145where TToEnum : struct, Enum
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\OptionalExtensions.cs (2)
17where TFromEnum : struct, Enum 18where TToEnum : struct, Enum
Microsoft.CodeAnalysis.VisualBasic (1)
CommandLine\VisualBasicCompiler.vb (1)
241For Each v As LanguageVersion In System.Enum.GetValues(GetType(LanguageVersion))
Microsoft.CodeAnalysis.Workspaces (39)
CodeCleanup\AbstractCodeCleanerService.cs (1)
670var types = annotation.Data.Split(s_separators).Select(s => (SpanMarkerType)Enum.Parse(typeof(SpanMarkerType), s)).ToArray();
CodeFixes\ExportCodeFixProviderAttribute.cs (1)
22private static readonly string[] s_documentKindNames = Enum.GetNames(typeof(TextDocumentKind));
CodeFixesAndRefactorings\EnumArrayConverter.cs (2)
12public static ImmutableArray<TEnum> FromStringArray<TEnum>(string[] strings) where TEnum : struct, Enum 18if (!Enum.TryParse(s, out TEnum enumValue))
CodeRefactorings\ExportCodeRefactoringProviderAttribute.cs (1)
20private static readonly string[] s_documentKindNames = Enum.GetNames(typeof(TextDocumentKind));
Editing\DeclarationModifiers.cs (1)
235if (Enum.TryParse(value, out Modifiers mods))
Log\FunctionIdExtensions.cs (1)
14() => Enum.GetValues<FunctionId>().ToImmutableDictionary(f => f, f => f.ToString()));
Options\OptionExtensions.cs (2)
20where TFromEnum : struct, Enum 21where TToEnum : struct, Enum
src\roslyn\src\Compilers\Core\Portable\InternalUtilities\EnumUtilties.cs (3)
16return (T[])Enum.GetValues(typeof(T)); 20internal static bool ContainsAllValues<T>(int mask) where T : struct, Enum, IConvertible 33internal static bool ContainsValue<T>(T value) where T : struct, Enum
src\roslyn\src\Dependencies\Contracts\EnumExtensions.cs (4)
12public static TEnum[] GetValues<TEnum>() where TEnum : struct, Enum 13=> Enum.GetValues<TEnum>(); 15public static string[] GetNames<TEnum>() where TEnum : struct, Enum 16=> Enum.GetNames<TEnum>();
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CodeStyle\CodeStyleOption2`1.cs (1)
180var severity = (DiagnosticSeverity)Enum.Parse(typeof(DiagnosticSeverity), severityAttribute.Value);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\NamingStyles\NamingStyle.cs (1)
480capitalizationScheme: (Capitalization)Enum.Parse(typeof(Capitalization), namingStyleElement.Attribute(nameof(CapitalizationScheme)).Value));
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\NamingStyles\Serialization\SerializableNamingRule.cs (1)
38EnforcementLevel = ((DiagnosticSeverity)Enum.Parse(typeof(DiagnosticSeverity), namingRuleElement.Attribute(nameof(EnforcementLevel))!.Value)).ToReportDiagnostic(),
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\NamingStyles\Serialization\SymbolSpecification.cs (5)
310=> (Accessibility)Enum.Parse(typeof(Accessibility), accessibilityElement.Value); 421var symbolKind = (SymbolKind)Enum.Parse(typeof(SymbolKind), symbolKindElement.Value); 433=> new((TypeKind)Enum.Parse(typeof(TypeKind), typeKindElement.Value)); 436=> new((MethodKind)Enum.Parse(typeof(MethodKind), methodKindElement.Value)); 536=> new((ModifierKindEnum)Enum.Parse(typeof(ModifierKindEnum), modifierElement.Value));
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Options\EditorConfigValueSerializer.cs (9)
104public static EditorConfigValueSerializer<T> CreateSerializerForEnum<T>() where T : struct, Enum 112public static EditorConfigValueSerializer<T> CreateSerializerForEnum<T>(BidirectionalMap<string, T> map) where T : struct, Enum 119public static EditorConfigValueSerializer<T> CreateSerializerForEnum<T>(BidirectionalMap<string, T> map, ImmutableDictionary<string, T> alternative) where T : struct, Enum 127public static EditorConfigValueSerializer<T> CreateSerializerForEnum<T>(IEnumerable<(string name, T value)> entries, IEnumerable<(string name, T value)> alternativeEntries) where T : struct, Enum 136public static EditorConfigValueSerializer<T?> CreateSerializerForNullableEnum<T>() where T : struct, Enum 158private static bool TryParseEnum<T>(string str, out T result) where T : struct, Enum 173return Enum.TryParse(str, ignoreCase: true, out result); 209where TFromEnum : struct, Enum 210where TToEnum : struct, Enum
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Simplification\SpecialTypeAnnotation.cs (1)
27=> (SpecialType)Enum.Parse(typeof(SpecialType), arg);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EnumValueUtilities.cs (2)
144where TFromEnum : struct, Enum 145where TToEnum : struct, Enum
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\OptionalExtensions.cs (2)
17where TFromEnum : struct, Enum 18where TToEnum : struct, Enum
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\TypeInferenceService\AbstractTypeInferenceService.AbstractTypeInferrer.cs (1)
119symbol.Name == nameof(Enum.HasFlag) &&
Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost (1)
MSBuild\ProjectFile\Conversions.cs (1)
63return Enum.TryParse<TEnum>(value, ignoreCase, out var result)
Microsoft.CodeAnalysis.Workspaces.MSBuild.Contracts (4)
src\roslyn\src\Dependencies\Contracts\EnumExtensions.cs (4)
12public static TEnum[] GetValues<TEnum>() where TEnum : struct, Enum 13=> Enum.GetValues<TEnum>(); 15public static string[] GetNames<TEnum>() where TEnum : struct, Enum 16=> Enum.GetNames<TEnum>();
Microsoft.CSharp (9)
Microsoft\CSharp\RuntimeBinder\ComInterop\TypeUtils.cs (1)
262if (source.IsEnum && destination == typeof(System.Enum))
Microsoft\CSharp\RuntimeBinder\ComInterop\VarEnumSelector.cs (1)
350argumentType = Enum.GetUnderlyingType(argumentType);
Microsoft\CSharp\RuntimeBinder\Semantics\Operators.cs (3)
1073Debug.Assert(Enum.IsDefined(bt1)); 1074Debug.Assert(Enum.IsDefined(bt2)); 1582Debug.Assert(Enum.IsDefined(bt));
Microsoft\CSharp\RuntimeBinder\Semantics\Tree\Constant.cs (1)
78return Type.IsEnumType ? Enum.ToObject(Type.AssociatedSystemType, objval) : objval;
Microsoft\CSharp\RuntimeBinder\Semantics\Types\PredefinedTypes.cs (1)
152new PredefinedTypeInfo(PredefinedType.PT_ENUM, typeof(Enum), "System.Enum"),
Microsoft\CSharp\RuntimeBinder\SymbolTable.cs (1)
880agg.SetUnderlyingType((AggregateType)GetCTypeFromType(Enum.GetUnderlyingType(type)));
src\runtime\src\libraries\Common\src\System\Runtime\InteropServices\ComEventsMethod.cs (1)
61args[i] = Enum.ToObject(t, args[i]);
Microsoft.Deployment.DotNet.Releases (2)
Product.cs (2)
151Enum.TryParse(value.GetString(), ignoreCase: true, out ReleaseType releaseType) ? releaseType : ReleaseType.Unknown : 155Enum.TryParse(value.GetString()?.Replace("-", ""), ignoreCase: true, out SupportPhase supportPhase) ? supportPhase : SupportPhase.Unknown :
Microsoft.Diagnostics.DataContractReader.Contracts (3)
Contracts\RuntimeInfo_1.cs (2)
21if (Enum.TryParse(arch, ignoreCase: true, out RuntimeInfoArchitecture parsedArch)) 34if (Enum.TryParse(os, ignoreCase: true, out RuntimeInfoOperatingSystem parsedOS))
Contracts\StackWalk\FrameHandling\FrameHelpers.cs (1)
76foreach (FrameType frameType in Enum.GetValues<FrameType>())
Microsoft.DotNet.Arcade.Sdk (1)
src\SetCorFlags.cs (1)
50if (Enum.TryParse<CorFlags>(value, out var result))
Microsoft.DotNet.Build.Manifest (2)
ArtifactModel.cs (1)
60else if (Enum.TryParse(val, out ArtifactVisibility visibility))
BuildIdentity.cs (1)
224return (PublishingInfraVersion)Enum.Parse(typeof(PublishingInfraVersion), value, true);
Microsoft.DotNet.Build.Tasks.Feed (2)
src\PushToBuildStorage.cs (2)
191if (!Enum.IsDefined(typeof(PublishingInfraVersion), PublishingVersion)) 504if (Enum.TryParse(item.ItemSpec, true, out ArtifactVisibility parsedVisibility))
Microsoft.DotNet.Build.Tasks.Installers (4)
src\RpmBuilder.cs (2)
220entries.Add(new((RpmHeaderTag)Enum.Parse(typeof(RpmHeaderTag), script.Key), RpmHeaderEntryType.String, script.Value)); 221entries.Add(new((RpmHeaderTag)Enum.Parse(typeof(RpmHeaderTag), $"{script.Key}prog"), RpmHeaderEntryType.String, "/bin/sh"));
src\RpmHeader.cs (2)
18where TEntryTag : struct, Enum 33: this((TEntryTag)Enum.ToObject(typeof(TEntryTag), entryTag), type, value)
Microsoft.DotNet.Build.Tasks.Packaging (2)
Extensions.cs (1)
70Enum.TryParse(packageDirectoryName, true, out result);
ValidationTask.cs (1)
115if (!Enum.TryParse<Suppression>(keyString, out key))
Microsoft.DotNet.HotReload.Utils.Generator (1)
EditAndContinueCapabilitiesParser.cs (1)
60Enum.TryParse<EnC.EditAndContinueCapabilities>(token.Value, ignoreCase: true, out res);
Microsoft.DotNet.HotReload.Watch (1)
Context\EnvironmentVariables.cs (1)
59public static TestFlags TestFlags => Environment.GetEnvironmentVariable("__DOTNET_WATCH_TEST_FLAGS") is { } value ? Enum.Parse<TestFlags>(value) : TestFlags.None;
Microsoft.DotNet.TemplateLocator (3)
src\sdk\src\Common\EnvironmentVariableNames.cs (1)
105return Enum.TryParse(span, ignoreCase: true, out architecture);
src\sdk\src\Resolvers\Microsoft.NET.Sdk.WorkloadManifestReader\WorkloadManifestReader.cs (2)
428if (Enum.TryParse<WorkloadDefinitionKind>(kindStr, true, out var parsedKind)) 526if (Enum.TryParse<WorkloadPackKind>(kindStr, true, out var parsedKind))
Microsoft.Extensions.AI (3)
src\LegacySupport\StringSyntaxAttribute\StringSyntaxAttribute.cs (1)
48/// <summary>The syntax identifier for strings containing <see cref="Enum"/> format specifiers.</summary>
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 228if (!Enum.IsDefined(typeof(T), argument))
Microsoft.Extensions.AI.Abstractions (4)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 226if (!Enum.IsDefined<T>(argument))
Utilities\AIJsonUtilities.Schema.Create.cs (2)
878return Enum.ToObject(parameterType, defaultValue); 883return Enum.ToObject(underlyingType, defaultValue);
Microsoft.Extensions.AI.Abstractions.Tests (2)
Image\ImageGenerationOptionsTests.cs (2)
122Assert.True(Enum.IsDefined(typeof(ImageGenerationResponseFormat), responseFormat)); 128foreach (ImageGenerationResponseFormat responseFormat in Enum.GetValues(typeof(ImageGenerationResponseFormat)))
Microsoft.Extensions.AI.Evaluation (2)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 228if (!Enum.IsDefined(typeof(T), argument))
Microsoft.Extensions.AI.Evaluation.Console (2)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 226if (!Enum.IsDefined<T>(argument))
Microsoft.Extensions.AI.Evaluation.Integration.Tests (1)
ResultsTests.cs (1)
138if (!Enum.TryParse(e.Value, out MeasurementSystem measurementSystem))
Microsoft.Extensions.AI.Evaluation.NLP (2)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 226if (!Enum.IsDefined<T>(argument))
Microsoft.Extensions.AI.Evaluation.Quality (2)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 226if (!Enum.IsDefined<T>(argument))
Microsoft.Extensions.AI.Evaluation.Reporting (3)
JsonSerialization\CamelCaseEnumConverter.cs (1)
11where TEnum : struct, System.Enum;
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 226if (!Enum.IsDefined<T>(argument))
Microsoft.Extensions.AI.Evaluation.Reporting.Azure (3)
src\Libraries\Microsoft.Extensions.AI.Evaluation.Reporting\CSharp\JsonSerialization\CamelCaseEnumConverter.cs (1)
11where TEnum : struct, System.Enum;
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 226if (!Enum.IsDefined<T>(argument))
Microsoft.Extensions.AI.Evaluation.Safety (3)
ContentSafetyEvaluator.cs (1)
95Enum.Parse<ContentSafetyServicePayloadFormat>(contentSafetyServicePayloadFormat);
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 226if (!Enum.IsDefined<T>(argument))
Microsoft.Extensions.AI.Integration.Tests (2)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 226if (!Enum.IsDefined<T>(argument))
Microsoft.Extensions.AI.OpenAI (2)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 228if (!Enum.IsDefined(typeof(T), argument))
Microsoft.Extensions.AI.Tests (1)
ChatCompletion\ChatClientStructuredOutputExtensionsTests.cs (1)
126foreach (Species v in Enum.GetValues(typeof(Species)))
Microsoft.Extensions.AmbientMetadata.Application (2)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 226if (!Enum.IsDefined<T>(argument))
Microsoft.Extensions.AmbientMetadata.Build (2)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 226if (!Enum.IsDefined<T>(argument))
Microsoft.Extensions.AsyncState (2)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 226if (!Enum.IsDefined<T>(argument))
Microsoft.Extensions.Caching.Hybrid (2)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 228if (!Enum.IsDefined(typeof(T), argument))
Microsoft.Extensions.Compliance.Abstractions (2)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 228if (!Enum.IsDefined(typeof(T), argument))
Microsoft.Extensions.Compliance.Redaction (3)
src\LegacySupport\StringSyntaxAttribute\StringSyntaxAttribute.cs (1)
48/// <summary>The syntax identifier for strings containing <see cref="Enum"/> format specifiers.</summary>
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 228if (!Enum.IsDefined(typeof(T), argument))
Microsoft.Extensions.Compliance.Testing (3)
src\LegacySupport\StringSyntaxAttribute\StringSyntaxAttribute.cs (1)
48/// <summary>The syntax identifier for strings containing <see cref="Enum"/> format specifiers.</summary>
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 228if (!Enum.IsDefined(typeof(T), argument))
Microsoft.Extensions.Configuration.Binder (2)
ConfigurationBinder.cs (1)
777object key = keyTypeIsEnum ? Enum.Parse(keyType, child.Key, true) :
src\runtime\src\libraries\Common\src\Extensions\ParameterDefaultValue\ParameterDefaultValue.cs (1)
55defaultValue = Enum.ToObject(underlyingType, defaultValue);
Microsoft.Extensions.DataIngestion (2)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 226if (!Enum.IsDefined<T>(argument))
Microsoft.Extensions.DataIngestion.Abstractions (2)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 228if (!Enum.IsDefined(typeof(T), argument))
Microsoft.Extensions.DataIngestion.Markdig (2)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 226if (!Enum.IsDefined<T>(argument))
Microsoft.Extensions.DataIngestion.MarkItDown (2)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 228if (!Enum.IsDefined(typeof(T), argument))
Microsoft.Extensions.DependencyInjection (1)
src\runtime\src\libraries\Common\src\Extensions\ParameterDefaultValue\ParameterDefaultValue.cs (1)
55defaultValue = Enum.ToObject(underlyingType, defaultValue);
Microsoft.Extensions.DependencyInjection.Abstractions (1)
src\runtime\src\libraries\Common\src\Extensions\ParameterDefaultValue\ParameterDefaultValue.cs (1)
55defaultValue = Enum.ToObject(underlyingType, defaultValue);
Microsoft.Extensions.DependencyInjection.AutoActivation (2)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 226if (!Enum.IsDefined<T>(argument))
Microsoft.Extensions.Diagnostics.ExceptionSummarization (4)
HttpExceptionSummaryProvider.cs (2)
39foreach (var socketError in Enum.GetValues<SocketError>()) 54foreach (var status in Enum.GetValues<WebExceptionStatus>())
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 226if (!Enum.IsDefined<T>(argument))
Microsoft.Extensions.Diagnostics.HealthChecks.Common (2)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 226if (!Enum.IsDefined<T>(argument))
Microsoft.Extensions.Diagnostics.Probes (2)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 226if (!Enum.IsDefined<T>(argument))
Microsoft.Extensions.Diagnostics.ResourceMonitoring (2)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 226if (!Enum.IsDefined<T>(argument))
Microsoft.Extensions.Diagnostics.Testing (2)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 226if (!Enum.IsDefined<T>(argument))
Microsoft.Extensions.Hosting.Testing (2)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 226if (!Enum.IsDefined<T>(argument))
Microsoft.Extensions.Http (2)
DependencyInjection\SocketsHttpHandlerBuilderExtensions.cs (2)
55/// Only simple (of type `bool`, `int`, <see cref="Enum"/> or <see cref="TimeSpan"/>) properties of <see cref="SocketsHttpHandler"/> will be parsed. 218=> Enum.TryParse<TEnum>(enumString, ignoreCase: true, out var result) ? result : null;
Microsoft.Extensions.Http.Resilience (2)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 228if (!Enum.IsDefined(typeof(T), argument))
Microsoft.Extensions.Logging.Configuration (1)
LoggerFilterConfigureOptions.cs (1)
79else if (Enum.TryParse(value, true, out level))
Microsoft.Extensions.Logging.Console (2)
_generated\0\BindingExtensions.g.cs (1)
560return Enum.Parse<T>(value, ignoreCase: true);
ConfigurationConsoleLoggerSettings.cs (1)
92else if (Enum.TryParse<LogLevel>(value, true, out level))
Microsoft.Extensions.ObjectPool.DependencyInjection (2)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 226if (!Enum.IsDefined<T>(argument))
Microsoft.Extensions.Options.Contextual (2)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 228if (!Enum.IsDefined(typeof(T), argument))
Microsoft.Extensions.Primitives (2)
ThrowHelper.cs (2)
61Debug.Assert(Enum.IsDefined(typeof(ExceptionResource), resource), 79Debug.Assert(Enum.IsDefined(typeof(ExceptionArgument), argument),
Microsoft.Extensions.Resilience (2)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 226if (!Enum.IsDefined<T>(argument))
Microsoft.Extensions.ServiceDiscovery (2)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 226if (!Enum.IsDefined<T>(argument))
Microsoft.Extensions.ServiceDiscovery.Abstractions (2)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 226if (!Enum.IsDefined<T>(argument))
Microsoft.Extensions.ServiceDiscovery.Dns (2)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 226if (!Enum.IsDefined<T>(argument))
Microsoft.Extensions.ServiceDiscovery.Yarp (2)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 226if (!Enum.IsDefined<T>(argument))
Microsoft.Extensions.Telemetry (2)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 228if (!Enum.IsDefined(typeof(T), argument))
Microsoft.Extensions.Telemetry.Abstractions (2)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 226if (!Enum.IsDefined<T>(argument))
Microsoft.Extensions.TimeProvider.Testing (2)
src\Shared\Throw\Throw.cs (2)
223where T : struct, Enum 228if (!Enum.IsDefined(typeof(T), argument))
Microsoft.Interop.ComInterfaceGenerator (1)
Analyzers\ConvertComImportToGeneratedComInterfaceAnalyzer.cs (1)
181return !Enum.IsDefined(typeof(UnmanagedType), unmanagedType)
Microsoft.Interop.JavaScript.JSImportGenerator (3)
JSMarshalAsAttributeInfoParser.cs (3)
33Enum.TryParse(name, out jsType); 39Enum.TryParse(argName, out jsTypeArg); 47Enum.TryParse(name, out jsType);
Microsoft.Interop.LibraryImportGenerator (4)
Analyzers\ConvertToLibraryImportAnalyzer.cs (1)
206return !Enum.IsDefined(typeof(UnmanagedType), unmanagedType)
Analyzers\ConvertToLibraryImportFixer.cs (1)
80CharSet? charSet = options.TryGetValue(CharSetOption, out Option charSetOption) && charSetOption is Option.String(string charSetString) && Enum.TryParse<CharSet>(charSetString, out CharSet result) ? result : null;
Analyzers\CustomMarshallerAttributeAnalyzer.cs (1)
690|| !Enum.IsDefined(typeof(MarshalMode), (MarshalMode)marshalMode))
LibraryImportGenerator.cs (1)
482private static MemberAccessExpressionSyntax CreateEnumExpressionSyntax<T>(T value) where T : Enum
Microsoft.Interop.LibraryImportGenerator.Downlevel (1)
DownlevelLibraryImportGenerator.cs (1)
427private static MemberAccessExpressionSyntax CreateEnumExpressionSyntax<T>(T value) where T : Enum
Microsoft.Interop.SourceGeneration (1)
MarshalAsParser.cs (1)
206if (!Enum.IsDefined(typeof(UnmanagedType), unmanagedType)
Microsoft.Maui (6)
Converters\FlexEnumsConverters.cs (6)
24 if (Enum.TryParse(strValue, true, out FlexJustify justify)) 63 if (Enum.TryParse(strValue, true, out FlexDirection aligncontent)) 98 if (Enum.TryParse(strValue, true, out FlexAlignContent aligncontent)) 137 if (Enum.TryParse(strValue, true, out FlexAlignItems alignitems)) 172 if (Enum.TryParse(strValue, true, out FlexAlignSelf alignself)) 207 if (Enum.TryParse(strValue, true, out FlexWrap wrap))
Microsoft.Maui.Controls (14)
Button\Button.cs (1)
604 position = (ButtonContentLayout.ImagePosition)Enum.Parse(typeof(ButtonContentLayout.ImagePosition), parts[positionIndex], true);
CompareStateTrigger.cs (3)
74 if (value2 is Enum) 86 return Enum.IsDefined(enumType, value) ? Enum.ToObject(enumType, value) : null;
DecorableTextElement.cs (1)
38 if (Enum.TryParse(item.Trim(), true, out TextDecorations textDecorations))
FlowDirectionConverter.cs (1)
22 if (Enum.TryParse(strValue, out FlowDirection direction))
FontAttributes.cs (1)
56 if (Enum.TryParse(part, true, out FontAttributes attr))
FontSizeConverter.cs (2)
52 else if (Enum.TryParse(value, ignoreCase, out NamedSize ns)) 96 if (Enum.TryParse(strValue, out NamedSize namedSize))
ListView\ListView.cs (2)
389 if (!Enum.IsDefined(typeof(ScrollToPosition), position)) 404 if (!Enum.IsDefined(typeof(ScrollToPosition), position))
ScrollView\ScrollView.cs (1)
264 if (!Enum.IsDefined(typeof(ScrollToPosition), position))
TextAlignment.cs (1)
38 if (Enum.TryParse(strValue, out TextAlignment direction))
Xaml\TypeConversionExtensions.cs (1)
173 return Enum.Parse(toType, str, ignoreCase);
Microsoft.Maui.Controls.Build.Tasks (3)
CompiledConverters\EnumTypeConverter.cs (1)
16 if (Enum.TryParse(value, out TEnum enumValue))
CompiledConverters\FontSizeTypeConverter.cs (1)
26 if (Enum.TryParse(value, out NamedSize namedSize))
SetPropertiesVisitor.cs (1)
506 || !Enum.TryParse((modeNode as ValueNode)?.Value as string, true, out BindingMode declaredmode))
Microsoft.Maui.Controls.DesignTools (2)
ButtonContentDesignTypeConverter.cs (2)
34 if (parts.Length == 2 && !Enum.TryParse(parts[1], true, out ImagePosition _)) 40 if (!Enum.TryParse(parts[0], true, out ImagePosition _))
Microsoft.Maui.Graphics (2)
Text\TextAttributesExtensions.cs (1)
135 if (Enum.TryParse(value, out T enumValue))
Text\XmlAttributedTextReader.cs (1)
126 if (Enum.TryParse(attributeName, out TextAttribute key))
Microsoft.ML.AutoML (10)
API\BinaryClassificationExperiment.cs (1)
50Trainers = Enum.GetValues(typeof(BinaryClassificationTrainer)).OfType<BinaryClassificationTrainer>().ToList();
API\MulticlassClassificationExperiment.cs (1)
45Trainers = Enum.GetValues(typeof(MulticlassClassificationTrainer)).OfType<MulticlassClassificationTrainer>().ToList();
API\RankingExperiment.cs (1)
44Trainers = Enum.GetValues(typeof(RankingTrainer)).OfType<RankingTrainer>().ToList();
API\RecommendationExperiment.cs (1)
35Trainers = Enum.GetValues(typeof(RecommendationTrainer)).OfType<RecommendationTrainer>().ToList();
API\RegressionExperiment.cs (1)
45Trainers = Enum.GetValues(typeof(RegressionTrainer)).OfType<RegressionTrainer>().ToList();
ColumnInference\ColumnGroupingInference.cs (1)
124return Enum.GetName(typeof(ColumnPurpose), purpose);
Experiment\SuggestedPipeline.cs (2)
86var trainerName = (TrainerName)Enum.Parse(typeof(TrainerName), pipelineNode.Name); 95var estimatorName = (EstimatorName)Enum.Parse(typeof(EstimatorName), pipelineNode.Name);
TrainerExtensions\TrainerExtensionUtil.cs (1)
283.ToDictionary(v => Enum.GetName(fi.FieldType, v), v => v);
Utils\SweepableParamAttributes.cs (1)
93case Enum _:
Microsoft.ML.AutoML.Tests (7)
EstimatorExtensionTests.cs (1)
32var estimatorNames = Enum.GetValues(typeof(EstimatorName)).Cast<EstimatorName>();
TrainerExtensionsTests.cs (6)
27var trainerNames = Enum.GetValues(typeof(TrainerName)).Cast<TrainerName>() 357var publicNames = Enum.GetValues(typeof(BinaryClassificationTrainer)).Cast<BinaryClassificationTrainer>(); 365var publicNames = Enum.GetValues(typeof(MulticlassClassificationTrainer)).Cast<MulticlassClassificationTrainer>(); 373var publicNames = Enum.GetValues(typeof(RegressionTrainer)).Cast<RegressionTrainer>(); 381var publicNames = Enum.GetValues(typeof(RecommendationTrainer)).Cast<RecommendationTrainer>(); 389var publicNames = Enum.GetValues(typeof(RankingTrainer)).Cast<RankingTrainer>();
Microsoft.ML.CodeGenerator (3)
CodeGenerator\CSharp\TrainerGeneratorFactory.cs (1)
22if (Enum.TryParse(node.Name, out TrainerName trainer))
CodeGenerator\CSharp\TransformGeneratorFactory.cs (2)
31if (Enum.TryParse(node.Name, out EstimatorName trainer)) 84if (Enum.TryParse(node.Name, out SpecialTransformer transformer))
Microsoft.ML.Core (4)
CommandLine\CmdParser.cs (1)
1893value = Enum.Parse(type, data, true);
EntryPoints\ModuleArgs.cs (1)
373case Enum _:
Utilities\Utils.cs (2)
1246public static string GetDescription(this Enum value) 1249string name = Enum.GetName(type, value);
Microsoft.ML.Core.Tests (1)
UnitTests\TestVBuffer.cs (1)
1099Contracts.Assert(cases == Enum.GetValues(typeof(GenLogic)).Length);
Microsoft.ML.Data (22)
Commands\TrainCommand.cs (1)
449ch.CheckUserArg(Enum.IsDefined(typeof(NormalizeOption), autoNorm), nameof(TrainCommand.Arguments.NormalizeFeatures),
Commands\TypeInfoCommand.cs (1)
87var kinds = Enum.GetValues(typeof(InternalDataKind)).Cast<InternalDataKind>().Distinct().OrderBy(k => k).ToArray();
DataLoadSave\Binary\BinaryLoader.cs (5)
344bool knowCompression = Enum.IsDefined(typeof(CompressionKind), compression); 503ectx.Assert(Enum.IsDefined(typeof(CompressionKind), compression)); 530Contracts.Assert((codec == null) || !Enum.IsDefined(typeof(CompressionKind), compression)); 1110bool knowCompression = Enum.IsDefined(typeof(CompressionKind), compression); 1779Ectx.Assert(Enum.IsDefined(typeof(CompressionKind), entry.Compression));
DataLoadSave\Database\DatabaseLoader.cs (2)
499ch.CheckUserArg(Enum.IsDefined(typeof(DbType), col.Type), nameof(Column.Type), "Bad item type"); 570Contracts.CheckDecode(Enum.IsDefined(typeof(InternalDataKind), kind));
DataLoadSave\Text\TextLoader.cs (2)
777ch.CheckUserArg(Enum.IsDefined(typeof(InternalDataKind), kind), nameof(Column.Type), "Bad item type"); 935Contracts.CheckDecode(Enum.IsDefined(typeof(InternalDataKind), kind));
EntryPoints\InputBuilder.cs (2)
446if (!Enum.IsDefined(type, value.Value<string>())) 448return Enum.Parse(type, value.Value<string>());
Model\Pfa\SavePfaCommand.cs (1)
82Host.CheckUserArg(Enum.IsDefined(typeof(Formatting), args.Formatting), nameof(args.Formatting), "Undefined value");
Transforms\ColumnSelecting.cs (2)
345Contracts.Assert(Enum.IsDefined(typeof(HiddenColumnOption), hiddenOption)); 361Contracts.Assert(Enum.IsDefined(typeof(HiddenColumnOption), colHiddenOption));
Transforms\TypeConverting.cs (2)
266Host.CheckDecode(Enum.IsDefined(typeof(InternalDataKind), kind)); 416ectx.Assert(Enum.IsDefined(typeof(InternalDataKind), kind));
Transforms\ValueToKeyMappingTransformer.cs (2)
283if (!Enum.IsDefined(typeof(ValueToKeyMappingEstimator.KeyOrdinality), options.Sort)) 290if (!Enum.IsDefined(typeof(ValueToKeyMappingEstimator.KeyOrdinality), sortOrder))
Transforms\ValueToKeyMappingTransformerImpl.cs (1)
519ectx.CheckDecode(Enum.IsDefined(typeof(MapType), mtype));
Utilities\TypeParsingUtils.cs (1)
46if (!Enum.TryParse(str, true, out dataKind))
Microsoft.ML.Ensemble (9)
OutputCombiners\MultiWeightedAverage.cs (3)
59Host.CheckUserArg(Enum.IsDefined(typeof(MultiWeightageKind), _weightageKind), nameof(options.WeightageName)); 69Host.CheckDecode(Enum.IsDefined(typeof(MultiWeightageKind), _weightageKind)); 87Host.Assert(Enum.IsDefined(typeof(MultiWeightageKind), _weightageKind));
OutputCombiners\WeightedAverage.cs (3)
57Host.CheckUserArg(Enum.IsDefined(typeof(WeightageKind), _weightageKind), nameof(options.WeightageName)); 66Host.CheckDecode(Enum.IsDefined(typeof(WeightageKind), _weightageKind)); 85Contracts.Assert(Enum.IsDefined(typeof(WeightageKind), _weightageKind));
Selector\SubModelSelector\BestPerformanceRegressionSelector.cs (1)
41Host.CheckUserArg(Enum.IsDefined(typeof(RegressionEvaluator.Metrics), args.MetricName), nameof(args.MetricName), "Undefined metric name");
Selector\SubModelSelector\BestPerformanceSelector.cs (1)
40Host.CheckUserArg(Enum.IsDefined(typeof(BinaryClassifierEvaluator.Metrics), args.MetricName),
Selector\SubModelSelector\BestPerformanceSelectorMulticlass.cs (1)
40Host.CheckUserArg(Enum.IsDefined(typeof(MulticlassClassificationEvaluator.Metrics), args.MetricName),
Microsoft.ML.EntryPoints (1)
JsonUtils\JsonManifestUtils.cs (1)
365var values = Enum.GetNames(type).Where(n => type.GetField(n).GetCustomAttribute<HideEnumValueAttribute>() == null);
Microsoft.ML.FastTree (9)
Dataset\IntArray.cs (2)
91Contracts.CheckParam(Enum.IsDefined(typeof(IntArrayType), type) && type != IntArrayType.Current, nameof(type)); 92Contracts.CheckParam(Enum.IsDefined(typeof(IntArrayBits), bitsPerItem), nameof(bitsPerItem));
SumupPerformanceCommand.cs (1)
89_host.CheckUserArg(Enum.IsDefined(typeof(IntArrayType), args.Type) && args.Type != IntArrayType.Current, nameof(args.Type), "Value not defined");
Utils\Timer.cs (6)
131TickTotals = new long[Enum.GetValues(typeof(TimerEvent)).Length]; 132CountTotals = new long[Enum.GetValues(typeof(CountEvent)).Length]; 136foreach (string name in Enum.GetNames(typeof(TimerEvent))) 141foreach (string name in Enum.GetNames(typeof(CountEvent))) 160foreach (TimerEvent n in Enum.GetValues(typeof(TimerEvent))) 175foreach (CountEvent n in Enum.GetValues(typeof(CountEvent)))
Microsoft.ML.ImageAnalytics (4)
ImageResizer.cs (4)
207Host.CheckDecode(Enum.IsDefined(typeof(ImageResizingEstimator.ResizingKind), scale)); 209Host.CheckDecode(Enum.IsDefined(typeof(ImageResizingEstimator.Anchor), anchor)); 456Contracts.CheckUserArg(Enum.IsDefined(typeof(ResizingKind), resizing), nameof(resizing)); 457Contracts.CheckUserArg(Enum.IsDefined(typeof(Anchor), anchor), nameof(anchor));
Microsoft.ML.InternalCodeAnalyzer (2)
NameFixProvider.cs (2)
56if (!Enum.TryParse(desiredNameStr, out desiredName)) 94Debug.Assert(!Enum.IsDefined(typeof(NameType), desiredName));
Microsoft.ML.SearchSpace (5)
Parameter.cs (5)
135/// Create a <see cref="Parameter"/> from a <see cref="Enum"/> value. The <see cref="ParameterType"/> will be <see cref="ParameterType.String"/>. 138public static Parameter FromEnum<T>(T value) where T : struct, Enum 158private static Parameter FromEnum(Enum e, Type t) 160return Parameter.FromString(Enum.GetName(t, e)); 183Enum e => Parameter.FromEnum(e, e.GetType()),
Microsoft.ML.Tests (1)
ExpressionLanguageTests\ExpressionLanguageTests.cs (1)
233bool tmp = Enum.TryParse(toks[i], out kind);
Microsoft.ML.TimeSeries (16)
SequentialAnomalyDetectionTransformBase.cs (9)
173Host.CheckUserArg(Enum.IsDefined(typeof(MartingaleType), martingale), nameof(ArgumentsBase.Martingale), "Value is undefined."); 174Host.CheckUserArg(Enum.IsDefined(typeof(AnomalySide), anomalySide), nameof(ArgumentsBase.Side), "Value is undefined."); 175Host.CheckUserArg(Enum.IsDefined(typeof(AlertingScore), alertingScore), nameof(ArgumentsBase.AlertOn), "Value is undefined."); 211Host.CheckDecode(Enum.IsDefined(typeof(MartingaleType), temp)); 215Host.CheckDecode(Enum.IsDefined(typeof(AlertingScore), temp)); 222Host.CheckDecode(Enum.IsDefined(typeof(AnomalySide), temp)); 240Host.Assert(Enum.IsDefined(typeof(MartingaleType), Martingale)); 241Host.Assert(Enum.IsDefined(typeof(AlertingScore), ThresholdScore)); 244Host.Assert(Enum.IsDefined(typeof(AnomalySide), Side));
SlidingWindowTransformBase.cs (3)
74Host.CheckUserArg(Enum.IsDefined(typeof(BeginOptions), args.Begin), nameof(args.Begin), "Undefined value."); 92Host.CheckDecode(Enum.IsDefined(typeof(BeginOptions), r)); 114Host.Assert(Enum.IsDefined(typeof(BeginOptions), _begin));
SsaAnomalyDetectionBase.cs (3)
196Host.CheckUserArg(Enum.IsDefined(typeof(ErrorFunction), options.ErrorFunction), nameof(options.ErrorFunction), ErrorFunctionUtils.ErrorFunctionHelpText); 233Host.CheckDecode(Enum.IsDefined(typeof(ErrorFunction), temp)); 272Host.Assert(Enum.IsDefined(typeof(ErrorFunction), ErrorFunction));
SsaChangePointDetector.cs (1)
143InternalTransform.Host.Assert(!Enum.IsDefined(typeof(MartingaleType), InternalTransform.Martingale));
Microsoft.ML.Transforms (17)
GcnTransform.cs (1)
846Contracts.CheckDecode(Enum.IsDefined(typeof(NormFunction), normKindVal));
MissingValueReplacing.cs (1)
441if (!Enum.IsDefined(typeof(ReplacementKind), kind))
OneHotEncoding.cs (2)
53if (!Enum.TryParse(extra, true, out OneHotEncodingEstimator.OutputKind kind)) 65if (!Enum.IsDefined(typeof(OneHotEncodingEstimator.OutputKind), kind))
Text\NgramTransform.cs (2)
160Contracts.CheckDecode(Enum.IsDefined(typeof(NgramExtractingEstimator.WeightingCriteria), Weighting)); 179Contracts.Assert(Enum.IsDefined(typeof(NgramExtractingEstimator.WeightingCriteria), Weighting));
Text\StopWordsRemovingTransformer.cs (4)
149var values = Enum.GetValues(typeof(StopWordsRemovingEstimator.Language)).Cast<int>(); 171var langsDictionary = Enum.GetValues(typeof(StopWordsRemovingEstimator.Language)).Cast<StopWordsRemovingEstimator.Language>() 237Contracts.CheckDecode(Enum.IsDefined(typeof(StopWordsRemovingEstimator.Language), lang)); 294foreach (StopWordsRemovingEstimator.Language lang in Enum.GetValues(typeof(StopWordsRemovingEstimator.Language)))
Text\TextFeaturizingEstimator.cs (3)
320=> (StopWordsRemovingEstimator.Language)Enum.Parse(typeof(StopWordsRemovingEstimator.Language), Language.ToString()); 385host.Check(Enum.IsDefined(typeof(Language), parent.OptionalSettings.Language)); 386host.Check(Enum.IsDefined(typeof(CaseMode), parent.OptionalSettings.CaseMode));
Text\TextNormalizing.cs (1)
164host.CheckDecode(Enum.IsDefined(typeof(TextNormalizingEstimator.CaseMode), _caseMode));
Text\WordEmbeddingsExtractor.cs (2)
187env.CheckUserArg(Enum.IsDefined(typeof(WordEmbeddingEstimator.PretrainedModelKind), modelKind), nameof(modelKind)); 227env.CheckUserArg(!options.ModelKind.HasValue || Enum.IsDefined(typeof(WordEmbeddingEstimator.PretrainedModelKind), options.ModelKind), nameof(options.ModelKind));
UngroupTransform.cs (1)
355ectx.CheckDecode(Enum.IsDefined(typeof(UngroupMode), modeIndex));
Microsoft.NET.Build.Containers (5)
ContainerHelpers.cs (1)
65if (!Enum.TryParse(portType, out PortType t))
Tasks\CreateNewImage.cs (4)
153if (Enum.TryParse<KnownImageFormats>(ImageFormat, out var imageFormat)) 164Log.LogErrorWithCodeFromResources(nameof(Strings.InvalidContainerImageFormat), ImageFormat, string.Join(",", Enum.GetValues<KnownImageFormats>())); 171if (Enum.TryParse<KnownImageFormats>(ImageFormat, out var imageFormat)) 182Log.LogErrorWithCodeFromResources(nameof(Strings.InvalidContainerImageFormat), ImageFormat, string.Join(",", Enum.GetValues<KnownImageFormats>()));
Microsoft.NET.Build.Tasks (8)
AssetsFileResolver.cs (1)
59Enum.TryParse<AssetType>(runtimeTarget.AssetType, true, out _assetType);
CreateAppHost.cs (2)
81if (Enum.TryParse(locationItem.ItemSpec, out HostWriter.DotNetSearchOptions.SearchLocation location) 82&& Enum.IsDefined(typeof(HostWriter.DotNetSearchOptions.SearchLocation), location))
ResolvePackageAssets.cs (1)
1626Enum.TryParse(dependencyTypeString, ignoreCase: true, out DependencyType dependencyType);
ResolvePackageDependencies.cs (1)
367foreach (var fileGroup in (FileGroup[])Enum.GetValues(typeof(FileGroup)))
src\sdk\src\Common\EnvironmentVariableNames.cs (1)
105return Enum.TryParse(span, ignoreCase: true, out architecture);
src\sdk\src\Resolvers\Microsoft.NET.Sdk.WorkloadManifestReader\WorkloadManifestReader.cs (2)
428if (Enum.TryParse<WorkloadDefinitionKind>(kindStr, true, out var parsedKind)) 526if (Enum.TryParse<WorkloadPackKind>(kindStr, true, out var parsedKind))
Microsoft.NET.HostModel (3)
Bundle\Bundler.cs (1)
114using (DeflateStream compressionStream = new DeflateStream(bundle, Enum.IsDefined(typeof(CompressionLevel), smallestSize) ? smallestSize : CompressionLevel.Optimal, leaveOpen: true))
MachO\BinaryFormat\Blobs\BlobParser.cs (1)
34Debug.Assert(!Enum.IsDefined(typeof(BlobMagic), magic), "Blob magic is known but not handled.");
src\runtime\src\coreclr\tools\Common\MachO\MachObjectFile.cs (1)
29return Enum.IsDefined(typeof(MachMagic), magic);
Microsoft.NET.Sdk.Publish.Tasks (14)
MsDeploy\CommonUtility.cs (5)
237if (Enum.TryParse<IISExpressMetadata>(name, out _)) 601string[] enumNames = Enum.GetNames(enumType); 758wellKnownProvider = Enum.Parse(DeploymentWellKnownProviderType, destType, true); 979validationKind = Enum.ToObject(validationKindType, ((int)(validationKind)) | ((int)(currentValidationKind))); 1221validationKind = Enum.ToObject(validationKindType, ((int)(validationKind)) | ((int)(currentvalidationKind)));
MsDeploy\DynamicAssembly.cs (1)
91retValue = Enum.ToObject(enumType, 0);
MsDeploy\VsMSDeployObject.cs (1)
290if (Enum.TryParse(name, out expressMetadata))
src\sdk\src\Common\EnvironmentVariableNames.cs (1)
105return Enum.TryParse(span, ignoreCase: true, out architecture);
Tasks\MsDeploy\MSDeploy.cs (3)
643foreach (string dPIdentity in Enum.GetNames(typeof(ExistingDeclareParameterMetadata))) 774foreach (string dPIdentity in Enum.GetNames(typeof(ExistingDeclareParameterMetadata))) 862if (Enum.TryParse(name, out expressMetadata))
Tasks\MsDeploy\VsMsdeploy.cs (2)
498Diagnostics.TraceLevel level = (Diagnostics.TraceLevel)Enum.ToObject(typeof(Diagnostics.TraceLevel), args.EventLevel); 969(Diagnostics.TraceLevel)Enum.Parse(typeof(Diagnostics.TraceLevel), DeploymentTraceLevel, true);
Tasks\ZipDeploy\ZipDeploymentStatus.cs (1)
60_log.LogMessage(string.Format(Resources.ZIPDEPLOY_DeploymentStatus, Enum.GetName(typeof(DeployStatus), deployStatus)));
Microsoft.NET.Sdk.Razor.Tasks (2)
DotnetToolTask.cs (1)
137if (!SuppressCurrentUserOnlyPipeOptions && !Enum.IsDefined(typeof(PipeOptions), PipeOptionCurrentUserOnly))
src\sdk\src\RazorSdk\Tool\Client.cs (1)
132if (Enum.IsDefined(typeof(PipeOptions), PipeOptionCurrentUserOnly))
Microsoft.NET.Sdk.WorkloadManifestReader (3)
src\sdk\src\Common\EnvironmentVariableNames.cs (1)
105return Enum.TryParse(span, ignoreCase: true, out architecture);
WorkloadManifestReader.cs (2)
428if (Enum.TryParse<WorkloadDefinitionKind>(kindStr, true, out var parsedKind)) 526if (Enum.TryParse<WorkloadPackKind>(kindStr, true, out var parsedKind))
Microsoft.Private.Windows.Core (6)
_generated\289\System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.g.cs (1)
55/// <summary>The syntax identifier for strings containing <see cref="Enum"/> format specifiers.</summary>
src\winforms\src\Microsoft.Private.Windows.Polyfills\System\EnumExtensions.cs (5)
8extension(Enum) 20public static bool IsDefined<TEnum>(TEnum value) where TEnum : struct, Enum => Enum.IsDefined(typeof(TEnum), value); 27public static TEnum[] GetValues<TEnum>() where TEnum : struct, Enum => 28[.. Enum.GetValues(typeof(TEnum)).Cast<TEnum>()];
Microsoft.TemplateEngine.Cli (4)
JExtensions.cs (1)
141if (val == null || !Enum.TryParse(val, out T result))
TemplateInvoker.cs (1)
306Reporter.Error.WriteLine(string.Format(LocalizableStrings.UnexpectedResult, Enum.GetName(typeof(CreationResultStatus), instantiateResult.Status), instantiateResult.ErrorMessage).Bold().Red());
TemplateResolution\TemplateResolutionResult.cs (2)
37/// <see cref="Enum"/> defines possible statuses for resolving template to invoke.<br /> 78/// <see cref="Enum"/> defines possible statuses for unambiguous template group resolution.
Microsoft.TemplateEngine.Core (1)
Expressions\Converter.cs (1)
61result = (T)Enum.Parse(typeof(T), s, true);
Microsoft.TemplateEngine.Edge (1)
src\sdk\src\TemplateEngine\Shared\JExtensions.cs (1)
174if (val == null || !Enum.TryParse(val, ignoreCase, out T result))
Microsoft.TemplateEngine.Utils (1)
src\sdk\src\TemplateEngine\Shared\JExtensions.cs (1)
174if (val == null || !Enum.TryParse(val, ignoreCase, out T result))
Microsoft.TemplateSearch.Common (1)
src\sdk\src\TemplateEngine\Shared\JExtensions.cs (1)
174if (val == null || !Enum.TryParse(val, ignoreCase, out T result))
Microsoft.TestPlatform.CommunicationUtilities (2)
Serialization\TestResultConverter.cs (1)
90testResult.Outcome = (TestOutcome)Enum.Parse(typeof(TestOutcome), propertyData!); break;
Serialization\TestRunStatisticsConverter.cs (1)
37if (Enum.TryParse<TestOutcome>(kvp.Name, out var outcome))
Microsoft.TestPlatform.CoreUtilities (3)
Helpers\EnvironmentVariableHelper.cs (2)
18public TEnum GetEnvironmentVariableAsEnum<TEnum>(string variable, TEnum defaultValue = default) where TEnum : struct, Enum 20? Enum.TryParse<TEnum>(value, out var enumValue) ? enumValue : defaultValue
Helpers\Interfaces\IEnvironmentVariableHelper.cs (1)
25TEnum GetEnvironmentVariableAsEnum<TEnum>(string variable, TEnum defaultValue = default) where TEnum : struct, Enum;
Microsoft.TestPlatform.Extensions.BlameDataCollector (9)
BlameCollector.cs (9)
368if (Enum.TryParse(attribute.Value, ignoreCase: true, out CrashDumpType value) && Enum.IsDefined(typeof(CrashDumpType), value)) 374_logger.LogWarning(_context.SessionDataCollectionContext, FormatBlameParameterValueIncorrectMessage(attribute, Enum.GetNames(typeof(CrashDumpType)))); 415if (Enum.TryParse(attribute.Value, ignoreCase: true, out HangDumpType value) && Enum.IsDefined(typeof(HangDumpType), value)) 421_logger.LogWarning(_context.SessionDataCollectionContext, FormatBlameParameterValueIncorrectMessage(attribute, Enum.GetNames(typeof(HangDumpType)))); 429if (Enum.TryParse(attribute.Value, ignoreCase: true, out HangDumpType value2) && Enum.IsDefined(typeof(HangDumpType), value2)) 437_logger.LogWarning(_context.SessionDataCollectionContext, FormatBlameParameterValueIncorrectMessage(attribute, Enum.GetNames(typeof(CrashDumpType))));
Microsoft.TestPlatform.TestHostRuntimeProvider (1)
Hosting\DotnetTestHostManager.cs (1)
592var architectureFromEnv = (Architecture)Enum.Parse(typeof(Architecture), dotnetRootArchitecture!, ignoreCase: true);
Microsoft.TestPlatform.Utilities (6)
CodeCoverageDataAttachmentsHandler.cs (1)
178s_mergeOperationEnumValues = Enum.GetValues(mergeOperationEnum);
InferRunSettingsHelper.cs (5)
172architecture = (Architecture)Enum.Parse(typeof(Architecture), nodeXml, true); 617var value = (Architecture)Enum.Parse(typeof(Architecture), xml, true); 619return Enum.IsDefined(typeof(Architecture), value) && value != Architecture.Default && value != Architecture.AnyCPU; 645var value = (FrameworkVersion)Enum.Parse(typeof(FrameworkVersion), xml, true); 647return Enum.IsDefined(typeof(FrameworkVersion), value) && value != FrameworkVersion.None;
Microsoft.VisualBasic.Core (14)
Microsoft\VisualBasic\CompilerServices\Conversions.vb (8)
2372If IsEnum(TargetType) Then Return [Enum].ToObject(TargetType, Expression) 2377If IsEnum(TargetType) Then Return [Enum].ToObject(TargetType, Expression) 2382If IsEnum(TargetType) Then Return [Enum].ToObject(TargetType, Expression) 2387If IsEnum(TargetType) Then Return [Enum].ToObject(TargetType, Expression) 2392If IsEnum(TargetType) Then Return [Enum].ToObject(TargetType, Expression) 2397If IsEnum(TargetType) Then Return [Enum].ToObject(TargetType, Expression) 2402If IsEnum(TargetType) Then Return [Enum].ToObject(TargetType, Expression) 2407If IsEnum(TargetType) Then Return [Enum].ToObject(TargetType, Expression)
Microsoft\VisualBasic\FileIO\FileSystem.vb (6)
895Debug.Assert([Enum].IsDefined(operation), "Invalid Operation") 964Debug.Assert([Enum].IsDefined(operation), "Invalid Operation") 1013Debug.Assert([Enum].IsDefined(Operation), "Invalid Operation") 1095Debug.Assert([Enum].IsDefined(operation), "Invalid Operation") 1600Debug.Assert([Enum].IsDefined(Operation)) 1601Debug.Assert([Enum].IsDefined(TargetType))
Microsoft.VisualStudio.TestPlatform.Common (1)
ExtensionFramework\Utilities\TestDiscovererPluginInformation.cs (1)
145Enum.TryParse(category, true, out AssemblyType assemblyType);
Microsoft.VisualStudio.TestPlatform.ObjectModel (6)
RunSettings\RunConfiguration.cs (6)
778archType = (Architecture)Enum.Parse(typeof(Architecture), value, true); 780if (!Enum.IsDefined(typeof(Architecture), archType) || Architecture.Default == archType || Architecture.AnyCPU == archType) 806defaultArchType = (Architecture)Enum.Parse(typeof(Architecture), defaultPlatformValue, true); 808if (!Enum.IsDefined(typeof(Architecture), defaultArchType) || Architecture.Default == defaultArchType || Architecture.AnyCPU == defaultArchType) 864runConfiguration.TestAdapterLoadingStrategy = Enum.TryParse<TestAdapterLoadingStrategy>(value, out var loadingStrategy) 919if (!Enum.TryParse(executionThreadApartmentState, out PlatformApartmentState apartmentState))
Microsoft.Win32.Registry (2)
Microsoft\Win32\RegistryKey.cs (2)
1212!Enum.IsDefined(typeof(RegistryValueKind), type) ? RegistryValueKind.Unknown : 1242if (!Enum.IsDefined(valueKind))
MSBuild (2)
MSBuildClientApp.cs (1)
90Enum.TryParse(exitResult.MSBuildAppExitTypeString, out MSBuildApp.ExitType MSBuildAppExitType))
XMake.cs (1)
1109if (!Enum.TryParse<CrashExitType>(exitType.ToString(), out CrashExitType crashExitType))
mscorlib (1)
src\runtime\src\libraries\shims\mscorlib\ref\mscorlib.cs (1)
222[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Enum))]
netstandard (1)
netstandard.cs (1)
780[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Enum))]
NuGet.Build.Tasks (8)
BuildTasksUtility.cs (1)
299if (!Enum.TryParse(restoreProjectStyleProperty, ignoreCase: true, out projectStyle))
CheckForDuplicateNuGetItemsTask.cs (2)
58NuGetLogCode logCode = (NuGetLogCode)Enum.Parse(typeof(NuGetLogCode), LogCode); 97if (Enum.TryParse(code, out NuGetLogCode logCode))
Common\MSBuildLogger.cs (4)
162Enum.GetName(typeof(NuGetLogCode), logMessage.Code), 163Enum.GetName(typeof(NuGetLogCode), logMessage.Code), 186Enum.GetName(typeof(NuGetLogCode), logMessage.Code), 187Enum.GetName(typeof(NuGetLogCode), logMessage.Code),
NuGetMessageTask.cs (1)
31if (!Enum.TryParse(Importance, ignoreCase: true, out MessageImportance messageImportance))
NuGet.Build.Tasks.Pack (4)
src\nuget-client\src\NuGet.Core\NuGet.Build.Tasks\Common\MSBuildLogger.cs (4)
162Enum.GetName(typeof(NuGetLogCode), logMessage.Code), 163Enum.GetName(typeof(NuGetLogCode), logMessage.Code), 186Enum.GetName(typeof(NuGetLogCode), logMessage.Code), 187Enum.GetName(typeof(NuGetLogCode), logMessage.Code),
NuGet.CommandLine.XPlat (9)
Commands\PackageReferenceCommands\ListPackage\ListPackageCommand.cs (3)
215!Enum.TryParse(outputFormatOption, ignoreCase: true, out outputFormat)) 293private static string GetEnumValues<T>() where T : struct, Enum 295var enumValues = Enum.GetValues<T>()
Commands\PackageSearch\PackageSearchArgs.cs (2)
60if (!Enum.TryParse(format, ignoreCase: true, out packageSearchFormat)) 72if (!Enum.TryParse(verbosity, ignoreCase: true, out packageSearchVerbosity))
Commands\Signing\SignCommand.cs (4)
225if (!Enum.TryParse(locationValue, ignoreCase: true, result: out storeLocation)) 230string.Join(",", Enum.GetValues<StoreLocation>().ToList()))); 243if (!Enum.TryParse(storeValue, ignoreCase: true, result: out storeName)) 248string.Join(",", Enum.GetValues<StoreName>().ToList())));
NuGet.Commands (8)
ClientCertificatesCommand\ClientCertArgsExtensions.cs (3)
18if (Enum.TryParse("FindBy" + args.FindBy, ignoreCase: true, result: out X509FindType value)) 28if (Enum.TryParse(args.StoreLocation, ignoreCase: true, result: out StoreLocation value)) 38if (Enum.TryParse(args.StoreName, ignoreCase: true, result: out StoreName value))
RestoreCommand\Utility\MSBuildRestoreUtility.cs (1)
1295Enum.TryParse(typeString, ignoreCase: true, result: out restoreType);
RestoreCommand\Utility\PackageSpecFactory.cs (1)
556if (!Enum.TryParse(restoreProjectStyleProperty, ignoreCase: true, out projectStyle))
SourcesCommands\SourceRunners.cs (1)
131Enum.TryParse<SourcesListFormat>(args.Format, ignoreCase: true, out format);
TrustedSignersCommand\TrustedSignerActionsProvider.cs (2)
93if (!Enum.IsDefined(typeof(VerificationTarget), trustTarget) || (trustTarget != VerificationTarget.Repository && trustTarget != VerificationTarget.Author)) 177if (!Enum.IsDefined(typeof(HashAlgorithmName), hashAlgorithm) || hashAlgorithm == HashAlgorithmName.Unknown)
NuGet.Common (4)
CryptoHashUtility.cs (2)
137Enum.TryParse<HashAlgorithmName>(hashAlgorithmName, ignoreCase: true, result: out var result); 149if (Enum.TryParse<HashAlgorithmName>(hashAlgorithm, ignoreCase: true, result: out var result))
Logging\LoggingExtensions.cs (1)
36return Enum.GetName(typeof(NuGetLogCode), code);
MsBuildStringUtility.cs (1)
110Enum.TryParse(value: split[i], ignoreCase: true, out NuGetLogCode logCode))
NuGet.Configuration (7)
Settings\Items\StoreClientCertItem.cs (3)
114if (Enum.TryParse("FindBy" + Attributes[ConfigurationConstants.FindByAttribute], ignoreCase: true, result: out X509FindType result)) 129if (Enum.TryParse(Attributes[ConfigurationConstants.StoreLocationAttribute], ignoreCase: true, result: out StoreLocation result)) 142if (Enum.TryParse(Attributes[ConfigurationConstants.StoreNameAttribute], ignoreCase: true, result: out StoreName result))
Settings\SettingFactory.cs (2)
29Enum.TryParse(element.Name.LocalName, ignoreCase: true, result: out elementType); 34Enum.TryParse(element.Parent?.Name.LocalName, ignoreCase: true, result: out parentType);
Utility\SettingsUtility.cs (2)
99if (!string.IsNullOrEmpty(validationMode) && Enum.TryParse(validationMode, ignoreCase: true, result: out SignatureValidationMode mode)) 438if (!string.IsNullOrEmpty(revocationModeSetting) && Enum.TryParse(revocationModeSetting, ignoreCase: true, result: out RevocationMode revocationMode))
NuGet.LibraryModel (3)
EnumUtility.cs (2)
10public static TEnum[] GetValues<TEnum>() where TEnum : struct, Enum => 12Enum.GetValues<TEnum>();
FrameworkDependencyFlagsUtils.cs (1)
26if (Enum.TryParse<FrameworkDependencyFlags>(value, ignoreCase: true, result: out var flag))
NuGet.Packaging (12)
Licenses\LicenseExpressionTokenizer.cs (1)
110var expressionToken = Enum.TryParse(value: token, result: out LicenseTokenType result);
NuspecReader.cs (1)
444var isKnownType = Enum.TryParse(type, ignoreCase: true, result: out LicenseType licenseType);
PackageCreation\Authoring\ManifestReader.cs (1)
187if (!Enum.TryParse(type, ignoreCase: true, result: out LicenseType licenseType))
Signing\Authoring\SignPackageRequest.cs (2)
66if (!Enum.IsDefined(typeof(HashAlgorithmName), signatureHashAlgorithm) || 72if (!Enum.IsDefined(typeof(HashAlgorithmName), timestampHashAlgorithm) ||
Signing\Signatures\Signature.cs (1)
348if (!Enum.IsDefined(typeof(HashAlgorithmName), algorithm))
Signing\Utility\CertificateChainUtility.cs (1)
80if (!Enum.IsDefined(typeof(CertificateType), certificateType))
Signing\Verification\CertificateHashAllowListEntry.cs (2)
20if (!Enum.IsDefined(typeof(SignaturePlacement), placement)) 30if (!Enum.IsDefined(typeof(HashAlgorithmName), algorithm))
Signing\Verification\SignedPackageVerifierSettings.cs (3)
90if (!Enum.IsDefined(typeof(VerificationTarget), verificationTarget)) 100if (!Enum.IsDefined(typeof(SignaturePlacement), signaturePlacement)) 110if (!Enum.IsDefined(typeof(SignatureVerificationBehavior), repositoryCountersignatureVerificationBehavior))
NuGet.ProjectModel (9)
JsonPackageSpecReader.Utf8JsonStreamReader.cs (3)
872&& Enum.TryParse(projectStyleString, ignoreCase: true, result: out ProjectStyle projectStyleValue)) 1142if (jsonReader.TokenType == JsonTokenType.String && Enum.TryParse(jsonReader.GetString(), out NuGetLogCode code)) 1159if (jsonReader.TokenType == JsonTokenType.String && Enum.TryParse(jsonReader.GetString(), out NuGetLogCode code))
LockFile\LockFileFormat.cs (2)
295writer.WriteValue(Enum.GetName(typeof(NuGetLogCode), logMessage.Code)); 298writer.WriteValue(Enum.GetName(typeof(LogLevel), logMessage.Level));
LockFile\Utf8JsonStreamIAssetsLogMessageConverter.cs (3)
79isValid &= Enum.TryParse(levelString, out level); 84isValid &= Enum.TryParse(codeString, out code); 89warningLevel = (WarningLevel)Enum.ToObject(typeof(WarningLevel), reader.GetInt32());
ProjectLockFile\PackagesLockFileFormat.cs (1)
258&& Enum.TryParse<PackageDependencyType>(typeString, ignoreCase: true, result: out var installationType))
NuGet.Protocol (25)
Plugins\MessageConverter.cs (4)
125if (!Enum.TryParse<MessageType>(typeStr, out var messageType) || !Enum.IsDefined(typeof(MessageType), messageType)) 136if (!Enum.TryParse<MessageMethod>(methodStr, out var messageMethod) || !Enum.IsDefined(typeof(MessageMethod), messageMethod))
Plugins\Messages\CopyFilesInPackageResponse.cs (1)
43if (!Enum.IsDefined(typeof(MessageResponseCode), responseCode))
Plugins\Messages\CopyNupkgFileResponse.cs (1)
30if (!Enum.IsDefined(typeof(MessageResponseCode), responseCode))
Plugins\Messages\GetAuthenticationCredentialsResponse.cs (1)
58if (!Enum.IsDefined(typeof(MessageResponseCode), responseCode))
Plugins\Messages\GetCredentialsRequest.cs (1)
43if (!Enum.IsDefined(typeof(HttpStatusCode), statusCode))
Plugins\Messages\GetCredentialsResponse.cs (1)
50if (!Enum.IsDefined(typeof(MessageResponseCode), responseCode))
Plugins\Messages\GetFilesInPackageResponse.cs (1)
43if (!Enum.IsDefined(typeof(MessageResponseCode), responseCode))
Plugins\Messages\GetOperationClaimsResponse.cs (1)
40var unrecognizedClaims = claims.Where(claim => !Enum.IsDefined(typeof(OperationClaim), claim));
Plugins\Messages\GetPackageHashResponse.cs (1)
40if (!Enum.IsDefined(typeof(MessageResponseCode), responseCode))
Plugins\Messages\GetPackageVersionsResponse.cs (1)
43if (!Enum.IsDefined(typeof(MessageResponseCode), responseCode))
Plugins\Messages\GetServiceIndexResponse.cs (1)
58if (!Enum.IsDefined(typeof(MessageResponseCode), responseCode))
Plugins\Messages\HandshakeResponse.cs (1)
48if (!Enum.IsDefined(typeof(MessageResponseCode), responseCode))
Plugins\Messages\InitializeResponse.cs (1)
30if (!Enum.IsDefined(typeof(MessageResponseCode), responseCode))
Plugins\Messages\LogRequest.cs (1)
42if (!Enum.IsDefined(typeof(LogLevel), logLevel))
Plugins\Messages\LogResponse.cs (1)
30if (!Enum.IsDefined(typeof(MessageResponseCode), responseCode))
Plugins\Messages\Message.cs (2)
74if (!Enum.IsDefined(typeof(MessageType), type)) 84if (!Enum.IsDefined(typeof(MessageMethod), method))
Plugins\Messages\MonitorNuGetProcessExitResponse.cs (1)
30if (!Enum.IsDefined(typeof(MessageResponseCode), responseCode))
Plugins\Messages\PrefetchPackageResponse.cs (1)
30if (!Enum.IsDefined(typeof(MessageResponseCode), responseCode))
Plugins\Messages\SetCredentialsResponse.cs (1)
30if (!Enum.IsDefined(typeof(MessageResponseCode), responseCode))
Plugins\Messages\SetLogLevelRequest.cs (1)
31if (!Enum.IsDefined(typeof(LogLevel), logLevel))
Plugins\Messages\SetLogLevelResponse.cs (1)
30if (!Enum.IsDefined(typeof(MessageResponseCode), responseCode))
PresentationBuildTasks (2)
Microsoft\Build\Tasks\Windows\UidManager.cs (1)
79_task = (UidTask)Enum.Parse(typeof(UidTask), _taskAsString);
src\wpf\src\Microsoft.DotNet.Wpf\src\PresentationFramework\System\Windows\SystemResourceKey.cs (1)
408Enum.TryParse(srkField, out SystemResourceKeyID srkId))
PresentationCore (10)
MS\Internal\FontFace\CompositeFontParser.cs (1)
333if (Enum.TryParse(_reader.GetAttribute("OS"), out fontFamilyOsVersion)
System\Windows\Input\Command\MouseActionConverter.cs (1)
105/// Helper function similar to <see cref="Enum.IsDefined{MouseAction}(MouseAction)"/>, just lighter and faster.
System\Windows\Input\Cursor.cs (1)
327return Enum.GetName(_cursorType);
System\Windows\Input\CursorConverter.cs (1)
106CursorType ct = Enum.Parse<CursorType>(text);
System\Windows\Input\InputScopeConverter.cs (2)
118sn = Enum.Parse<InputScopeNameValue>(spanSource); 154return Enum.GetName(((InputScopeName)inputScope.Names[0]).NameValue);
System\Windows\Input\InputScopeNameConverter.cs (2)
101nameValue = Enum.Parse<InputScopeNameValue>(stringSource); 138return Enum.GetName(inputScopeName.NameValue);
System\Windows\Media\Knowncolors.cs (1)
823if (Enum.IsDefined(color))
System\Windows\Media\RequestCachePolicyConverter.cs (1)
75HttpRequestCacheLevel level = Enum.Parse<HttpRequestCacheLevel>(s, true);
PresentationFramework (15)
MS\Internal\Controls\StickyNote\StickyNoteAnnotations.cs (1)
70foreach (XmlToken val in Enum.GetValues<XmlToken>())
System\Windows\Controls\DataGridColumn.cs (1)
1155ItemsSource = Enum.GetValues(propertyType)
System\Windows\Documents\FixedElement.cs (1)
157return string.Create(CultureInfo.InvariantCulture, $"{{S@{_start}---E@{_end}}} {System.Enum.GetName(_type)}");
System\Windows\Documents\FlowNode.cs (1)
178return $"Pg{page}-nCp{_fp}-Id{_scopeId}-Tp{System.Enum.GetName(_type)}";
System\Windows\Documents\Tracing\SpellerCOMActionTraceLogger.cs (1)
157foreach (Actions a in Enum.GetValues<Actions>())
System\Windows\Markup\Baml2006\Baml2006Reader.cs (1)
2510return Enum.ToObject(type.UnderlyingType, bytes).ToString();
System\Windows\Markup\Baml2006\WpfGeneratedKnownTypes.cs (1)
12895typeof(System.Enum),
System\Windows\Markup\BamlReader.cs (1)
2456if (Enum.IsDefined(keyId))
System\Windows\Markup\BamlRecords.cs (1)
2741_valueObject = Enum.ToObject(propertyType, enumBits);
System\Windows\Markup\Primitives\ElementMarkupObject.cs (2)
927Enum enumValue = value as Enum;
System\Windows\SystemKeyConverter.cs (3)
252return $"{Enum.GetName(id)}Key"; 262string propName = $"{Enum.GetName(id)}Key"; 274return Enum.GetName(id);
System\Windows\SystemResourceKey.cs (1)
408Enum.TryParse(srkField, out SystemResourceKeyID srkId))
PresentationUI (5)
MS\Internal\Documents\RightsManagementResourceHelper.cs (2)
114RightsManagementStatus[] statusList = Enum.GetValues<RightsManagementStatus>(); 136+ Enum.GetName(status)
MS\Internal\Documents\RMPublishingDialog.RightsTable.cs (1)
604return (RightsTableColumn)Enum.ToObject(typeof(RightsTableColumn), index);
MS\Internal\Documents\SignatureResourceHelper.cs (2)
140SignatureStatus[] statusList = Enum.GetValues<SignatureStatus>(); 162+ Enum.GetName(sigStatus)
ReachFramework (36)
PrintConfig\PrintSchema.cs (34)
1982internal static string[] CollationNames = Enum.GetNames(typeof(Collation)); 1983internal static int[] CollationEnums = (int[])(Array)Enum.GetValues<Collation>(); 1992internal static string[] DuplexNames = Enum.GetNames(typeof(Duplexing)); 1993internal static int[] DuplexEnums = (int[])(Array)Enum.GetValues<Duplexing>(); 2004internal static string[] DirectionNames = Enum.GetNames(typeof(PagesPerSheetDirection)); 2005internal static int[] DirectionEnums = (int[])(Array)Enum.GetValues<PagesPerSheetDirection>(); 2014internal static string[] StaplingNames = Enum.GetNames(typeof(Stapling)); 2015internal static int[] StaplingEnums = (int[])(Array)Enum.GetValues<Stapling>(); 2024internal static string[] SubstitutionNames = Enum.GetNames(typeof(DeviceFontSubstitution)); 2025internal static int[] SubstitutionEnums = (int[])(Array)Enum.GetValues<DeviceFontSubstitution>(); 2043internal static string[] MediaSizeNames = Enum.GetNames(typeof(PageMediaSizeName)); 2044internal static int[] MediaSizeEnums = (int[])(Array)Enum.GetValues<PageMediaSizeName>(); 2069internal static string[] MediaTypeNames = Enum.GetNames(typeof(PageMediaType)); 2070internal static int[] MediaTypeEnums = (int[])(Array)Enum.GetValues<PageMediaType>(); 2079internal static string[] OrientationNames = Enum.GetNames(typeof(PageOrientation)); 2080internal static int[] OrientationEnums = (int[])(Array)Enum.GetValues<PageOrientation>(); 2089internal static string[] ColorNames = Enum.GetNames(typeof(OutputColor)); 2090internal static int[] ColorEnums = (int[])(Array)Enum.GetValues<OutputColor>(); 2102internal static string[] QualityNames = Enum.GetNames(typeof(PageQualitativeResolution)); 2103internal static int[] QualityEnums = (int[])(Array)Enum.GetValues<PageQualitativeResolution>(); 2115internal static string[] ScalingNames = Enum.GetNames(typeof(PageScaling)); 2116internal static int[] ScalingEnums = (int[])(Array)Enum.GetValues<PageScaling>(); 2125internal static string[] ModeNames = Enum.GetNames(typeof(TrueTypeFontMode)); 2126internal static int[] ModeEnums = (int[])(Array)Enum.GetValues<TrueTypeFontMode>(); 2135internal static string[] PageOrderNames = Enum.GetNames(typeof(PageOrder)); 2136internal static int[] PageOrderEnums = (int[])(Array)Enum.GetValues<PageOrder>(); 2145internal static string[] PhotoIntentNames = Enum.GetNames(typeof(PhotoPrintingIntent)); 2146internal static int[] PhotoIntentEnums = (int[])(Array)Enum.GetValues<PhotoPrintingIntent>(); 2155internal static string[] BorderlessNames = Enum.GetNames(typeof(PageBorderless)); 2156internal static int[] BorderlessEnums = (int[])(Array)Enum.GetValues<PageBorderless>(); 2165internal static string[] OutputQualityNames = Enum.GetNames(typeof(OutputQuality)); 2166internal static int[] OutputQualityEnums = (int[])(Array)Enum.GetValues<OutputQuality>(); 2177internal static string[] InputBinNames = Enum.GetNames(typeof(InputBin)); 2178internal static int[] InputBinEnums = (int[])(Array)Enum.GetValues<InputBin>();
PrintConfig\PrtCap_Public.cs (2)
55_countRootFeatures = Enum.GetNames(typeof(CapabilityName)).Length; 56_countLocalParamDefs = Enum.GetNames(typeof(PrintSchemaLocalParameterDefs)).Length;
Roslyn.Diagnostics.Analyzers (34)
src\roslyn\src\Compilers\Core\Portable\InternalUtilities\EnumUtilties.cs (3)
16return (T[])Enum.GetValues(typeof(T)); 20internal static bool ContainsAllValues<T>(int mask) where T : struct, Enum, IConvertible 33internal static bool ContainsValue<T>(T value) where T : struct, Enum
src\roslyn\src\Dependencies\Contracts\EnumExtensions.cs (5)
18extension(Enum) 20public static TEnum[] GetValues<TEnum>() where TEnum : struct, Enum 21=> (TEnum[])Enum.GetValues(typeof(TEnum)); 23public static string[] GetNames<TEnum>() where TEnum : struct, Enum 24=> Enum.GetNames(typeof(TEnum));
src\roslyn\src\RoslynAnalyzers\Utilities\Compiler\Options\AnalyzerOptionsExtensions.cs (3)
27ImmutableHashSet.CreateRange(Enum.GetValues<OutputKind>()); 144tryParseValue: static (value, out result) => Enum.TryParse(value, ignoreCase: true, result: out result), 164if (Enum.TryParse(kindStr, ignoreCase: true, result: out TEnum kind))
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CodeStyle\CodeStyleOption2`1.cs (1)
180var severity = (DiagnosticSeverity)Enum.Parse(typeof(DiagnosticSeverity), severityAttribute.Value);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\NamingStyles\NamingStyle.cs (1)
480capitalizationScheme: (Capitalization)Enum.Parse(typeof(Capitalization), namingStyleElement.Attribute(nameof(CapitalizationScheme)).Value));
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\NamingStyles\Serialization\SerializableNamingRule.cs (1)
38EnforcementLevel = ((DiagnosticSeverity)Enum.Parse(typeof(DiagnosticSeverity), namingRuleElement.Attribute(nameof(EnforcementLevel))!.Value)).ToReportDiagnostic(),
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\NamingStyles\Serialization\SymbolSpecification.cs (5)
310=> (Accessibility)Enum.Parse(typeof(Accessibility), accessibilityElement.Value); 421var symbolKind = (SymbolKind)Enum.Parse(typeof(SymbolKind), symbolKindElement.Value); 433=> new((TypeKind)Enum.Parse(typeof(TypeKind), typeKindElement.Value)); 436=> new((MethodKind)Enum.Parse(typeof(MethodKind), methodKindElement.Value)); 536=> new((ModifierKindEnum)Enum.Parse(typeof(ModifierKindEnum), modifierElement.Value));
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Options\EditorConfigValueSerializer.cs (9)
104public static EditorConfigValueSerializer<T> CreateSerializerForEnum<T>() where T : struct, Enum 112public static EditorConfigValueSerializer<T> CreateSerializerForEnum<T>(BidirectionalMap<string, T> map) where T : struct, Enum 119public static EditorConfigValueSerializer<T> CreateSerializerForEnum<T>(BidirectionalMap<string, T> map, ImmutableDictionary<string, T> alternative) where T : struct, Enum 127public static EditorConfigValueSerializer<T> CreateSerializerForEnum<T>(IEnumerable<(string name, T value)> entries, IEnumerable<(string name, T value)> alternativeEntries) where T : struct, Enum 136public static EditorConfigValueSerializer<T?> CreateSerializerForNullableEnum<T>() where T : struct, Enum 158private static bool TryParseEnum<T>(string str, out T result) where T : struct, Enum 173return Enum.TryParse(str, ignoreCase: true, out result); 209where TFromEnum : struct, Enum 210where TToEnum : struct, Enum
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Simplification\SpecialTypeAnnotation.cs (1)
27=> (SpecialType)Enum.Parse(typeof(SpecialType), arg);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EnumValueUtilities.cs (2)
144where TFromEnum : struct, Enum 145where TToEnum : struct, Enum
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\OptionalExtensions.cs (2)
17where TFromEnum : struct, Enum 18where TToEnum : struct, Enum
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\TypeInferenceService\AbstractTypeInferenceService.AbstractTypeInferrer.cs (1)
119symbol.Name == nameof(Enum.HasFlag) &&
rzc (2)
Client.cs (1)
132if (Enum.IsDefined(typeof(PipeOptions), PipeOptionCurrentUserOnly))
ConnectionHost.cs (1)
77if (Enum.IsDefined(typeof(PipeOptions), PipeOptionCurrentUserOnly))
Security.TransportSecurity.IntegrationTests (1)
Https\HttpsTests.4.1.0.cs (1)
41factory = new ChannelFactory<IWcfService>(basicHttpsBinding, new EndpointAddress(Endpoints.Https_DefaultBinding_Address + Enum.GetName(typeof(WSMessageEncoding), messageEncoding)));
Shared (3)
src\LegacySupport\StringSyntaxAttribute\StringSyntaxAttribute.cs (1)
48/// <summary>The syntax identifier for strings containing <see cref="Enum"/> format specifiers.</summary>
Throw\Throw.cs (2)
223where T : struct, Enum 228if (!Enum.IsDefined(typeof(T), argument))
System.CommandLine (2)
Argument.cs (1)
111_ => Enum.GetNames(valueType).Select(n => new CompletionItem(n))
Binding\ArgumentConverter.cs (1)
65if (Enum.TryParse(type, value, ignoreCase: true, out var converted))
System.ComponentModel.Annotations (6)
System\ComponentModel\DataAnnotations\DataTypeAttribute.cs (1)
18private static readonly string[] _dataTypeStrings = Enum.GetNames<DataType>();
System\ComponentModel\DataAnnotations\EnumDataTypeAttribute.cs (4)
77? Enum.Parse(EnumType, stringValue, false) 78: Enum.ToObject(EnumType, value); 98return Enum.IsDefined(EnumType, convertedValue); 105Convert.ChangeType(enumValue, Enum.GetUnderlyingType(enumType), CultureInfo.InvariantCulture).ToString();
System\ComponentModel\DataAnnotations\Schema\DatabaseGeneratedAttribute.cs (1)
18if (!Enum.IsDefined(databaseGeneratedOption))
System.ComponentModel.Composition (1)
Microsoft\Internal\GenerationServices.cs (1)
90rawValue = Convert.ChangeType(value, Enum.GetUnderlyingType(valueType), null);
System.ComponentModel.TypeConverter (36)
System\ComponentModel\EnumConverter.cs (31)
15/// Provides a type converter to convert <see cref='System.Enum'/> objects to and 26if (!type.IsEnum && !type.Equals(typeof(Enum))) 44if (sourceType == typeof(string) || sourceType == typeof(Enum[])) 57if (destinationType == typeof(Enum[]) || destinationType == typeof(InstanceDescriptor)) 88bool isUnderlyingTypeUInt64 = Enum.GetUnderlyingType(EnumType) == typeof(ulong); 92convertedValue |= GetEnumValue(isUnderlyingTypeUInt64, Enum.Parse(EnumType, strValue.AsSpan(v), true), culture); 94return Enum.ToObject(EnumType, convertedValue); 98return Enum.Parse(EnumType, strValue, true); 106else if (value is Enum[]) 108bool isUnderlyingTypeUInt64 = Enum.GetUnderlyingType(EnumType) == typeof(ulong); 110foreach (Enum e in (Enum[])value) 114return Enum.ToObject(EnumType, finalValue); 130if (!EnumType.IsDefined(typeof(FlagsAttribute), false) && !Enum.IsDefined(EnumType, value)) 135return Enum.Format(EnumType, value, "G"); 149Type underlyingType = Enum.GetUnderlyingType(EnumType); 154MethodInfo? method = typeof(Enum).GetMethod("ToObject", new Type[] { typeof(Type), underlyingType }); 174if (destinationType == typeof(Enum[]) && value != null) 178bool isUnderlyingTypeUInt64 = Enum.GetUnderlyingType(EnumType) == typeof(ulong); 179List<Enum> flagValues = new List<Enum>(); 181Array objValues = Enum.GetValuesAsUnderlyingType(EnumType); 197flagValues.Add((Enum)Enum.ToObject(EnumType, ul)); 212flagValues.Add((Enum)Enum.ToObject(EnumType, longValue)); 219return new Enum[] { (Enum)Enum.ToObject(EnumType, value) }; 283value = Enum.Parse(EnumType, field.Name); 330public override bool IsValid(ITypeDescriptorContext? context, object? value) => Enum.IsDefined(EnumType, value!);
System\ComponentModel\ReflectPropertyDescriptor.cs (2)
204_defaultValue = Enum.ToObject(PropertyType, _defaultValue); 304Enum.ToObject(PropertyType, defaultValue!) :
System\ComponentModel\ReflectTypeDescriptionProvider.cs (2)
184[typeof(Enum)] = new IntrinsicTypeConverterData((type) => new EnumConverter(type), cacheConverterInstance: false), 1561converterData = IntrinsicTypeConverters[typeof(Enum)];
System\ComponentModel\ToolboxItemFilterAttribute.cs (1)
105public override string ToString() => FilterString + "," + Enum.GetName<ToolboxItemFilterType>(FilterType);
System.Configuration.ConfigurationManager (5)
System\Configuration\GenericEnumConverter.cs (2)
38return Enum.Parse(_enumType, value); 51string names = string.Join(", ", Enum.GetNames(_enumType));
System\Diagnostics\TraceConfiguration.cs (2)
61traceSource.Switch.Level = Enum.Parse<SourceLevels>(sourceElement.SwitchValue); 80traceSource.Switch.Level = Enum.Parse<SourceLevels>(sourceElement.SwitchValue);
System\Diagnostics\TraceUtils.cs (1)
199Enum.Parse(type, value, false) :
System.Data.Common (6)
System\Data\DataException.cs (1)
345private static Exception _InvalidEnumArgumentException<T>(T value) where T : Enum
System\Data\DataRowExtensions.cs (3)
196Type fromType = valueType.IsEnum ? Enum.GetUnderlyingType(valueType) : valueType; 197Type toType = nullableType.IsEnum ? Enum.GetUnderlyingType(nullableType) : nullableType; 199value = nullableType.IsEnum ? Enum.ToObject(nullableType, value) : Convert.ChangeType(value, nullableType, null);
System\Data\DataTable.cs (1)
3131Debug.Assert(Enum.GetUnderlyingType(typeof(DataRowState)) == typeof(int), "Invalid DataRowState type");
System\Data\DataViewManager.cs (1)
135_dataViewSettingsCollection[table]!.RowStateFilter = Enum.Parse<DataViewRowState>(r.Value);
System.Data.OleDb (3)
OleDbConnectionStringBuilder.cs (3)
640convertedValue |= (int)Enum.Parse<OleDbServiceValues>(v, true); 646return (int)Enum.Parse<OleDbServiceValues>(svalue, true); 683OleDbServiceValues[] objValues = Enum.GetValues<OleDbServiceValues>();
System.Diagnostics.EventLog (2)
System\Diagnostics\EventData.cs (1)
42if (!Enum.IsDefined(value))
System\Diagnostics\EventLogInternal.cs (1)
1309if (!Enum.IsDefined(type))
System.Diagnostics.PerformanceCounter (3)
System\Diagnostics\CounterCreationData.cs (1)
36if (!Enum.IsDefined(value))
System\Diagnostics\PerformanceData\PerfProviderCollection.cs (2)
36private static readonly CounterType[] s_counterTypes = Enum.GetValues<CounterType>(); 37private static readonly CounterSetInstanceType[] s_counterSetInstanceTypes = Enum.GetValues<CounterSetInstanceType>();
System.Diagnostics.Process (2)
System\Diagnostics\Process.cs (1)
418if (!Enum.IsDefined(value))
System\Diagnostics\ProcessStartInfo.cs (1)
364if (!Enum.IsDefined(value))
System.Diagnostics.TraceSource (2)
System\Diagnostics\SourceSwitch.cs (1)
36SwitchSetting = (int)Enum.Parse<SourceLevels>(Value, true);
System\Diagnostics\TraceSwitch.cs (1)
97TraceLevel level = Enum.Parse<TraceLevel>(Value, true);
System.Drawing.Common (2)
System\Drawing\FontConverter.cs (1)
239fontStyle |= Enum.Parse<FontStyle>(styleText, true);
System\Drawing\Printing\PrinterSettings.cs (1)
286if (!Enum.IsDefined(value))
System.Formats.Asn1 (34)
System\Formats\Asn1\AsnDecoder.Enumerated.cs (13)
121where TEnum : Enum 125return (TEnum)Enum.ToObject( 189public static Enum ReadEnumeratedValue( 234return (Enum)Enum.ToObject(enumType, value); 255return (Enum)Enum.ToObject(enumType, value); 350public TEnum ReadEnumeratedValue<TEnum>(Asn1Tag? expectedTag = null) where TEnum : Enum 404public Enum ReadEnumeratedValue(Type enumType, Asn1Tag? expectedTag = null) 406Enum ret = AsnDecoder.ReadEnumeratedValue(_data.Span, RuleSet, enumType, out int consumed, expectedTag); 495public TEnum ReadEnumeratedValue<TEnum>(Asn1Tag? expectedTag = null) where TEnum : Enum 549public Enum ReadEnumeratedValue(Type enumType, Asn1Tag? expectedTag = null) 551Enum ret = AsnDecoder.ReadEnumeratedValue(_data, RuleSet, enumType, out int consumed, expectedTag);
System\Formats\Asn1\AsnDecoder.NamedBitList.cs (14)
110where TFlagsEnum : Enum 114TFlagsEnum ret = (TFlagsEnum)Enum.ToObject( 177public static unsafe Enum ReadNamedBitListValue( 217Enum ret; 222ret = (Enum)Enum.ToObject(flagsEnumType, 0); 272ret = (Enum)Enum.ToObject(flagsEnumType, InterpretNamedBitListReversed(valueSpan)); 484public TFlagsEnum ReadNamedBitListValue<TFlagsEnum>(Asn1Tag? expectedTag = null) where TFlagsEnum : Enum 538public Enum ReadNamedBitListValue(Type flagsEnumType, Asn1Tag? expectedTag = null) 540Enum ret = AsnDecoder.ReadNamedBitListValue( 666public TFlagsEnum ReadNamedBitListValue<TFlagsEnum>(Asn1Tag? expectedTag = null) where TFlagsEnum : Enum 720public Enum ReadNamedBitListValue(Type flagsEnumType, Asn1Tag? expectedTag = null) 722Enum ret = AsnDecoder.ReadNamedBitListValue(
System\Formats\Asn1\AsnWriter.Enumerated.cs (4)
31/// <seealso cref="WriteEnumeratedValue(Enum,Asn1Tag?)"/> 33public void WriteEnumeratedValue(Enum value, Asn1Tag? tag = null) 63/// <seealso cref="WriteEnumeratedValue(Enum,Nullable{Asn1Tag})"/> 64public void WriteEnumeratedValue<TEnum>(TEnum value, Asn1Tag? tag = null) where TEnum : Enum
System\Formats\Asn1\AsnWriter.NamedBitList.cs (3)
35public void WriteNamedBitList(Enum value, Asn1Tag? tag = null) 67public void WriteNamedBitList<TEnum>(TEnum value, Asn1Tag? tag = null) where TEnum : Enum 103private void WriteNamedBitList(Asn1Tag? tag, Type tEnum, Enum value)
System.IO.Compression.ZipFile (1)
System\IO\Compression\ZipFile.Create.cs (1)
502if (compressionLevel.HasValue && !Enum.IsDefined(compressionLevel.Value))
System.IO.FileSystem.Watcher (1)
System\IO\FileSystemWatcher.cs (1)
67foreach (int enumValue in Enum.GetValues<NotifyFilters>())
System.IO.Packaging (1)
System\IO\Packaging\InternalRelationshipCollection.cs (1)
324relationshipTargetMode = Enum.Parse<TargetMode>(targetModeAttributeValue, ignoreCase: false);
System.Linq.Expressions (17)
System\Dynamic\Utils\TypeUtils.cs (2)
259if (instanceType.IsEnum && AreReferenceAssignable(targetType, typeof(Enum))) 860source.IsValueType && (destination == typeof(object) || destination == typeof(ValueType)) || source.IsEnum && destination == typeof(Enum);
System\Linq\Expressions\Compiler\ILGen.cs (1)
571typeFrom == typeof(System.Enum) ||
System\Linq\Expressions\Interpreter\LightCompiler.cs (2)
1150nonNullableFrom = Enum.GetUnderlyingType(nonNullableFrom); 1155nonNullableTo = Enum.GetUnderlyingType(nonNullableTo);
System\Linq\Expressions\Interpreter\TypeOperations.cs (11)
399frame.Push(from == null ? null : Enum.ToObject(_t, from)); 426frame.Push(Enum.ToObject(_t, (int)from)); 429frame.Push(Enum.ToObject(_t, (long)from)); 432frame.Push(Enum.ToObject(_t, (uint)from)); 435frame.Push(Enum.ToObject(_t, (ulong)from)); 438frame.Push(Enum.ToObject(_t, (byte)from)); 441frame.Push(Enum.ToObject(_t, (sbyte)from)); 444frame.Push(Enum.ToObject(_t, (short)from)); 447frame.Push(Enum.ToObject(_t, (ushort)from)); 451frame.Push(Enum.ToObject(_t, (char)from)); 457frame.Push(Enum.ToObject(_t, (bool)from));
System\Linq\Expressions\Interpreter\Utilities.cs (1)
148result = Enum.ToObject(type, result);
System.Management (1)
System\Management\WMIGenerator.cs (1)
4072cboe1.Right = new CodeTypeOfExpression(typeof(System.Enum));
System.Net.Http (1)
System\Net\Http\DiagnosticsHelper.cs (1)
75Debug.Assert(Enum.GetValues<HttpRequestError>().Length == 12, "We need to extend the mapping in case new values are added to HttpRequestError.");
System.Net.Security (1)
System\Net\Security\NetSecurityTelemetry.cs (1)
183Debug.Assert(Enum.GetValues<SslProtocols>()[^1] == SslProtocols.Tls13, "Make sure to add a counter for new SslProtocols");
System.Net.WebSockets (1)
System\Net\WebSockets\WebSocketStateHelper.cs (1)
46Debug.Assert(Enum.IsDefined(flag));
System.Private.CoreLib (84)
Internal\IntrinsicSupport\ComparerHelpers.cs (1)
96internal static int EnumOnlyCompare<T>(T x, T y) where T : struct, Enum
Internal\Reflection\Augments\ReflectionAugments.cs (1)
56Type underlyingType = Enum.GetUnderlyingType(type);
Internal\Reflection\Extensions\NonPortable\CustomAttributeInstantiator.cs (1)
137argumentValue = Enum.ToObject(argumentType, argumentValue!);
src\runtime\src\coreclr\tools\Common\Internal\Metadata\NativeFormat\NativeMetadataReader.cs (1)
127return string.Format("{1} : {0,8:X8}", _value, Enum.GetName(typeof(HandleType), this.HandleType));
src\runtime\src\libraries\System.Private.CoreLib\src\System\Collections\Generic\Comparer.cs (1)
131internal sealed partial class EnumComparer<T> : Comparer<T>, ISerializable where T : struct, Enum
src\runtime\src\libraries\System.Private.CoreLib\src\System\Collections\Generic\EqualityComparer.cs (1)
259public sealed partial class EnumEqualityComparer<T> : EqualityComparer<T>, ISerializable where T : struct, Enum
src\runtime\src\libraries\System.Private.CoreLib\src\System\ComponentModel\DefaultValueAttribute.cs (2)
59else if (type.IsSubclassOf(typeof(Enum)) && value != null) 61_value = Enum.Parse(type, value, true);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Convert.cs (2)
211if (ReferenceEquals(targetType, typeof(Enum))) 212return (Enum)value;
src\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\CodeAnalysis\StringSyntaxAttribute.cs (1)
50/// <summary>The syntax identifier for strings containing <see cref="Enum"/> format specifiers.</summary>
src\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventPipePayloadDecoder.cs (1)
30Type? enumType = parameterType.IsEnum ? Enum.GetUnderlyingType(parameterType) : null;
src\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventProvider.cs (2)
414if (data is Enum) 418Type underlyingType = Enum.GetUnderlyingType(data.GetType());
src\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventSource.cs (2)
1230public static implicit operator EventSourcePrimitive(Enum value) => new(value); 3403value = Enum.Parse(p.PropertyType, val);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\ManifestBuilder.cs (3)
263if (type.IsEnum && Enum.GetUnderlyingType(type) != typeof(ulong) && Enum.GetUnderlyingType(type) != typeof(long)) 385if (Enum.IsDefined(attribs.EventChannelType))
src\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\TraceLogging\PropertyValue.cs (2)
177type = Enum.GetUnderlyingType(type); 228type = Enum.GetUnderlyingType(type);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\TraceLogging\Statics.cs (1)
483dataType = Enum.GetUnderlyingType(dataType);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Enum.cs (21)
57public static unsafe string? GetName<TEnum>(TEnum value) where TEnum : struct, Enum 84/// <paramref name="enumType"/> is not an <see cref="Enum"/>, or <paramref name="value"/> is neither of type <paramref name="enumType"/> 219public static string[] GetNames<TEnum>() where TEnum : struct, Enum 247/// <exception cref="ArgumentException"><paramref name="enumType"/> is not an <see cref="Enum"/>.</exception> 280/// <exception cref="ArgumentException"><paramref name="enumType"/> is not an <see cref="Enum"/>.</exception> 290public static TEnum[] GetValues<TEnum>() where TEnum : struct, Enum 302/// <exception cref="ArgumentException"><paramref name="enumType"/> is not an <see cref="Enum"/>.</exception> 320public static Array GetValuesAsUnderlyingType<TEnum>() where TEnum : struct, Enum => 399public bool HasFlag(Enum flag) 472public static unsafe bool IsDefined<TEnum>(TEnum value) where TEnum : struct, Enum 515/// <paramref name="enumType"/> is not an <see cref="Enum"/>, 544/// <exception cref="ArgumentException"><paramref name="enumType"/> is not an <see cref="Enum"/>.</exception> 556/// <exception cref="ArgumentException"><paramref name="enumType"/> is not an <see cref="Enum"/>.</exception> 572/// <exception cref="ArgumentException"><paramref name="enumType"/> is not an <see cref="Enum"/>.</exception> 597/// <exception cref="ArgumentException"><paramref name="enumType"/> is not an <see cref="Enum"/>.</exception> 613/// <exception cref="ArgumentException"><typeparamref name="TEnum"/> is not an <see cref="Enum"/> type</exception> 622/// <exception cref="ArgumentException"><typeparamref name="TEnum"/> is not an <see cref="Enum"/> type</exception> 636/// <exception cref="ArgumentException"><typeparamref name="TEnum"/> is not an <see cref="Enum"/> type</exception> 658/// <exception cref="ArgumentException"><typeparamref name="TEnum"/> is not an <see cref="Enum"/> type</exception> 1620/// <exception cref="ArgumentException">The <paramref name="enumType"/> parameter is not an <see cref="Enum"/> type.</exception> 1642return ((Enum)value).ToString(format);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Environment.GetFolderPathCore.Unix.cs (1)
146if (!Enum.IsDefined(folder))
src\runtime\src\libraries\System.Private.CoreLib\src\System\MemoryExtensions.cs (2)
6165if (Enum.TryFormatUnconstrained(value, _destination.Slice(_pos), out int charsWritten)) 6226if (Enum.TryFormatUnconstrained(value, _destination.Slice(_pos), out int charsWritten, format))
src\runtime\src\libraries\System.Private.CoreLib\src\System\Reflection\CustomAttributeTypedArgument.cs (1)
99private static object? CanonicalizeValue(object? value) => (value is Enum e) ? e.GetValue() : value;
src\runtime\src\libraries\System.Private.CoreLib\src\System\Reflection\Emit\Opcode.cs (1)
117name = Enum.GetName(opCodeValue)!.ToLowerInvariant().Replace('_', '.');
src\runtime\src\libraries\System.Private.CoreLib\src\System\Resources\NeutralResourcesLanguageAttribute.cs (1)
24if (!Enum.IsDefined(location))
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\DefaultInterpolatedStringHandler.cs (2)
270while (!Enum.TryFormatUnconstrained(value, _chars.Slice(_pos), out charsWritten)) 337while (!Enum.TryFormatUnconstrained(value, _chars.Slice(_pos), out charsWritten, format))
src\runtime\src\libraries\System.Private.CoreLib\src\System\Text\StringBuilder.cs (2)
3047if (Enum.TryFormatUnconstrained(value, _stringBuilder.RemainingCurrentChunk, out int charsWritten)) 3118if (Enum.TryFormatUnconstrained(value, _stringBuilder.RemainingCurrentChunk, out int charsWritten, format))
src\runtime\src\libraries\System.Private.CoreLib\src\System\Text\Unicode\Utf8.cs (2)
734return Enum.TryFormatUnconstrained(value, utf16, out int charsWritten, format) ? 757if (Enum.TryFormatUnconstrained(value, array, out charsWritten, format))
src\runtime\src\libraries\System.Private.CoreLib\src\System\Type.cs (1)
126public virtual bool IsEnum { [Intrinsic] get => IsSubclassOf(typeof(Enum)); }
src\runtime\src\libraries\System.Private.CoreLib\src\System\Type.Enum.cs (2)
160ulArray[i] = Enum.ToUInt64(array.GetValue(i)!); 162ulong ulValue = Enum.ToUInt64(value);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Type.Helpers.cs (1)
30if (underlyingType == typeof(Delegate) || underlyingType == typeof(Enum))
System\Collections\Generic\Comparer.NativeAot.cs (1)
30internal sealed partial class EnumComparer<T> : Comparer<T> where T : struct, Enum
System\Collections\Generic\EqualityComparer.NativeAot.cs (1)
36public sealed partial class EnumEqualityComparer<T> : EqualityComparer<T> where T : struct, Enum
System\Reflection\DynamicInvokeInfo.cs (1)
581defaultValue = Enum.ToObject(Type.GetTypeFromMethodTable(nullableType), defaultValue);
System\Reflection\EnumInfo.cs (2)
35Debug.Assert(Enum.AreSorted(values)); 38ValuesAreSequentialFromZero = Enum.AreSequentialFromZero(values);
System\Reflection\Runtime\General\Assignability.cs (2)
258t = Enum.GetUnderlyingType(t); 337return t.IsClass && t != typeof(object) && t != typeof(ValueType) && t != typeof(Enum);
System\Reflection\Runtime\General\MetadataReaderExtensions.NativeFormat.cs (1)
160Type underlyingType = Enum.GetUnderlyingType(enumType);
System\Reflection\Runtime\General\NativeFormat\DefaultValueParser.cs (1)
18defaultValue = Enum.ToObject(declaredType, defaultValue);
System\Reflection\Runtime\MethodInfos\RuntimeMethodInfo.cs (2)
430dstTypeUnderlying = Enum.GetUnderlyingType(dstType); 435srcTypeUnderlying = Enum.GetUnderlyingType(srcType);
System\Reflection\Runtime\TypeInfos\RuntimeTypeInfo.cs (1)
834Type enumType = typeof(Enum);
System\RuntimeType.NativeAot.cs (13)
94if (!Enum.TryGetUnboxedValueOfEnumOrInteger(value, out rawValue)) 103return Enum.GetName(this, rawValue); 111string[] ret = Enum.GetNamesNoCopy(this); 122return Enum.InternalGetUnderlyingType(this); 147EnumInfo enumInfo = Enum.GetEnumInfo(this); 158if (!Enum.TryGetUnboxedValueOfEnumOrInteger(value, out rawValue)) 161throw new ArgumentException(SR.Format(SR.Arg_EnumUnderlyingTypeAndObjectMustBeSameType, value.GetType(), Enum.InternalGetUnderlyingType(this))); 166if (value is Enum) 173Type underlyingType = Enum.InternalGetUnderlyingType(this); 178return Enum.GetName(this, rawValue) != null; 188Array values = Enum.GetValuesAsUnderlyingTypeNoCopy(this); 195Array.CreateInstance(Enum.InternalGetUnderlyingType(this), count) : 207return Enum.GetValuesAsUnderlyingType(this);
System.Private.DataContractSerialization (13)
System\Runtime\Serialization\CodeGenerator.cs (3)
807Ldc(Convert.ChangeType(o, Enum.GetUnderlyingType(valueType), null)); 985Ldelem(Enum.GetUnderlyingType(arrayElementType)); 1024Stelem(Enum.GetUnderlyingType(arrayElementType));
System\Runtime\Serialization\DataContract.cs (2)
663"Enum" => typeof(Enum), 754else if (type == typeof(Enum) || type == typeof(ValueType))
System\Runtime\Serialization\EnumDataContract.cs (3)
129Type baseType = Enum.GetUnderlyingType(type); 372return Enum.ToObject(UnderlyingType, (object)(ulong)longValue); 373return Enum.ToObject(UnderlyingType, (object)longValue);
System\Runtime\Serialization\Json\JsonEnumDataContract.cs (2)
30enumValue = Enum.ToObject(TraditionalDataContract.UnderlyingType, jsonReader.ReadElementContentAsUnsignedLong()); 34enumValue = Enum.ToObject(TraditionalDataContract.UnderlyingType, jsonReader.ReadElementContentAsLong());
System\Runtime\Serialization\Json\JsonFormatGeneratorStatics.cs (1)
481s_parseEnumMethod = typeof(Enum).GetMethod("Parse", BindingFlags.Static | BindingFlags.Public, new Type[] { typeof(Type), typeof(string) });
System\Runtime\Serialization\Json\ReflectionJsonFormatReader.cs (1)
205pairKey = Enum.Parse(keyType, keyString);
System\Runtime\Serialization\Json\XmlObjectSerializerWriteContextComplexJson.cs (1)
124if (declaredContract.UnderlyingType == typeof(Enum))
System.Private.Reflection.Execution (1)
Internal\Reflection\Execution\TypeLoader\ConstraintValidatorSupport.cs (1)
307return NormalizedPrimitiveTypeSizeForIntegerTypes(Enum.GetUnderlyingType(type));
System.Private.TypeLoader (3)
Internal\Runtime\TypeLoader\TypeLoaderTypeSystemContext.cs (1)
104return (DefType)ResolveRuntimeTypeHandle(typeof(Enum).TypeHandle);
Internal\TypeSystem\RuntimeNoMetadataType.cs (2)
183(MethodTable->IsGenericTypeDefinition || MethodTable->BaseType == typeof(System.Enum).TypeHandle.ToEETypePtr())) 194MethodTable->BaseType != typeof(System.Enum).TypeHandle.ToEETypePtr());
System.Private.Windows.Core.TestUtilities (6)
XUnit\EnumDataAttribute.cs (2)
9public class EnumDataAttribute<TEnum> : CommonMemberDataAttribute where TEnum : struct, Enum 13public static ReadOnlyTheoryData TheoryData { get; } = new(Enum.GetValues<TEnum>());
XUnit\InvalidEnumDataAttribute.cs (4)
14public class InvalidEnumDataAttribute<TEnum> : CommonMemberDataAttribute where TEnum : unmanaged, Enum 35defined = Enum.IsDefined(currentValue); 55defined = Enum.IsDefined(currentValue); 65defined = Enum.IsDefined(currentValue);
System.Private.Xml (27)
System\Xml\Serialization\CodeGenerator.cs (3)
778Ldc(Convert.ChangeType(o, Enum.GetUnderlyingType(valueType), null)); 1062Ldelem(Enum.GetUnderlyingType(arrayElementType)); 1109Stelem(Enum.GetUnderlyingType(arrayElementType));
System\Xml\Serialization\ReflectionXmlSerializationReader.cs (3)
1280return Enum.ToObject(mapping.TypeDesc!.Type!, ToEnum(source, table, mapping.TypeDesc.Name)); 1288return Enum.Parse(mapping.TypeDesc!.Type!, c.Name); 1759object choiceValue = Enum.Parse(choice.Mapping!.TypeDesc!.Type!, name);
System\Xml\Serialization\SoapReflectionImporter.cs (2)
752string strValue = Enum.Format(a.SoapDefaultValue.GetType(), a.SoapDefaultValue, "G").Replace(",", " "); 753string numValue = Enum.Format(a.SoapDefaultValue.GetType(), a.SoapDefaultValue, "D");
System\Xml\Serialization\XmlReflectionImporter.cs (2)
2161string strValue = Enum.Format(t, a.XmlDefaultValue, "G").Replace(",", " "); 2162string numValue = Enum.Format(t, a.XmlDefaultValue, "D");
System\Xml\Serialization\XmlSerializationReader.cs (1)
3053Writer.Write(typeof(Enum).FullName);
System\Xml\Serialization\XmlSerializationReaderILGen.cs (3)
992ilg.Ldc(Enum.ToObject(mapping.TypeDesc!.Type!, constants[i].Value)); 1029underlyingType = Enum.GetUnderlyingType(returnType); 1095retValues.Add(Enum.ToObject(mapping.TypeDesc.Type!, c.Value));
System\Xml\Serialization\XmlSerializationWriterILGen.cs (5)
222ilg.Ldc(Enum.Parse(mapping.TypeDesc.Type!, enumDefaultValue!, false)); 634ilg.Ldc(Enum.ToObject(mapping.TypeDesc.Type!, c.Value)); 2253eValue = Enum.ToObject(choiceMapping.TypeDesc!.Type!, choiceMapping.Constants[i].Value); 2267eValue = Enum.ToObject(choiceMapping.TypeDesc!.Type!, choiceMapping.Constants[i].Value); 2342ilg.Ldc(Enum.Parse(type, memberName, false));
System\Xml\Xsl\IlGen\OptimizerPatterns.cs (3)
57private static readonly int s_patternCount = Enum.GetValues<OptimizerPatternName>().Length; 245Debug.Assert(Enum.IsDefined(pattern)); 256Debug.Assert(Enum.IsDefined(pattern));
System\Xml\Xsl\IlGen\XmlILTrace.cs (1)
182string s = Enum.GetName(typeof(XmlILOptimization), opt)!;
System\Xml\Xsl\QIL\QilXmlWriter.cs (2)
209this.writer.WriteStartElement(Enum.GetName(n.NodeType)!); 280this.writer.WriteStartElement("", Enum.GetName(node.NodeType)!, "");
System\Xml\Xsl\Runtime\XmlExtensionFunction.cs (1)
330return Enum.GetUnderlyingType(clrType);
System\Xml\Xsl\XmlQueryTypeFactory.cs (1)
350XmlTypeCode[] arrEnum = Enum.GetValues<XmlTypeCode>();
System.Reflection.Emit (1)
System\Reflection\Emit\EnumBuilderImpl.cs (1)
19_typeBuilder = new TypeBuilderImpl(name, visibility | TypeAttributes.Sealed, typeof(Enum), module,
System.Reflection.Metadata (4)
System\Reflection\Metadata\BlobWriterImpl.cs (3)
167type = Enum.GetUnderlyingType(type); 264type = Enum.GetUnderlyingType(type); 337type = Enum.GetUnderlyingType(type);
System\Reflection\Metadata\Ecma335\Encoding\BlobEncoders.cs (1)
598/// <see cref="Enum"/> (encoded as the underlying integer value).
System.Resources.Extensions (1)
src\runtime\src\libraries\Common\src\System\Resources\ResourceWriter.cs (1)
474ResourceTypeCode typeCode = Enum.Parse<ResourceTypeCode>(typeName);
System.Resources.Writer (1)
src\runtime\src\libraries\Common\src\System\Resources\ResourceWriter.cs (1)
474ResourceTypeCode typeCode = Enum.Parse<ResourceTypeCode>(typeName);
System.Runtime (1)
src\runtime\artifacts\obj\System.Runtime\Release\net11.0\System.Runtime.Forwards.cs (1)
179[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Enum))]
System.ServiceModel.Federation (1)
System\ServiceModel\Federation\WSTrustChannelSecurityTokenProvider.cs (1)
369if (!Enum.IsDefined(typeof(SecurityKeyEntropyMode), value))
System.ServiceModel.NetFramingBase (1)
System\ServiceModel\Channels\SslProtocolsHelper.cs (1)
14foreach (var protocol in Enum.GetValues(typeof(SslProtocols)))
System.ServiceModel.NetTcp (1)
System\ServiceModel\Channels\SslProtocolsHelper.cs (1)
14foreach (var protocol in Enum.GetValues(typeof(SslProtocols)))
System.ServiceModel.Primitives (2)
Extensions\ReflectionExtensions.cs (1)
203return GetTypeCode(Enum.GetUnderlyingType(type));
System\ServiceModel\Description\PrincipalPermissionMode.cs (1)
21return Enum.IsDefined(typeof(PrincipalPermissionMode), principalPermissionMode);
System.ServiceModel.UnixDomainSocket (1)
System\ServiceModel\Channels\SslProtocolsHelper.cs (1)
14foreach (var protocol in Enum.GetValues(typeof(SslProtocols)))
System.ServiceProcess.ServiceController (1)
System\ServiceProcess\ServiceController.cs (1)
982if (!Enum.IsDefined(desiredStatus))
System.Text.Encodings.Web (1)
System\Text\Encodings\Web\ThrowHelper.cs (1)
25Debug.Assert(Enum.IsDefined(typeof(ExceptionArgument), argument),
System.Text.Json (11)
src\runtime\src\libraries\System.Text.Json\Common\ReflectionExtensions.cs (2)
308return Enum.ToObject(parameterType, defaultValue); 313return Enum.ToObject(underlyingType, defaultValue);
System\Text\Json\Serialization\Converters\Value\EnumConverter.cs (5)
17where T : struct, Enum 269success = Enum.TryParse(source, out result); 400s_isFlagsEnum || (dictionaryKeyPolicy is not null && Enum.IsDefined(typeof(T), value)), 534string[] names = Enum.GetNames<T>(); 535T[] values = Enum.GetValues<T>();
System\Text\Json\Serialization\Converters\Value\EnumConverterFactory.cs (1)
57where T : struct, Enum
System\Text\Json\Serialization\JsonNumberEnumConverter.cs (1)
18where TEnum : struct, Enum
System\Text\Json\Serialization\JsonStringEnumConverter.cs (1)
17where TEnum : struct, Enum
System\Text\Json\Serialization\Metadata\JsonMetadataServices.Converters.cs (1)
287public static JsonConverter<T> GetEnumConverter<T>(JsonSerializerOptions options) where T : struct, Enum
System.Text.Json.SourceGeneration (1)
Helpers\SourceGeneratorHelpers.cs (1)
13public static string FormatEnumLiteral<TEnum>(string fullyQualifiedName, TEnum value) where TEnum : struct, Enum
System.Text.RegularExpressions (6)
System\Text\RegularExpressions\RegexWriter.cs (2)
31Debug.Assert(!Enum.IsDefined(BeforeChild)); 32Debug.Assert(!Enum.IsDefined(AfterChild));
System\Text\RegularExpressions\Symbolic\RegexNodeConverter.cs (2)
378Debug.Assert(!Enum.IsDefined((UnicodeCategory)UnicodeCategoryCount)); 523Debug.Assert(Enum.IsDefined(code) || code == (UnicodeCategory)(RegexCharClass.SpaceConst - 1), $"Unknown category: {code}");
System\Text\RegularExpressions\Symbolic\UnicodeCategoryConditions.cs (1)
28Debug.Assert(Enum.GetValues<UnicodeCategory>().Length == UnicodeCategoryValueCount);
System\Text\RegularExpressions\Symbolic\UnicodeCategoryRangesGenerator.cs (1)
42foreach (UnicodeCategory c in Enum.GetValues<UnicodeCategory>())
System.Windows.Forms (26)
_generated\0\BaseValidator.cs (1)
8public static void Validate(System.Enum enumToValidate, string parameterName = "value")
System\Windows\Forms\ActiveX\AxHost.AxPropertyDescriptor.cs (1)
226_baseDescriptor.SetValue(component, Enum.ToObject(PropertyType, value));
System\Windows\Forms\ComponentModel\COM2Interop\COM2EnumConverter.cs (1)
35? Enum.ToObject(destinationType, value)
System\Windows\Forms\ComponentModel\COM2Interop\Com2IPerPropertyBrowsingHandler.Com2IPerPropertyBrowsingEnum.cs (1)
114valueItems[i] = Enum.ToObject(targetType, valueItems[i]);
System\Windows\Forms\ComponentModel\COM2Interop\COM2PropertyDescriptor.cs (1)
660_lastValue = Enum.ToObject(_propertyType, _lastValue);
System\Windows\Forms\Controls\DataGridView\DataGridViewBand.cs (1)
487if (!Enum.IsDefined(value))
System\Windows\Forms\Controls\DataGridView\DataGridViewCellStyle.cs (1)
97Debug.Assert(Enum.IsDefined(value));
System\Windows\Forms\Controls\DataGridView\DataGridViewHeaderCell.cs (1)
564Debug.Assert(Enum.IsDefined(newButtonState));
System\Windows\Forms\Controls\ListView\ListView.ListViewAccessibleObject.cs (1)
14private static readonly int[] s_enumViewValues = (int[])Enum.GetValues(typeof(View));
System\Windows\Forms\Controls\ListView\ListViewItem.IKeyboardToolTip.cs (1)
34foreach (SearchDirectionHint searchDirectionHint in Enum.GetValues(typeof(SearchDirectionHint)))
System\Windows\Forms\Controls\WebBrowser\WebBrowser.WebBrowserSite.cs (1)
165if (lpMsg->message != PInvokeCore.WM_CHAR && Enum.IsDefined((Shortcut)keyCode))
System\Windows\Forms\Input\KeyEventArgs.cs (1)
48if (!Enum.IsDefined(keyGenerated))
System\Windows\Forms\Input\KeysConverter.cs (12)
130=> sourceType == typeof(string) || sourceType == typeof(Enum[]) || base.CanConvertFrom(context, sourceType); 137=> destinationType == typeof(Enum[]) || base.CanConvertTo(context, destinationType); 174currentKey = (Keys)Enum.Parse(typeof(Keys), token); 198if (value is Enum[] valueAsEnumArray) 201foreach (Enum e in valueAsEnumArray) 206return Enum.ToObject(typeof(Keys), finalValue); 230: destinationType == typeof(Enum[]) 234Enum[] GetTermKeys(Keys key) 236List<Enum> termKeys = []; 274if (!foundKey && Enum.IsDefined(keyOnly)) 322if (!foundKey && Enum.IsDefined(keyOnly)) 324termStrings.Append(Enum.GetName(keyOnly));
System\Windows\Forms\Input\PreviewKeyDownEventArgs.cs (1)
38if (!Enum.IsDefined(keyGenerated))
System\Windows\Forms\Panels\TableLayoutPanel\TableLayoutSettingsTypeConverter.cs (1)
197SizeType type = (SizeType)Enum.Parse(sizeTypeType, styleString.AsSpan(currentIndex, nextIndex - currentIndex), true);
System.Windows.Forms.Analyzers.CSharp (3)
System\Windows\Forms\CSharp\Generators\ApplicationConfiguration\ProjectFileReader.cs (2)
111if (!Enum.TryParse(rawValue, true, out highDpiMode) || 112!Enum.IsDefined(typeof(HighDpiMode), highDpiMode))
System\Windows\Forms\CSharp\Generators\ApplicationConfiguration\ProjectFileReader.FontConverter.cs (1)
104fontStyle |= (FontStyle)Enum.Parse(typeof(FontStyle), styleText, true);
System.Windows.Forms.Design (10)
_generated\0\BaseValidator.cs (1)
8public static void Validate(System.Enum enumToValidate, string parameterName = "value")
System\ComponentModel\Design\Serialization\CodeDomSerializationProvider.cs (1)
68if (typeof(Enum).IsAssignableFrom(objectType))
System\ComponentModel\Design\Serialization\CodeDomSerializerBase.cs (2)
1406if (result != left && left is Enum) 1409result = Enum.ToObject(left.GetType(), result);
System\ComponentModel\Design\Serialization\EnumCodeDomSerializer.cs (6)
27if (value is not Enum enumValue) 34Enum[] values; 36if (converter is not null && converter.CanConvertTo(typeof(Enum[]))) 38values = (Enum[])converter.ConvertTo(enumValue, typeof(Enum[]))!; 61foreach (Enum term in values)
System.Windows.Forms.Primitives (2)
System\EnumExtensions.cs (1)
19public static unsafe void ChangeFlags<T>(ref this T value, T flags, bool set) where T : unmanaged, Enum
System\Windows\Forms\Internals\ScaleHelper.cs (1)
86Debug.Assert(Enum.IsDefined(processDpiAwareness));
System.Xaml (1)
System\Windows\Markup\StaticExtension.cs (1)
101return Enum.Parse(type, fieldString);
testhost (1)
src\vstest\src\testhost.x86\DefaultEngineInvoker.cs (1)
291var traceLevel = Enum.IsDefined(typeof(PlatformTraceLevel), traceLevelInt) ?
testhost.arm64 (1)
src\vstest\src\testhost.x86\DefaultEngineInvoker.cs (1)
291var traceLevel = Enum.IsDefined(typeof(PlatformTraceLevel), traceLevelInt) ?
testhost.x86 (1)
DefaultEngineInvoker.cs (1)
291var traceLevel = Enum.IsDefined(typeof(PlatformTraceLevel), traceLevelInt) ?
TestProject.AppHost (2)
tests\testproject\Common\TestResourceNames.cs (2)
24if (Enum.TryParse<TestResourceNames>(resourceName, ignoreCase: true, out var name)) 39return string.Join(',', Enum.GetValues<TestResourceNames>()
TestProject.IntegrationServiceA (2)
tests\testproject\Common\TestResourceNames.cs (2)
24if (Enum.TryParse<TestResourceNames>(resourceName, ignoreCase: true, out var name)) 39return string.Join(',', Enum.GetValues<TestResourceNames>()
UIAutomationClient (1)
System\Windows\Automation\Text\TextRange.cs (1)
244obj = Enum.ToObject(ai.Type, (int)obj);
UIAutomationClientSideProviders (2)
MS\Internal\AutomationProxies\WindowsEditBoxRange.cs (1)
185if (targetAttribute is Enum)
MS\Internal\AutomationProxies\WindowsRichEditRange.cs (1)
436else if (v2 is Enum)
vstest.console (9)
CommandLine\Executor.cs (1)
160if (Enum.TryParse<TraceLevel>(diagVerbosity, ignoreCase: true, out var parsedVerbosity))
Internal\ConsoleLogger.cs (1)
207if (verbosityExists && Enum.TryParse(verbosity, true, out Verbosity verbosityLevel))
Processors\CLIRunSettingsArgumentProcessor.cs (1)
233bool success = Enum.TryParse<Architecture>(value, true, out var architecture);
Processors\EnableDiagArgumentProcessor.cs (1)
200if (traceLevelExists && Enum.TryParse(traceLevelStr, true, out PlatformTraceLevel traceLevel))
Processors\PlatformArgumentProcessor.cs (2)
106var validPlatforms = Enum.GetValues(typeof(Architecture)).Cast<Architecture>() 110var validPlatform = Enum.TryParse(argument, true, out Architecture platform);
Processors\RunSettingsArgumentProcessor.cs (1)
145if (Enum.TryParse<Architecture>(platformStr, true, out var architecture))
Processors\TestAdapterLoadingStrategyArgumentProcessor.cs (1)
158if (!Enum.TryParse(value, out strategy))
TestPlatformHelpers\TestRequestManager.cs (1)
1368chosenPlatform = (Architecture)Enum.Parse(typeof(Architecture), platformXml, ignoreCase: true);
vstest.console.arm64 (9)
src\vstest\src\vstest.console\CommandLine\Executor.cs (1)
160if (Enum.TryParse<TraceLevel>(diagVerbosity, ignoreCase: true, out var parsedVerbosity))
src\vstest\src\vstest.console\Internal\ConsoleLogger.cs (1)
207if (verbosityExists && Enum.TryParse(verbosity, true, out Verbosity verbosityLevel))
src\vstest\src\vstest.console\Processors\CLIRunSettingsArgumentProcessor.cs (1)
233bool success = Enum.TryParse<Architecture>(value, true, out var architecture);
src\vstest\src\vstest.console\Processors\EnableDiagArgumentProcessor.cs (1)
200if (traceLevelExists && Enum.TryParse(traceLevelStr, true, out PlatformTraceLevel traceLevel))
src\vstest\src\vstest.console\Processors\PlatformArgumentProcessor.cs (2)
106var validPlatforms = Enum.GetValues(typeof(Architecture)).Cast<Architecture>() 110var validPlatform = Enum.TryParse(argument, true, out Architecture platform);
src\vstest\src\vstest.console\Processors\RunSettingsArgumentProcessor.cs (1)
145if (Enum.TryParse<Architecture>(platformStr, true, out var architecture))
src\vstest\src\vstest.console\Processors\TestAdapterLoadingStrategyArgumentProcessor.cs (1)
158if (!Enum.TryParse(value, out strategy))
src\vstest\src\vstest.console\TestPlatformHelpers\TestRequestManager.cs (1)
1368chosenPlatform = (Architecture)Enum.Parse(typeof(Architecture), platformXml, ignoreCase: true);