Skip to content
This repository was archived by the owner on Jun 27, 2019. It is now read-only.

Commit 73a44f6

Browse files
committed
Swallow EntryPointNotFoundException thrown due to unsupported SetErrorMode on Mono
1 parent a2d0336 commit 73a44f6

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

src/GitTools.Core/GitTools.Core.Shared/Helpers/ProcessHelper.cs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,32 @@ public enum ErrorModes
132132

133133
public struct ChangeErrorMode : IDisposable
134134
{
135-
int oldMode;
135+
readonly int oldMode;
136136

137137
public ChangeErrorMode(ErrorModes mode)
138138
{
139-
oldMode = SetErrorMode((int)mode);
139+
try
140+
{
141+
oldMode = SetErrorMode((int)mode);
142+
}
143+
catch (EntryPointNotFoundException)
144+
{
145+
oldMode = (int)mode;
146+
}
140147
}
141148

142-
void IDisposable.Dispose() { SetErrorMode(oldMode); }
149+
150+
void IDisposable.Dispose()
151+
{
152+
try
153+
{
154+
SetErrorMode(oldMode);
155+
}
156+
catch (EntryPointNotFoundException)
157+
{
158+
// NOTE: Mono doesn't support DllImport("kernel32.dll") and its SetErrorMode method, obviously. @asbjornu
159+
}
160+
}
143161

144162
[DllImport("kernel32.dll")]
145163
static extern int SetErrorMode(int newMode);

0 commit comments

Comments
 (0)