diff --git a/src/libraries/Common/src/System/Resources/ResourceWriter.cs b/src/libraries/Common/src/System/Resources/ResourceWriter.cs index 2db581f8e6010..1f93de2776395 100644 --- a/src/libraries/Common/src/System/Resources/ResourceWriter.cs +++ b/src/libraries/Common/src/System/Resources/ResourceWriter.cs @@ -488,7 +488,11 @@ private static ResourceTypeCode FindTypeCode(object? value, List types) if (typeName.StartsWith("ResourceTypeCode.", StringComparison.Ordinal)) { typeName = typeName.Substring(17); // Remove through '.' +#if NETCOREAPP ResourceTypeCode typeCode = Enum.Parse(typeName); +#else + ResourceTypeCode typeCode = (ResourceTypeCode)Enum.Parse(typeof(ResourceTypeCode), typeName); +#endif return typeCode; } } diff --git a/src/libraries/System.Text.Encodings.Web/src/System/Text/Encodings/Web/ThrowHelper.cs b/src/libraries/System.Text.Encodings.Web/src/System/Text/Encodings/Web/ThrowHelper.cs index 752f66d8c2e94..d4491ead88d2c 100644 --- a/src/libraries/System.Text.Encodings.Web/src/System/Text/Encodings/Web/ThrowHelper.cs +++ b/src/libraries/System.Text.Encodings.Web/src/System/Text/Encodings/Web/ThrowHelper.cs @@ -22,7 +22,7 @@ internal static void ThrowArgumentOutOfRangeException(ExceptionArgument argument private static string GetArgumentName(ExceptionArgument argument) { - Debug.Assert(Enum.IsDefined(argument), + Debug.Assert(Enum.IsDefined(typeof(ExceptionArgument), argument), "The enum value is not defined, please check the ExceptionArgument Enum."); return argument.ToString(); diff --git a/src/tasks/AotCompilerTask/MonoAOTCompiler.cs b/src/tasks/AotCompilerTask/MonoAOTCompiler.cs index cb8305bd48430..09d58b2a9d083 100644 --- a/src/tasks/AotCompilerTask/MonoAOTCompiler.cs +++ b/src/tasks/AotCompilerTask/MonoAOTCompiler.cs @@ -373,7 +373,7 @@ private bool ProcessAndValidateArguments() if (!Enum.TryParse(Mode, true, out parsedAotMode)) { - Log.LogError($"Unknown Mode value: {Mode}. '{nameof(Mode)}' must be one of: {string.Join(",", Enum.GetNames())}"); + Log.LogError($"Unknown Mode value: {Mode}. '{nameof(Mode)}' must be one of: {string.Join(",", Enum.GetNames(typeof(MonoAotMode)))}"); return false; } diff --git a/src/tasks/Microsoft.NET.WebAssembly.Webcil/WasmModuleReader.cs b/src/tasks/Microsoft.NET.WebAssembly.Webcil/WasmModuleReader.cs index f6e30f3c287e6..a0744c33a8376 100644 --- a/src/tasks/Microsoft.NET.WebAssembly.Webcil/WasmModuleReader.cs +++ b/src/tasks/Microsoft.NET.WebAssembly.Webcil/WasmModuleReader.cs @@ -101,7 +101,7 @@ private bool DoVisitSection(out bool shouldStop) shouldStop = false; byte code = _reader.ReadByte(); Section section = (Section)code; - if (!Enum.IsDefined(section)) + if (!Enum.IsDefined(typeof(Section), section)) return false; uint sectionSize = ReadULEB128(); diff --git a/src/tasks/WasmAppBuilder/EmccCompile.cs b/src/tasks/WasmAppBuilder/EmccCompile.cs index 1db6ce80f241a..3471206f7abde 100644 --- a/src/tasks/WasmAppBuilder/EmccCompile.cs +++ b/src/tasks/WasmAppBuilder/EmccCompile.cs @@ -75,7 +75,7 @@ private bool ExecuteActual() if (!Enum.TryParse(OutputMessageImportance, ignoreCase: true, out MessageImportance messageImportance)) { - Log.LogError($"Invalid value for OutputMessageImportance={OutputMessageImportance}. Valid values: {string.Join(", ", Enum.GetNames())}"); + Log.LogError($"Invalid value for OutputMessageImportance={OutputMessageImportance}. Valid values: {string.Join(", ", Enum.GetNames(typeof(MessageImportance)))}"); return false; }