These properties are being flagged with S4275. This makes sense based on the rule’s description because the DependecyProperty fields aren’t private and the naming pattern doesn’t match. Is my best option for resolving this issue to use #pragma warning disable S4275 and #pragma warning restore S4275 around the properties?
public static readonly DependencyProperty ToolTipProperty = DependencyProperty.Register("ToolTip", typeof(string), typeof(MyObject), new PropertyMetadata(new PropertyChangedCallback(ToolTipPropertyChanged)));
public string ToolTip
{
get
{
return (string)GetValue(ToolTipProperty);
}
set
{
SetValue(ToolTipProperty, value);
}
}
Coming back, @ckdrc, I cannot reproduce the issue.
this is my attempt to reproduce:
public class Repro3442 : System.Windows.Controls.Primitives.ButtonBase
{
public static readonly DependencyProperty IsSpinningProperty = DependencyProperty.Register("IsSpinning", typeof(Boolean),typeof(Repro3442));
public bool IsSpinning
{
get { return (bool)GetValue(IsSpinningProperty); }
set { SetValue(IsSpinningProperty, value); }
}
}
Can you provide more code from your reproducer, please?
Can you please try to make a reproducer project and analyze it on SonarCloud? It’s free for open source projects. Having it on SonarCloud will be a clear reproducer.