Comments (3)
when there is an "async" before the main function.
How do you find Main
in the code? What if there's a trial version of some Main
that's commented out (or conditionally compiled out) and using a quick & dirty trick like regular expressions to sniff out the async
before Main
picks on the wrong thing?
The first thing is "can do", then "do it pretty"!
True but often when you have it working one way then there's a lesser urge to make it pretty. :)
from linqpadless.
Seems the code to do so is trivial with Roslyn:
var tests =
from source in new[]
{
@"
/*
async Task Main() {
await Task.Delay(TimeSpan.FromSeconds(1));
Console.WriteLine(DateTime.Now);
}
*/
async void Foo() {}
void Main() {}
",
@"
async void Foo() {}
async void Main() {
await Task.Delay(TimeSpan.FromSeconds(1));
Console.WriteLine(DateTime.Now);
}
"
}
select
CSharpSyntaxTree.ParseText(source).GetRoot()
.DescendantNodes().OfType<MethodDeclarationSyntax>()
.Any(md => "Main" == (string) md.Identifier.Text
&& md.Modifiers.Any(m => m.IsKind(SyntaxKind.AsyncKeyword)));
foreach (var test in tests)
Console.WriteLine(test);
from linqpadless.
IMO, it's ok that simply add an "await" when there is an "async" before the main function.
The first thing is "can do", then "do it pretty"!
from linqpadless.
Related Issues (20)
- Use C# compiler from Microsoft.Net.Compilers
- Use C# Interactive from Microsoft.Net.Compilers
- Interactive session errors on references to system assemblies in C# script HOT 2
- LINQPad program queries with args don't compile HOT 5
- Calls requiring STA threads don't work HOT 5
- No template for running query HOT 4
- Support namespace removal added in LINQPad 6
- Support namespace declarations (starting with LINQPad 6) in queries HOT 6
- Types without extension methods should remain nested UserQuery
- Support Main in a class, outside or under a namespace
- Support #load directive
- No template for running query HOT 2
- Support no-nesting via NONEST conditional
- System doesn't use LINQPad nuget manager specifing version HOT 2
- How LinqPadless V1.1 support netstandard 2.0? HOT 1
- Nuget error attempting to query latest version of SSH.NET HOT 2
- LinqPadless 1.1 - SSL certificate error HOT 10
- SSL certificate error when downloading compiler with version 1.2 HOT 2
- Make available as dotnet global util HOT 1
- VS Projects not loading HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from linqpadless.