-
Notifications
You must be signed in to change notification settings - Fork 4
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
Fixes for INPC002 when static #169
Comments
[Test]
public static void StaticEventHandlerOfPropertyChangedEventArgsInvoke()
{
var before = @"
namespace N
{
using System;
using System.ComponentModel;
public static class C
{
public static event EventHandler<PropertyChangedEventArgs> StaticPropertyChanged;
public static string ↓P { get; set; }
}
}";
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;
StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs(nameof(P)));
}
}
}
}";
RoslynAssert.CodeFix(Analyzer, Fix, ExpectedDiagnostic, before, after);
} |
[Test]
public static void StaticEventHandlerOfPropertyChangedEventArgsInvoker()
{
var before = @"
namespace N
{
using System;
using System.ComponentModel;
public static class C
{
public static event EventHandler<PropertyChangedEventArgs> StaticPropertyChanged;
public static string ↓P { get; set; }
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);
} |
[Test]
public static void StaticPropertyChangedEventHandlerInvoke()
{
var before = @"
namespace N
{
using System.ComponentModel;
public class C
{
public static event PropertyChangedEventHandler PropertyChanged;
public static string ↓P { get; set; }
}
}";
var after = @"
namespace N
{
using System.ComponentModel;
public class C
{
private static string p;
public static event PropertyChangedEventHandler PropertyChanged;
public static string P
{
get => p;
set
{
if (value == p)
{
return;
}
p = value;
PropertyChanged?.Invoke(null, new PropertyChangedEventArgs(nameof(P)));
}
}
}
}";
RoslynAssert.CodeFix(Analyzer, Fix, ExpectedDiagnostic, before, after);
} |
[Test]
public static void StaticPropertyChangedEventHandlerInvoker()
{
var before = @"
namespace N
{
using System.ComponentModel;
public class C
{
public static event PropertyChangedEventHandler PropertyChanged;
public static string ↓P { get; set; }
private static void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(null, new PropertyChangedEventArgs(propertyName));
}
}
}";
var after = @"
namespace N
{
using System.ComponentModel;
public class C
{
private static string p;
public static event PropertyChangedEventHandler PropertyChanged;
public static string P
{
get => p;
set
{
if (value == p)
{
return;
}
p = value;
OnPropertyChanged(nameof(P));
}
}
private static void OnPropertyChanged(string propertyName)
{
PropertyChanged?.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
Not extremely useful as binding to static properties is rare.
The text was updated successfully, but these errors were encountered: