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

ArgumentNullException in VS 15.9.4 #103

Open
Khaos66 opened this issue Jan 8, 2019 · 4 comments
Open

ArgumentNullException in VS 15.9.4 #103

Khaos66 opened this issue Jan 8, 2019 · 4 comments

Comments

@Khaos66
Copy link

Khaos66 commented Jan 8, 2019

Prerequisites

  • [ x] I have written a descriptive issue title
  • [ x] I have verified that I am running the latest version of DisposableFixer: 1.4.0
  • [ x] I have searched open and closed issues to ensure it has not already been reported

Description

I get this exception sometimes with the latest update of Visual Studio 2017.

Although I can't provide the code causing this issue, I hope this call stack will help:

System.ArgumentNullException : Value cannot be null.
Parameter name: syntax
   at Microsoft.CodeAnalysis.CSharp.CSharpSemanticModel.CheckSyntaxNode(CSharpSyntaxNode syntax)
   at Microsoft.CodeAnalysis.CSharp.CSharpSemanticModel.GetTypeInfo(ExpressionSyntax expression,CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.CSharp.CSharpExtensions.GetTypeInfo(SemanticModel semanticModel,ExpressionSyntax expression,CancellationToken cancellationToken)
   at async DisposableFixer.CodeFix.UndisposedMemberCodeFixProvider.CreateDisposeCallInParameterlessDisposeMethod(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.CodeActions.CodeAction.GetChangedSolutionAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.CodeActions.CodeAction.ComputeOperationsAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.CodeActions.CodeAction.GetPreviewOperationsAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedAction.GetPreviewResultAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedActionWithNestedFlavors.<>c__DisplayClass11_0.<GetPreviewAsync>b__0(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.Extensions.IExtensionManagerExtensions.PerformFunctionAsync[T](<Unknown Parameters>)
@BADF00D
Copy link
Owner

BADF00D commented Jan 8, 2019

It looks like you want to dispose a undisposed field or property. Is there anything special with the type of the member? Is it a field or property? Is the type not yet known (missing reference)?
Maybe you can reproduce the issue with dummy code, that can be published here.

@BADF00D BADF00D added the bug label Jan 8, 2019
@BADF00D BADF00D added this to the Release 2.0.0 milestone Jan 8, 2019
@Khaos66
Copy link
Author

Khaos66 commented Jan 8, 2019

I'm trying to reproduce the issue within a sample project.
I got it once, but after doing the steps again, I didn't.
I'll keep on trying.

These are the building blocks:

  1. Create a new Winforms project
  2. (Add new Form1, if not there already)
  3. Add field: private readonly Timer _timer;
  4. Add Initialization to constructor: this._timer = new Timer() { Interval = 100 }
  5. Save Form1.cs
  6. Switch to the Dispose(bool) method with the methods combobox at the top right
  7. Add: _timer?.Dispose();
  8. Save and close Form1.Designer.cs
  9. Put Cursor on 'new Timer()' and press CTRL+.
    !BOOM! (sometimes)

@BADF00D BADF00D modified the milestones: Release 2.0.0, Release 2.1.0 Aug 16, 2019
@BADF00D BADF00D removed this from the Release 2.1.0 milestone Sep 20, 2019
@BADF00D
Copy link
Owner

BADF00D commented Oct 26, 2019

Did you encounter this error once more? Since 8th January I made a lots of bug fixes, maybe this is already fixed.
Up to now I was not able to verify this issue. It is kind of strange the the codefix crashes, after you already disposed the field, since the codefix should not have been popped up at all.

@Khaos66
Copy link
Author

Khaos66 commented Nov 10, 2019

I did not =) Maybe you're right

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

No branches or pull requests

2 participants