Move GetExceptionForHRInternal into common (#50085)
authorMichal Strehovský <MichalStrehovsky@users.noreply.github.com>
Tue, 23 Mar 2021 14:19:19 +0000 (15:19 +0100)
committerGitHub <noreply@github.com>
Tue, 23 Mar 2021 14:19:19 +0000 (07:19 -0700)
Deleted the HResults.S_OK and HResults.S_FALSE cases because those are handled by the caller. Didn't touch anything otherwise.

src/libraries/Common/src/System/HResults.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs
src/mono/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.Mono.cs

index 22127a4..330c3df 100644 (file)
@@ -122,5 +122,33 @@ namespace System
         internal const int RO_E_CLOSED = unchecked((int)0x80000013);
         internal const int RPC_E_CHANGED_MODE = unchecked((int)0x80010106);
         internal const int TYPE_E_TYPEMISMATCH = unchecked((int)0x80028CA0);
+        internal const int STG_E_PATHNOTFOUND = unchecked((int)0x80030003);
+        internal const int CTL_E_PATHNOTFOUND = unchecked((int)0x800A004C);
+        internal const int CTL_E_FILENOTFOUND = unchecked((int)0x800A0035);
+        internal const int FUSION_E_INVALID_PRIVATE_ASM_LOCATION = unchecked((int)0x80131041);
+        internal const int FUSION_E_SIGNATURE_CHECK_FAILED = unchecked((int)0x80131045);
+        internal const int FUSION_E_LOADFROM_BLOCKED = unchecked((int)0x80131051);
+        internal const int FUSION_E_CACHEFILE_FAILED = unchecked((int)0x80131052);
+        internal const int FUSION_E_ASM_MODULE_MISSING = unchecked((int)0x80131042);
+        internal const int FUSION_E_INVALID_NAME = unchecked((int)0x80131047);
+        internal const int FUSION_E_PRIVATE_ASM_DISALLOWED = unchecked((int)0x80131044);
+        internal const int FUSION_E_HOST_GAC_ASM_MISMATCH = unchecked((int)0x80131050);
+        internal const int COR_E_MODULE_HASH_CHECK_FAILED = unchecked((int)0x80131039);
+        internal const int FUSION_E_REF_DEF_MISMATCH = unchecked((int)0x80131040);
+        internal const int SECURITY_E_INCOMPATIBLE_SHARE = unchecked((int)0x80131401);
+        internal const int SECURITY_E_INCOMPATIBLE_EVIDENCE = unchecked((int)0x80131403);
+        internal const int SECURITY_E_UNVERIFIABLE = unchecked((int)0x80131402);
+        internal const int COR_E_FIXUPSINEXE = unchecked((int)0x80131019);
+        internal const int ERROR_TOO_MANY_OPEN_FILES = unchecked((int)0x80070004);
+        internal const int ERROR_SHARING_VIOLATION = unchecked((int)0x80070020);
+        internal const int ERROR_LOCK_VIOLATION = unchecked((int)0x80070021);
+        internal const int ERROR_OPEN_FAILED = unchecked((int)0x8007006E);
+        internal const int ERROR_DISK_CORRUPT = unchecked((int)0x80070571);
+        internal const int ERROR_UNRECOGNIZED_VOLUME = unchecked((int)0x800703ED);
+        internal const int ERROR_DLL_INIT_FAILED = unchecked((int)0x8007045A);
+        internal const int FUSION_E_CODE_DOWNLOAD_DISABLED = unchecked((int)0x80131048);
+        internal const int CORSEC_E_MISSING_STRONGNAME = unchecked((int)0x8013141b);
+        internal const int MSEE_E_ASSEMBLYLOADINPROGRESS = unchecked((int)0x80131016);
+        internal const int ERROR_FILE_INVALID = unchecked((int)0x800703EE);
     }
 }
index 3c247a1..2eef2d0 100644 (file)
@@ -592,6 +592,236 @@ namespace System.Runtime.InteropServices
             return GetExceptionForHRInternal(errorCode, errorInfo);
         }
 
