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 INPC013 when static #170

Open
JohanLarsson opened this issue Jan 19, 2020 · 0 comments
Open

Fix for INPC013 when static #170

JohanLarsson opened this issue Jan 19, 2020 · 0 comments

Comments

@JohanLarsson
Copy link
Collaborator

        [Test]
        public static void StaticEventHandlerOfPropertyChangedEventArgsInvoker()
        {
            var before = @"
namespace N
{
    using System;
    using System.ComponentModel;

    public static class C
    {
        private static string p;

        public static event EventHandler<PropertyChangedEventArgs> StaticPropertyChanged;

        public static string P
        {
            get => p;
            set
            {
                if (value == p)
                {
                    return;
                }

                p = value;
                OnStaticPropertyChanged(↓""P"");
            }
        }

        private static void OnStaticPropertyChanged(string propertyName)
        {
            StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs(propertyName));
        }
    }
}";

            var after = @"
namespace N
{
    using System;
    using System.ComponentModel;

    public static class C
    {
        private static string p;

        public static event EventHandler<PropertyChangedEventArgs> StaticPropertyChanged;

        public static string P
        {
            get => p;
            set
            {
                if (value == p)
                {
                    return;
                }

                p = value;
                OnStaticPropertyChanged(nameof(P));
            }
        }

        private static void OnStaticPropertyChanged(string propertyName)
        {
            StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs(propertyName));
        }
    }
}";
            RoslynAssert.CodeFix(Analyzer, Fix, ExpectedDiagnostic, before, after);
        }
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