The following code:
public async Task DoStuffAsync()
{
// ... some code ...
using var buffer = new MemoryStream();
await File.WriteToStreamAsync(buffer);
UseBuffer(buffer.ToArray());
}
Throws the following exception when building:
Analyzer 'CodeCracker.CSharp.Usage.DisposableVariableNotDisposedAnalyzer' threw an exception of type 'System.ArgumentNullException' with message 'Value cannot be null. (Parameter 'syntax')'.
Changing it to the old syntax works fine:
public async Task DoStuffAsync()
{
// ... some code ...
using (var buffer = new MemoryStream())
{
await File.WriteToStreamAsync(buffer);
UseBuffer(buffer.ToArray());
}
}
However, this doesn't break always. I do have other cases in the same project, where the new syntax works and again some, where it doesn't work. So it's hard to create a generic replication project, but for those methods where it doesn't work, it fails every single time, I try to compile it with the new syntax and works every single time, I try to compile it with the old syntax.
The following code:
Throws the following exception when building:
Changing it to the old syntax works fine:
However, this doesn't break always. I do have other cases in the same project, where the new syntax works and again some, where it doesn't work. So it's hard to create a generic replication project, but for those methods where it doesn't work, it fails every single time, I try to compile it with the new syntax and works every single time, I try to compile it with the old syntax.