+#if !CORECLR
+        private static Exception? GetExceptionForHRInternal(int errorCode, IntPtr errorInfo)
+        {
+            switch (errorCode)
+            {
+                case HResults.COR_E_AMBIGUOUSMATCH:
+                    return new System.Reflection.AmbiguousMatchException();
+                case HResults.COR_E_APPLICATION:
+                    return new System.ApplicationException();
+                case HResults.COR_E_ARGUMENT:
+                    return new System.ArgumentException();
+                case HResults.COR_E_ARGUMENTOUTOFRANGE:
+                    return new System.ArgumentOutOfRangeException();
+                case HResults.COR_E_ARITHMETIC:
+                    return new System.ArithmeticException();
+                case HResults.COR_E_ARRAYTYPEMISMATCH:
+                    return new System.ArrayTypeMismatchException();
+                case HResults.COR_E_BADEXEFORMAT:
+                    return new System.BadImageFormatException();
+                case HResults.COR_E_BADIMAGEFORMAT:
+                    return new System.BadImageFormatException();
+                //case HResults.COR_E_CODECONTRACTFAILED:
+                //return new System.Diagnostics.Contracts.ContractException ();
+                //case HResults.COR_E_COMEMULATE:
+                case HResults.COR_E_CUSTOMATTRIBUTEFORMAT:
+                    return new System.Reflection.CustomAttributeFormatException();
+                case HResults.COR_E_DATAMISALIGNED:
+                    return new System.DataMisalignedException();
+                case HResults.COR_E_DIRECTORYNOTFOUND:
+                    return new System.IO.DirectoryNotFoundException();
+                case HResults.COR_E_DIVIDEBYZERO:
+                    return new System.DivideByZeroException();
+                case HResults.COR_E_DLLNOTFOUND:
+                    return new System.DllNotFoundException();
+                case HResults.COR_E_DUPLICATEWAITOBJECT:
+                    return new System.DuplicateWaitObjectException();
+                case HResults.COR_E_ENDOFSTREAM:
+                    return new System.IO.EndOfStreamException();
+                case HResults.COR_E_ENTRYPOINTNOTFOUND:
+                    return new System.EntryPointNotFoundException();
+                case HResults.COR_E_EXCEPTION:
+                    return new System.Exception();
+                case HResults.COR_E_EXECUTIONENGINE:
+                    return new System.ExecutionEngineException();
+                case HResults.COR_E_FIELDACCESS:
+                    return new System.FieldAccessException();
+                case HResults.COR_E_FILELOAD:
+                    return new System.IO.FileLoadException();
+                case HResults.COR_E_FILENOTFOUND:
+                    return new System.IO.FileNotFoundException();
+                case HResults.COR_E_FORMAT:
+                    return new System.FormatException();
+                case HResults.COR_E_INDEXOUTOFRANGE:
+                    return new System.IndexOutOfRangeException();
+                case HResults.COR_E_INSUFFICIENTEXECUTIONSTACK:
+                    return new System.InsufficientExecutionStackException();
+                case HResults.COR_E_INVALIDCAST:
+                    return new System.InvalidCastException();
+                case HResults.COR_E_INVALIDFILTERCRITERIA:
+                    return new System.Reflection.InvalidFilterCriteriaException();
+                case HResults.COR_E_INVALIDOLEVARIANTTYPE:
+                    return new System.Runtime.InteropServices.InvalidOleVariantTypeException();
+                case HResults.COR_E_INVALIDOPERATION:
+                    return new System.InvalidOperationException();
+                case HResults.COR_E_INVALIDPROGRAM:
+                    return new System.InvalidProgramException();
+                case HResults.COR_E_IO:
+                    return new System.IO.IOException();
+                case HResults.COR_E_MARSHALDIRECTIVE:
+                    return new System.Runtime.InteropServices.MarshalDirectiveException();
+                case HResults.COR_E_MEMBERACCESS:
+                    return new System.MemberAccessException();
+                case HResults.COR_E_METHODACCESS:
+                    return new System.MethodAccessException();
+                case HResults.COR_E_MISSINGFIELD:
+                    return new System.MissingFieldException();
+                case HResults.COR_E_MISSINGMANIFESTRESOURCE:
+                    return new System.Resources.MissingManifestResourceException();
+                case HResults.COR_E_MISSINGMEMBER:
+                    return new System.MissingMemberException();
+                case HResults.COR_E_MISSINGMETHOD:
+                    return new System.MissingMethodException();
+                case HResults.COR_E_MULTICASTNOTSUPPORTED:
+                    return new System.MulticastNotSupportedException();
+                case HResults.COR_E_NOTFINITENUMBER:
+                    return new System.NotFiniteNumberException();
+                case HResults.COR_E_NOTSUPPORTED:
+                    return new System.NotSupportedException();
+                case HResults.E_POINTER:
+                    return new System.NullReferenceException();
+                case HResults.COR_E_OBJECTDISPOSED:
+                    return new System.ObjectDisposedException("");
+                case HResults.COR_E_OPERATIONCANCELED:
+                    return new System.OperationCanceledException();
+                case HResults.COR_E_OUTOFMEMORY:
+                    return new System.OutOfMemoryException();
+                case HResults.COR_E_OVERFLOW:
+                    return new System.OverflowException();
+                case HResults.COR_E_PATHTOOLONG:
+                    return new System.IO.PathTooLongException();
+                case HResults.COR_E_PLATFORMNOTSUPPORTED:
+                    return new System.PlatformNotSupportedException();
+                case HResults.COR_E_RANK:
+                    return new System.RankException();
+                case HResults.COR_E_REFLECTIONTYPELOAD:
+                    return new System.MissingMethodException();
+                case HResults.COR_E_RUNTIMEWRAPPED:
+                    return new System.MissingMethodException();
+                case HResults.COR_E_SECURITY:
+                    return new System.Security.SecurityException();
+                case HResults.COR_E_SERIALIZATION:
+                    return new System.Runtime.Serialization.SerializationException();
+                case HResults.COR_E_STACKOVERFLOW:
+                    return new System.StackOverflowException();
+                case HResults.COR_E_SYNCHRONIZATIONLOCK:
+                    return new System.Threading.SynchronizationLockException();
+                case HResults.COR_E_SYSTEM:
+                    return new System.SystemException();
+                case HResults.COR_E_TARGET:
+                    return new System.Reflection.TargetException();
+                case HResults.COR_E_TARGETINVOCATION:
+                    return new System.MissingMethodException();
+                case HResults.COR_E_TARGETPARAMCOUNT:
+                    return new System.Reflection.TargetParameterCountException();
+                case HResults.COR_E_THREADABORTED:
+                    return new System.Threading.ThreadAbortException();
+                case HResults.COR_E_THREADINTERRUPTED:
+                    return new System.Threading.ThreadInterruptedException();
+                case HResults.COR_E_THREADSTART:
+                    return new System.Threading.ThreadStartException();
+                case HResults.COR_E_THREADSTATE:
+                    return new System.Threading.ThreadStateException();
+                case HResults.COR_E_TYPEACCESS:
+                    return new System.TypeAccessException();
+                case HResults.COR_E_TYPEINITIALIZATION:
+                    return new System.TypeInitializationException("");
+                case HResults.COR_E_TYPELOAD:
+                    return new System.TypeLoadException();
+                case HResults.COR_E_TYPEUNLOADED:
+                    return new System.TypeUnloadedException();
+                case HResults.COR_E_UNAUTHORIZEDACCESS:
+                    return new System.UnauthorizedAccessException();
+                //case HResults.COR_E_UNSUPPORTEDFORMAT:
+                case HResults.COR_E_VERIFICATION:
+                    return new System.Security.VerificationException();
+                //case HResults.E_INVALIDARG:
+                case HResults.E_NOTIMPL:
+                    return new System.NotImplementedException();
+                //case HResults.E_POINTER:
+                case HResults.RO_E_CLOSED:
+                    return new System.ObjectDisposedException("");
+                case HResults.COR_E_ABANDONEDMUTEX:
+                case HResults.COR_E_AMBIGUOUSIMPLEMENTATION:
+                case HResults.COR_E_CANNOTUNLOADAPPDOMAIN:
+                case HResults.COR_E_CONTEXTMARSHAL:
+                //case HResults.COR_E_HOSTPROTECTION:
+                case HResults.COR_E_INSUFFICIENTMEMORY:
+                case HResults.COR_E_INVALIDCOMOBJECT:
+                case HResults.COR_E_KEYNOTFOUND:
+                case HResults.COR_E_MISSINGSATELLITEASSEMBLY:
+                case HResults.COR_E_SAFEARRAYRANKMISMATCH:
+                case HResults.COR_E_SAFEARRAYTYPEMISMATCH:
+                //case HResults.COR_E_SAFEHANDLEMISSINGATTRIBUTE:
+                //case HResults.COR_E_SEMAPHOREFULL:
+                //case HResults.COR_E_THREADSTOP:
+                case HResults.COR_E_TIMEOUT:
+                case HResults.COR_E_WAITHANDLECANNOTBEOPENED:
+                case HResults.DISP_E_OVERFLOW:
+                case HResults.E_BOUNDS:
+                case HResults.E_CHANGED_STATE:
+                case HResults.E_FAIL:
+                case HResults.E_HANDLE:
+                case HResults.ERROR_MRM_MAP_NOT_FOUND:
+                case HResults.TYPE_E_TYPEMISMATCH:
+                case HResults.CO_E_NOTINITIALIZED:
+                case HResults.RPC_E_CHANGED_MODE:
+                    return new COMException("", errorCode);
+
+                case HResults.STG_E_PATHNOTFOUND:
+                case HResults.CTL_E_PATHNOTFOUND:
+                    {
+                        return new System.IO.DirectoryNotFoundException
+                        {
+                            HResult = errorCode
+                        };
+                    }
+                case HResults.FUSION_E_INVALID_PRIVATE_ASM_LOCATION:
+                case HResults.FUSION_E_SIGNATURE_CHECK_FAILED:
+                case HResults.FUSION_E_LOADFROM_BLOCKED:
+                case HResults.FUSION_E_CACHEFILE_FAILED:
+                case HResults.FUSION_E_ASM_MODULE_MISSING:
+                case HResults.FUSION_E_INVALID_NAME:
+                case HResults.FUSION_E_PRIVATE_ASM_DISALLOWED:
+                case HResults.FUSION_E_HOST_GAC_ASM_MISMATCH:
+                case HResults.COR_E_MODULE_HASH_CHECK_FAILED:
+                case HResults.FUSION_E_REF_DEF_MISMATCH:
+                case HResults.SECURITY_E_INCOMPATIBLE_SHARE:
+                case HResults.SECURITY_E_INCOMPATIBLE_EVIDENCE:
+                case HResults.SECURITY_E_UNVERIFIABLE:
+                case HResults.COR_E_FIXUPSINEXE:
+                case HResults.ERROR_TOO_MANY_OPEN_FILES:
+                case HResults.ERROR_SHARING_VIOLATION:
+                case HResults.ERROR_LOCK_VIOLATION:
+                case HResults.ERROR_OPEN_FAILED:
+                case HResults.ERROR_DISK_CORRUPT:
+                case HResults.ERROR_UNRECOGNIZED_VOLUME:
+                case HResults.ERROR_DLL_INIT_FAILED:
+                case HResults.FUSION_E_CODE_DOWNLOAD_DISABLED:
+                case HResults.CORSEC_E_MISSING_STRONGNAME:
+                case HResults.MSEE_E_ASSEMBLYLOADINPROGRESS:
+                case HResults.ERROR_FILE_INVALID:
+                    {
+                        return new System.IO.FileLoadException
+                        {
+                            HResult = errorCode
+                        };
+                    }
+                case HResults.CTL_E_FILENOTFOUND:
+                    {
+                        return new System.IO.FileNotFoundException
+                        {
+                            HResult = errorCode
+                        };
+                    }
+                default:
+                    return new COMException("", errorCode);
+            }
+        }
+#endif
+
         /// <summary>
         /// Throws a CLR exception based on the HRESULT.
         /// </summary>
