-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Propagate C++ exceptions back to C#.
- Loading branch information
Showing
7 changed files
with
92 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using Microsoft.CodeAnalysis; | ||
|
||
namespace Reinterop | ||
{ | ||
/// <summary> | ||
/// Inserts the "ReinteropException" class into an assembly as it is compiled. | ||
/// This is intended to be used from a RegisterPostInitializationOutput | ||
/// callback on an IIncrementalGenerator. | ||
/// </summary> | ||
internal class CSharpReinteropException | ||
{ | ||
public static void Generate(GeneratorExecutionContext context) | ||
{ | ||
context.AddSource("ReinteropException", Source); | ||
} | ||
|
||
public const string Source = | ||
""" | ||
namespace Reinterop | ||
{ | ||
[Reinterop] | ||
internal class ReinteropException : System.Exception | ||
{ | ||
public ReinteropException(string message) : base(message) {} | ||
internal static void ExposeToCPP() | ||
{ | ||
ReinteropException e = new ReinteropException("message"); | ||
} | ||
} | ||
} | ||
"""; | ||
} | ||
} |
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
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