Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using - declaration does not work with DisposableVariableNotDisposedAnalyzer #1043

Open
pgrm opened this issue Jul 22, 2020 · 0 comments
Open

Comments

@pgrm
Copy link

pgrm commented Jul 22, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant