Created
March 20, 2021 11:25
-
-
Save kolosovpetro/0e199ec8edcaf618b020b5119792c495 to your computer and use it in GitHub Desktop.
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading.Tasks; | |
public class C { | |
public void Main() | |
{ | |
var str = new DisposableStruct(); | |
using(str) { | |
Console.WriteLine(str.isDisposed); | |
} | |
} | |
} | |
struct DisposableStruct : IDisposable { | |
public bool isDisposed; | |
public void Dispose() { isDisposed = true; } | |
} |
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
using System; | |
using System.Diagnostics; | |
using System.Reflection; | |
using System.Runtime.CompilerServices; | |
using System.Security; | |
using System.Security.Permissions; | |
[assembly: CompilationRelaxations(8)] | |
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] | |
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] | |
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] | |
[assembly: AssemblyVersion("0.0.0.0")] | |
[module: UnverifiableCode] | |
public class C | |
{ | |
public void Main() | |
{ | |
DisposableStruct disposableStruct = default(DisposableStruct); | |
DisposableStruct disposableStruct2 = disposableStruct; | |
try | |
{ | |
Console.WriteLine(disposableStruct.isDisposed); | |
} | |
finally | |
{ | |
((IDisposable)disposableStruct2).Dispose(); | |
} | |
} | |
} | |
internal struct DisposableStruct : IDisposable | |
{ | |
public bool isDisposed; | |
public void Dispose() | |
{ | |
isDisposed = true; | |
} | |
} |
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
{ | |
"version": 1, | |
"target": "C#", | |
"mode": "Debug" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment