Skip to content

Commit 7609977

Browse files
committed
Fix NUnit3 causes AssemblyBuilder.Save access violation.
1 parent f078320 commit 7609977

9 files changed

Lines changed: 19 additions & 0 deletions

src/MsgPack/Serialization/EmittingSerializers/SerializationMethodGeneratorManager.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ private SerializationMethodGeneratorManager( bool isDebuggable, bool isCollectab
175175
#else
176176
: AssemblyBuilderAccess.Run
177177
#endif // !NETFX_35
178+
#if DEBUG
179+
,
180+
SerializerDebugging.DumpDirectory
181+
#endif // DEBUG
178182
);
179183
#else
180184
AssemblyBuilder.DefineDynamicAssembly(

src/MsgPack/Serialization/SerializerDebugging.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,14 @@ public static void ResetDependentAssemblies()
268268
#endif // !NETSTANDARD1_1 && !NETSTANDARD1_3
269269
}
270270

271+
private static string _dumpDirectory;
272+
273+
public static string DumpDirectory
274+
{
275+
get { return Interlocked.CompareExchange( ref _dumpDirectory, null, null ); }
276+
set { Interlocked.Exchange( ref _dumpDirectory, value ); }
277+
}
278+
271279
#if !NETSTANDARD1_1 && !NETSTANDARD1_3
272280
private static int _wasDeleted;
273281
private const string HistoryFile = "MsgPack.Serialization.SerializationGenerationDebugging.CodeDOM.History.txt";

test/MsgPack.UnitTest.CodeDom/Serialization/ArrayCodeDomBasedAutoMessagePackSerializerTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ private bool CanDump
124124
public void SetUp()
125125
{
126126
SerializerDebugging.DeletePastTemporaries();
127+
SerializerDebugging.DumpDirectory = TestContext.CurrentContext.WorkDirectory;
127128
//SerializerDebugging.TraceEnabled = true;
128129
//SerializerDebugging.DumpEnabled = true;
129130
if ( SerializerDebugging.TraceEnabled )

test/MsgPack.UnitTest.CodeDom/Serialization/MapCodeDomBasedAutoMessagePackSerializerTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ private bool CanDump
126126
public void SetUp()
127127
{
128128
SerializerDebugging.DeletePastTemporaries();
129+
SerializerDebugging.DumpDirectory = TestContext.CurrentContext.WorkDirectory;
129130
//SerializerDebugging.TraceEnabled = true;
130131
//SerializerDebugging.DumpEnabled = true;
131132
if ( SerializerDebugging.TraceEnabled )

test/MsgPack.UnitTest/Serialization/ArrayFieldBasedAutoMessagePackSerializerTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ private bool CanDump
124124
public void SetUp()
125125
{
126126
SerializerDebugging.DeletePastTemporaries();
127+
SerializerDebugging.DumpDirectory = TestContext.CurrentContext.WorkDirectory;
127128
//SerializerDebugging.TraceEnabled = true;
128129
//SerializerDebugging.DumpEnabled = true;
129130
if ( SerializerDebugging.TraceEnabled )

test/MsgPack.UnitTest/Serialization/ArrayReflectionBasedAutoMessagePackSerializerTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ private bool CanDump
124124
public void SetUp()
125125
{
126126
SerializerDebugging.DeletePastTemporaries();
127+
SerializerDebugging.DumpDirectory = TestContext.CurrentContext.WorkDirectory;
127128
//SerializerDebugging.TraceEnabled = true;
128129
//SerializerDebugging.DumpEnabled = true;
129130
if ( SerializerDebugging.TraceEnabled )

test/MsgPack.UnitTest/Serialization/AutoMessagePackSerializerTest.ttinclude

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ namespace MsgPack.Serialization
213213
}
214214
#>
215215
SerializerDebugging.DeletePastTemporaries();
216+
SerializerDebugging.DumpDirectory = TestContext.CurrentContext.WorkDirectory;
216217
//SerializerDebugging.TraceEnabled = true;
217218
//SerializerDebugging.DumpEnabled = true;
218219
if ( SerializerDebugging.TraceEnabled )

test/MsgPack.UnitTest/Serialization/MapFieldBasedAutoMessagePackSerializerTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ private bool CanDump
126126
public void SetUp()
127127
{
128128
SerializerDebugging.DeletePastTemporaries();
129+
SerializerDebugging.DumpDirectory = TestContext.CurrentContext.WorkDirectory;
129130
//SerializerDebugging.TraceEnabled = true;
130131
//SerializerDebugging.DumpEnabled = true;
131132
if ( SerializerDebugging.TraceEnabled )

test/MsgPack.UnitTest/Serialization/MapReflectionBasedAutoMessagePackSerializerTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ private bool CanDump
126126
public void SetUp()
127127
{
128128
SerializerDebugging.DeletePastTemporaries();
129+
SerializerDebugging.DumpDirectory = TestContext.CurrentContext.WorkDirectory;
129130
//SerializerDebugging.TraceEnabled = true;
130131
//SerializerDebugging.DumpEnabled = true;
131132
if ( SerializerDebugging.TraceEnabled )

0 commit comments

Comments
 (0)