Closed richardnagle closed 2 years ago
I believe this is likely an issue with the script pre-processing.
To unblock you for this specific use case as it's an stream that implements async disposable you can adjust your code to
Task("C#8-Using-Statement")
.Does(async () =>
{
await using var file = System.IO.File.Create(@".\temp.txt");
});
Just FYI Cake has a built in IO abstraction layer that handles OS/Environment specific things for you. i.e. path normalization. It will also mean you can take advantage of any module that enhances the filesystem i.e. long path, there's a fake file system in Cake.Testing etc.
Utilizing Cake FileSystem could i.e. look something like
Task("C#8-Using-Statement")
.Does(async context =>
{
await using var file = context.FileSystem.GetFile("./temp.txt").OpenWrite();
});
I stumbled across this just now while trying the latest shiny C# with Cake version 2.0.0-rc0002
: 😞
(Example from using statement (C# Reference))
I stumbled across this just now while trying the latest shiny C# with Cake version
2.0.0-rc0002
: 😞(Example from using statement (C# Reference))
Fix would be somewhere around here https://github.com/cake-build/cake/blob/0de2adc821dd65bc7c003d16c03878971c2698e6/src/Cake.Core/Scripting/Processors/UsingStatementProcessor.cs#L35
Some conditional to return false.
Maybe line contains (
and )
or something similar.
:tada: This issue has been resolved in version v2.0.0 :tada:
The release is available on:
Your GitReleaseManager bot :package::rocket:
What You Are Seeing?
When using the new C#8
using var...
statement, the cake script produces compile errors.What is Expected?
This script should compile successfully.
What version of Cake are you using?
0.35.0
Are you running on a 32 or 64 bit system?
64bit
What environment are you running on? Windows? Linux? Mac?
Windows 10
Are you running on a CI Server? If so, which one?
No
How Did You Get This To Happen? (Steps to Reproduce)
Output Log