index 7e46c37..68bb8fa 100644 (file)
@@ -38,237 +38,6 @@ namespace System.Runtime.InteropServices
         [MethodImplAttribute(MethodImplOptions.InternalCall)]
         internal static extern void SetLastWin32Error(int error);
 
-        private static Exception? GetExceptionForHRInternal(int errorCode, IntPtr errorInfo)
-        {
-            switch (errorCode)
-            {
-                case HResults.S_OK:
-                case HResults.S_FALSE:
-                    return null;
-                case HResults.COR_E_AMBIGUOUSMATCH:
-                    return new System.Reflection.AmbiguousMatchException();
-                case HResults.COR_E_APPLICATION:
-                    return new System.ApplicationException();
-                case HResults.COR_E_ARGUMENT:
-                    return new System.ArgumentException();
-                case HResults.COR_E_ARGUMENTOUTOFRANGE:
-                    return new System.ArgumentOutOfRangeException();
-                case HResults.COR_E_ARITHMETIC:
-                    return new System.ArithmeticException();
-                case HResults.COR_E_ARRAYTYPEMISMATCH:
-                    return new System.ArrayTypeMismatchException();
-                case HResults.COR_E_BADEXEFORMAT:
-                    return new System.BadImageFormatException();
-                case HResults.COR_E_BADIMAGEFORMAT:
-                    return new System.BadImageFormatException();
-                //case HResults.COR_E_CODECONTRACTFAILED:
-                //return new System.Diagnostics.Contracts.ContractException ();
-                //case HResults.COR_E_COMEMULATE:
-                case HResults.COR_E_CUSTOMATTRIBUTEFORMAT:
-                    return new System.Reflection.CustomAttributeFormatException();
-                case HResults.COR_E_DATAMISALIGNED:
-                    return new System.DataMisalignedException();
-                case HResults.COR_E_DIRECTORYNOTFOUND:
-                    return new System.IO.DirectoryNotFoundException();
-                case HResults.COR_E_DIVIDEBYZERO:
-                    return new System.DivideByZeroException();
-                case HResults.COR_E_DLLNOTFOUND:
-                    return new System.DllNotFoundException();
-                case HResults.COR_E_DUPLICATEWAITOBJECT:
-                    return new System.DuplicateWaitObjectException();
-                case HResults.COR_E_ENDOFSTREAM:
-                    return new System.IO.EndOfStreamException();
-                case HResults.COR_E_ENTRYPOINTNOTFOUND:
-                    return new System.EntryPointNotFoundException();
-                case HResults.COR_E_EXCEPTION:
-                    return new System.Exception();
-                case HResults.COR_E_EXECUTIONENGINE:
-                    return new System.ExecutionEngineException();
-                case HResults.COR_E_FIELDACCESS:
-                    return new System.FieldAccessException();
-                case HResults.COR_E_FILELOAD:
-                    return new System.IO.FileLoadException();
-                case HResults.COR_E_FILENOTFOUND:
-                    return new System.IO.FileNotFoundException();
-                case HResults.COR_E_FORMAT:
-                    return new System.FormatException();
-                case HResults.COR_E_INDEXOUTOFRANGE:
-                    return new System.IndexOutOfRangeException();
-                case HResults.COR_E_INSUFFICIENTEXECUTIONSTACK:
-                    return new System.InsufficientExecutionStackException();
-                case HResults.COR_E_INVALIDCAST:
-                    return new System.InvalidCastException();
-                case HResults.COR_E_INVALIDFILTERCRITERIA:
-                    return new System.Reflection.InvalidFilterCriteriaException();
-                case HResults.COR_E_INVALIDOLEVARIANTTYPE:
-                    return new System.Runtime.InteropServices.InvalidOleVariantTypeException();
-                case HResults.COR_E_INVALIDOPERATION:
-                    return new System.InvalidOperationException();
-                case HResults.COR_E_INVALIDPROGRAM:
-                    return new System.InvalidProgramException();
-                case HResults.COR_E_IO:
-                    return new System.IO.IOException();
-                case HResults.COR_E_MARSHALDIRECTIVE:
-                    return new System.Runtime.InteropServices.MarshalDirectiveException();
-                case HResults.COR_E_MEMBERACCESS:
-                    return new System.MemberAccessException();
-                case HResults.COR_E_METHODACCESS:
-                    return new System.MethodAccessException();
-                case HResults.COR_E_MISSINGFIELD:
-                    return new System.MissingFieldException();
-                case HResults.COR_E_MISSINGMANIFESTRESOURCE:
-                    return new System.Resources.MissingManifestResourceException();
-                case HResults.COR_E_MISSINGMEMBER:
-                    return new System.MissingMemberException();
-                case HResults.COR_E_MISSINGMETHOD:
-                    return new System.MissingMethodException();
-                case HResults.COR_E_MULTICASTNOTSUPPORTED:
-                    return new System.MulticastNotSupportedException();
-                case HResults.COR_E_NOTFINITENUMBER:
-                    return new System.NotFiniteNumberException();
-                case HResults.COR_E_NOTSUPPORTED:
-                    return new System.NotSupportedException();
-                case HResults.E_POINTER:
-                    return new System.NullReferenceException();
-                case HResults.COR_E_OBJECTDISPOSED:
-                    return new System.ObjectDisposedException("");
-                case HResults.COR_E_OPERATIONCANCELED:
-                    return new System.OperationCanceledException();
-                case HResults.COR_E_OUTOFMEMORY:
-                    return new System.OutOfMemoryException();
-                case HResults.COR_E_OVERFLOW:
-                    return new System.OverflowException();
-                case HResults.COR_E_PATHTOOLONG:
-                    return new System.IO.PathTooLongException();
-                case HResults.COR_E_PLATFORMNOTSUPPORTED:
-                    return new System.PlatformNotSupportedException();
-                case HResults.COR_E_RANK:
-                    return new System.RankException();
-                case HResults.COR_E_REFLECTIONTYPELOAD:
-                    return new System.MissingMethodException();
-                case HResults.COR_E_RUNTIMEWRAPPED:
-                    return new System.MissingMethodException();
-                case HResults.COR_E_SECURITY:
-                    return new System.Security.SecurityException();
-                case HResults.COR_E_SERIALIZATION:
-                    return new System.Runtime.Serialization.SerializationException();
-                case HResults.COR_E_STACKOVERFLOW:
-                    return new System.StackOverflowException();
-                case HResults.COR_E_SYNCHRONIZATIONLOCK:
-                    return new System.Threading.SynchronizationLockException();
-                case HResults.COR_E_SYSTEM:
-                    return new System.SystemException();
-                case HResults.COR_E_TARGET:
-                    return new System.Reflection.TargetException();
-                case HResults.COR_E_TARGETINVOCATION:
-                    return new System.MissingMethodException();
-                case HResults.COR_E_TARGETPARAMCOUNT:
-                    return new System.Reflection.TargetParameterCountException();
-                case HResults.COR_E_THREADABORTED:
-                    return new System.Threading.ThreadAbortException();
-                case HResults.COR_E_THREADINTERRUPTED:
-                    return new System.Threading.ThreadInterruptedException();
-                case HResults.COR_E_THREADSTART:
-                    return new System.Threading.ThreadStartException();
-                case HResults.COR_E_THREADSTATE:
-                    return new System.Threading.ThreadStateException();
-                case HResults.COR_E_TYPEACCESS:
-                    return new System.TypeAccessException();
-                case HResults.COR_E_TYPEINITIALIZATION:
-                    return new System.TypeInitializationException("");
-                case HResults.COR_E_TYPELOAD:
-                    return new System.TypeLoadException();
-                case HResults.COR_E_TYPEUNLOADED:
-                    return new System.TypeUnloadedException();
-                case HResults.COR_E_UNAUTHORIZEDACCESS:
-                    return new System.UnauthorizedAccessException();
-                //case HResults.COR_E_UNSUPPORTEDFORMAT:
-                case HResults.COR_E_VERIFICATION:
-                    return new System.Security.VerificationException();
-                //case HResults.E_INVALIDARG:
-                case HResults.E_NOTIMPL:
-                    return new System.NotImplementedException();
-                //case HResults.E_POINTER:
-                case HResults.RO_E_CLOSED:
-                    return new System.ObjectDisposedException("");
-                case HResults.COR_E_ABANDONEDMUTEX:
-                case HResults.COR_E_AMBIGUOUSIMPLEMENTATION:
-                case HResults.COR_E_CANNOTUNLOADAPPDOMAIN:
-                case HResults.COR_E_CONTEXTMARSHAL:
-                //case HResults.COR_E_HOSTPROTECTION:
-                case HResults.COR_E_INSUFFICIENTMEMORY:
-                case HResults.COR_E_INVALIDCOMOBJECT:
-                case HResults.COR_E_KEYNOTFOUND:
-                case HResults.COR_E_MISSINGSATELLITEASSEMBLY:
-                case HResults.COR_E_SAFEARRAYRANKMISMATCH:
-                case HResults.COR_E_SAFEARRAYTYPEMISMATCH:
-                //case HResults.COR_E_SAFEHANDLEMISSINGATTRIBUTE:
-                //case HResults.COR_E_SEMAPHOREFULL:
-                //case HResults.COR_E_THREADSTOP:
-                case HResults.COR_E_TIMEOUT:
-                case HResults.COR_E_WAITHANDLECANNOTBEOPENED:
-                case HResults.DISP_E_OVERFLOW:
-                case HResults.E_BOUNDS:
-                case HResults.E_CHANGED_STATE:
-                case HResults.E_FAIL:
-                case HResults.E_HANDLE:
-                case HResults.ERROR_MRM_MAP_NOT_FOUND:
-                case HResults.TYPE_E_TYPEMISMATCH:
-                case HResults.CO_E_NOTINITIALIZED:
-                case HResults.RPC_E_CHANGED_MODE:
-                    return new COMException("", errorCode);
-
-                case HResults.STG_E_PATHNOTFOUND:
-                case HResults.CTL_E_PATHNOTFOUND:
-                    {
-                        return new System.IO.DirectoryNotFoundException
-                        {
-                            HResult = errorCode
-                        };
-                    }
-                case HResults.FUSION_E_INVALID_PRIVATE_ASM_LOCATION:
-                case HResults.FUSION_E_SIGNATURE_CHECK_FAILED:
-                case HResults.FUSION_E_LOADFROM_BLOCKED:
-                case HResults.FUSION_E_CACHEFILE_FAILED:
-                case HResults.FUSION_E_ASM_MODULE_MISSING:
-                case HResults.FUSION_E_INVALID_NAME:
-                case HResults.FUSION_E_PRIVATE_ASM_DISALLOWED:
-                case HResults.FUSION_E_HOST_GAC_ASM_MISMATCH:
-                case HResults.COR_E_MODULE_HASH_CHECK_FAILED:
-                case HResults.FUSION_E_REF_DEF_MISMATCH:
-                case HResults.SECURITY_E_INCOMPATIBLE_SHARE:
-                case HResults.SECURITY_E_INCOMPATIBLE_EVIDENCE:
-                case HResults.SECURITY_E_UNVERIFIABLE:
-                case HResults.COR_E_FIXUPSINEXE:
-                case HResults.ERROR_TOO_MANY_OPEN_FILES:
-                case HResults.ERROR_SHARING_VIOLATION:
-                case HResults.ERROR_LOCK_VIOLATION:
-                case HResults.ERROR_OPEN_FAILED:
-                case HResults.ERROR_DISK_CORRUPT:
-                case HResults.ERROR_UNRECOGNIZED_VOLUME:
-                case HResults.ERROR_DLL_INIT_FAILED:
-                case HResults.FUSION_E_CODE_DOWNLOAD_DISABLED:
-                case HResults.CORSEC_E_MISSING_STRONGNAME:
-                case HResults.MSEE_E_ASSEMBLYLOADINPROGRESS:
-                case HResults.ERROR_FILE_INVALID:
-                    {
-                        return new System.IO.FileLoadException
-                        {
-                            HResult = errorCode
-                        };
-                    }
-                case HResults.CTL_E_FILENOTFOUND:
-                    {
-                        return new System.IO.FileNotFoundException
-                        {
-                            HResult = errorCode
-                        };
-                    }
-                default:
-                    return new COMException("", errorCode);
-            }
-        }
-
         private static void PrelinkCore(MethodInfo m)
         {
             if (!(m is RuntimeMethodInfo))
@@ -455,42 +224,3 @@ namespace System.Runtime.InteropServices
         #endregion
     }
 }
