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

UndisposedFieldCodeFixProvider crashes #139

Open
3 tasks done
BADF00D opened this issue Nov 11, 2019 · 0 comments
Open
3 tasks done

UndisposedFieldCodeFixProvider crashes #139

BADF00D opened this issue Nov 11, 2019 · 0 comments
Labels

Comments

@BADF00D
Copy link
Owner

BADF00D commented Nov 11, 2019

Prerequisites

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

Description

When hitting Ctrl+. on user.Select(u => u.FirstName) the crash occures. Btw FirstName is already disposed and SetValidateNotifyError is an extension method that pipes the given given extended argument.

Source Code

public MainWindowViewModel(IObservable<UserDto> user)
        {
            Func<string, IEnumerable> noneEmptyString = value => string.IsNullOrWhiteSpace(value) ? "Please provide a value" : null;

            DateOfDeath = user.Select(u => u.DateOfDeath)
                .ToPropertyViewModel();
            var isReadOnly = DateOfDeath.Where(dt => dt.HasValue)
                .Select(dt => dt.HasValue)
                .DistinctUntilChanged()
                .Publish()
                .RefCount();

            Name = user.Select(u => u.Name)
                .ToPropertyViewModel(isReadOnly)
                .SetValidateNotifyError(noneEmptyString);
            FirstName = user.Select(u => u.FirstName)
                .ToPropertyViewModel(isReadOnly)
                .SetValidateNotifyError(noneEmptyString);
            DateOfBirth = user.Select(u => u.DateOfBirth)
                .ToPropertyViewModel(Observable.Return(true));

            ResetCommand = ObservableExt
                .AnyOfLatest(Name.ObserveHasChanges, FirstName.ObserveHasChanges, DateOfBirth.ObserveHasChanges, DateOfDeath.ObserveHasChanges)
                .ToReactiveCommand();

            Name.ResetOn(ResetCommand.ToUnit());
        }

Stacktrace

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>)

Screenshot

@BADF00D BADF00D added the bug label Nov 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant