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

Fix for INPC005 MvvmCross.SetProperty #123

Closed
JohanLarsson opened this issue Aug 18, 2019 · 2 comments
Closed

Fix for INPC005 MvvmCross.SetProperty #123

JohanLarsson opened this issue Aug 18, 2019 · 2 comments

Comments

@JohanLarsson
Copy link
Collaborator

Not sure what we should pass as action, maybe null. Waiting with support for this.

@JohanLarsson JohanLarsson changed the title Handle MvvmCross.SetProperty Fix for INPC005 MvvmCross.SetProperty Aug 18, 2019
@JohanLarsson
Copy link
Collaborator Author

            [Test]
            public static void NoCheckToUseSetAndRaise()
            {
                var before = @"
namespace RoslynSandbox
{
    public class ViewModel : MvvmCross.ViewModels.MvxNotifyPropertyChanged
    {
        private string name;

        public string Name
        {
            get => this.name;
            set
            {
                this.name = value;
                ↓this.RaisePropertyChanged();
            }
        }
    }
}";

                var after = @"
namespace RoslynSandbox
{
    public class ViewModel : MvvmCross.ViewModels.MvxNotifyPropertyChanged
    {
        private string name;

        public string Name
        {
            get => this.name;
            set => this.SetProperty(ref this.name, value);
        }
    }
}";
                RoslynAssert.CodeFix(Analyzer, Fix, ExpectedDiagnostic, before, after, fixTitle: "Use MvxNotifyPropertyChanged.SetProperty");
                RoslynAssert.FixAll(Analyzer, Fix, ExpectedDiagnostic, before, after, fixTitle: "Use MvxNotifyPropertyChanged.SetProperty");
            }

@JohanLarsson
Copy link
Collaborator Author

            [Test]
            public static void NoCheckExpressionToUseSetAndRaise()
            {
                var before = @"
namespace RoslynSandbox
{
    public class ViewModel : MvvmCross.ViewModels.MvxNotifyPropertyChanged
    {
        private string name;

        public string Name
        {
            get => this.name;
            set
            {
                this.name = value;
                ↓this.RaisePropertyChanged(() => this.Name);
            }
        }
    }
}";

                var after = @"
namespace RoslynSandbox
{
    public class ViewModel : MvvmCross.ViewModels.MvxNotifyPropertyChanged
    {
        private string name;

        public string Name
        {
            get => this.name;
            set => this.SetProperty(ref this.name, value);
        }
    }
}";
                RoslynAssert.CodeFix(Analyzer, Fix, ExpectedDiagnostic, before, after, fixTitle: "Use MvxNotifyPropertyChanged.SetProperty");
                RoslynAssert.FixAll(Analyzer, Fix, ExpectedDiagnostic, before, after, fixTitle: "Use MvxNotifyPropertyChanged.SetProperty");
            }

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

1 participant