-
-namespace System
-{
-    internal static partial class HResults
-    {
-        // DirectoryNotFoundException
-        public const int STG_E_PATHNOTFOUND = unchecked((int)0x80030003);
-        public const int CTL_E_PATHNOTFOUND = unchecked((int)0x800A004C);
-
-        // FileNotFoundException
-        public const int CTL_E_FILENOTFOUND = unchecked((int)0x800A0035);
-
-        public const int FUSION_E_INVALID_PRIVATE_ASM_LOCATION = unchecked((int)0x80131041);
-        public const int FUSION_E_SIGNATURE_CHECK_FAILED = unchecked((int)0x80131045);
-        public const int FUSION_E_LOADFROM_BLOCKED = unchecked((int)0x80131051);
-        public const int FUSION_E_CACHEFILE_FAILED = unchecked((int)0x80131052);
-        public const int FUSION_E_ASM_MODULE_MISSING = unchecked((int)0x80131042);
-        public const int FUSION_E_INVALID_NAME = unchecked((int)0x80131047);
-        public const int FUSION_E_PRIVATE_ASM_DISALLOWED = unchecked((int)0x80131044);
-        public const int FUSION_E_HOST_GAC_ASM_MISMATCH = unchecked((int)0x80131050);
-        public const int COR_E_MODULE_HASH_CHECK_FAILED = unchecked((int)0x80131039);
-        public const int FUSION_E_REF_DEF_MISMATCH = unchecked((int)0x80131040);
-        public const int SECURITY_E_INCOMPATIBLE_SHARE = unchecked((int)0x80131401);
-        public const int SECURITY_E_INCOMPATIBLE_EVIDENCE = unchecked((int)0x80131403);
-        public const int SECURITY_E_UNVERIFIABLE = unchecked((int)0x80131402);
-        public const int COR_E_FIXUPSINEXE = unchecked((int)0x80131019);
-        public const int ERROR_TOO_MANY_OPEN_FILES = unchecked((int)0x80070004);
-        public const int ERROR_SHARING_VIOLATION = unchecked((int)0x80070020);
-        public const int ERROR_LOCK_VIOLATION = unchecked((int)0x80070021);
-        public const int ERROR_OPEN_FAILED = unchecked((int)0x8007006E);
-        public const int ERROR_DISK_CORRUPT = unchecked((int)0x80070571);
-        public const int ERROR_UNRECOGNIZED_VOLUME = unchecked((int)0x800703ED);
-        public const int ERROR_DLL_INIT_FAILED = unchecked((int)0x8007045A);
-        public const int FUSION_E_CODE_DOWNLOAD_DISABLED = unchecked((int)0x80131048);
-        public const int CORSEC_E_MISSING_STRONGNAME = unchecked((int)0x8013141b);
-        public const int MSEE_E_ASSEMBLYLOADINPROGRESS = unchecked((int)0x80131016);
-        public const int ERROR_FILE_INVALID = unchecked((int)0x800703EE);
-    }
-}