-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
113 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/ExpressionEvaluator/Core/Source/ExpressionCompiler/MetadataUtilities_Exceptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Diagnostics; | ||
|
||
namespace Microsoft.CodeAnalysis.ExpressionEvaluator | ||
{ | ||
internal static partial class MetadataUtilities | ||
{ | ||
internal const uint COR_E_BADIMAGEFORMAT = 0x8007000b; | ||
internal const uint CORDBG_E_MISSING_METADATA = 0x80131c35; | ||
|
||
internal static bool IsBadOrMissingMetadataException(Exception e, string moduleName) | ||
{ | ||
Debug.Assert(moduleName != null); | ||
var objectDisposed = e as ObjectDisposedException; | ||
if (objectDisposed != null) | ||
{ | ||
Debug.WriteLine($"Module '{moduleName}' has been disposed."); | ||
return true; | ||
} | ||
switch (GetHResult(e)) | ||
{ | ||
case COR_E_BADIMAGEFORMAT: | ||
Debug.WriteLine($"Module '{moduleName}' contains corrupt metadata."); | ||
return true; | ||
case CORDBG_E_MISSING_METADATA: | ||
Debug.WriteLine($"Module '{moduleName}' is missing metadata."); | ||
return true; | ||
default: | ||
return false; | ||
} | ||
} | ||
|
||
private static bool IsBadMetadataException(Exception e) | ||
{ | ||
return GetHResult(e) == COR_E_BADIMAGEFORMAT; | ||
} | ||
|
||
private static uint GetHResult(Exception e) | ||
{ | ||
return unchecked((uint)e.HResult); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters