async Main doesn't work in Run mode
See original GitHub issueI’ve tried to compile the following code:
using System;
using System.Threading.Tasks;
public static class Program {
public static async Task Main() {
Console.WriteLine("🌄");
}
}
The compilation failed with an error:
Unbreakable.AssemblyGuardException: Type System.Runtime.CompilerServices.AsyncTaskMethodBuilder is not allowed.
at Unbreakable.Internal.AssemblyValidator.EnsureAllowed(TypeReference type, String memberName)
at Unbreakable.Internal.AssemblyValidator.ValidateMemberReference(MemberReference reference)
at Unbreakable.Internal.AssemblyValidator.ValidateInstructionAndGetPolicy(Instruction instruction, MethodDefinition method)
at Unbreakable.AssemblyGuard.ValidateAndRewriteMethod(MethodDefinition method, RuntimeGuardReferences guard, AssemblyValidator validator, AssemblyGuardSettings settings)
at Unbreakable.AssemblyGuard.ValidateAndRewriteType(TypeDefinition type, RuntimeGuardReferences guard, AssemblyValidator validator, AssemblyGuardSettings settings)
at Unbreakable.AssemblyGuard.ValidateAndRewriteType(TypeDefinition type, RuntimeGuardReferences guard, AssemblyValidator validator, AssemblyGuardSettings settings)
at Unbreakable.AssemblyGuard.Rewrite(AssemblyDefinition assembly, AssemblyGuardSettings settings)
at SharpLab.Server.Execution.Executor.Execute(Stream assemblyStream, Stream symbolStream, IWorkSession session)
at SharpLab.Server.MirrorSharp.SlowUpdate.<ProcessAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MirrorSharp.Internal.Handlers.SlowUpdateHandler.<ExecuteAsync>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at MirrorSharp.Internal.Connection.<ReceiveAndProcessInternalAsync>d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MirrorSharp.Internal.Connection.<ReceiveAndProcessAsync>d__12.MoveNext()
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:6 (4 by maintainers)
Top Results From Across the Web
javascript - How can I use async/await at the top level?
I can't seem to wrap my head around why this does not work. Because main returns a promise; all async functions do. At...
Read more >C# Async code doesn't work on Visual Studio Release ...
This code pings each ip address 4 times asynchronously, and the entire function is made to run on 5k IP addresses using task.Add...
Read more >Because this call is not awaited, execution of the current ...
The call to the async method starts an asynchronous task. However, because no Await operator is applied, the program continues without waiting ...
Read more >Async methods do not stop executing when exiting play ...
A program is running as long as it has at least one active thread. So outside the editor it should behave the same....
Read more >C# Async code doesn't work on Visual Studio Release ...
Question C# Async code doesn't work on Visual Studio Release mode, works perfectly well on debug mode (with or without attaching the debugger)....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @ForNeVeR, this is now resolved, as new Run mode does not have restrictions on async code.
Yep, current Run mode does not use Unbreakable.