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

[StyleCleanUp] Addressing SA warnings Part 3 #10125

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/Microsoft.DotNet.Wpf/src/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,6 @@ dotnet_diagnostic.SA1131.severity = suggestion
# SA1206: Keyword ordering
dotnet_diagnostic.SA1206.severity = suggestion

# SA1400: Member should declare an access modifier
dotnet_diagnostic.SA1400.severity = suggestion

# SA1404: Code analysis suppression should have justification
dotnet_diagnostic.SA1404.severity = suggestion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ internal static Point ClientToScreen(UIElement relativeTo, Point point)
// This cache is bound (gated) by the number of assemblies in the appdomain.
// We use a callback on GC to purge out collected assemblies, so we don't grow indefinitely.
//
static Dictionary<object, AssemblyName> _assemblies; // get key via GetKeyForAssembly
static object syncObject = new object();
static bool _isGCCallbackPending;
private static Dictionary<object, AssemblyName> _assemblies; // get key via GetKeyForAssembly
private static object syncObject = new object();
private static bool _isGCCallbackPending;

// PERF: Cache delegate for CleanupCollectedAssemblies to avoid allocating it each time.
static readonly WaitCallback _cleanupCollectedAssemblies = CleanupCollectedAssemblies;
private static readonly WaitCallback _cleanupCollectedAssemblies = CleanupCollectedAssemblies;

/// <summary>
/// This function iterates through the assemblies loaded in the current
Expand Down Expand Up @@ -158,7 +158,7 @@ internal static Assembly GetLoadedAssembly(AssemblyName assemblyName)
return null;
}

static AssemblyName GetAssemblyName(Assembly assembly)
private static AssemblyName GetAssemblyName(Assembly assembly)
{
object key = assembly.IsDynamic ? (object)new WeakRefKey(assembly) : assembly;
lock (syncObject)
Expand Down Expand Up @@ -194,7 +194,7 @@ static AssemblyName GetAssemblyName(Assembly assembly)
}

// After a GC, clean up the weakrefs to any collected dynamic assemblies
static void CleanupCollectedAssemblies(object state) // dummy parameter required by WaitCallback definition
private static void CleanupCollectedAssemblies(object state) // dummy parameter required by WaitCallback definition
{
bool foundLiveDynamicAssemblies = false;
List<object> keysToRemove = null;
Expand Down Expand Up @@ -301,7 +301,7 @@ static internal CultureInfo GetCultureInfoByIetfLanguageTag(string languageTag)
#if WINDOWS_BASE || PRESENTATION_CORE || SYSTEM_XAML
// for use as the key to a dictionary, when the "real" key is an object
// that we should not keep alive by a strong reference.
class WeakRefKey : WeakReference
internal class WeakRefKey : WeakReference
{
public WeakRefKey(object target)
:base(target)
Expand Down Expand Up @@ -345,18 +345,18 @@ public override bool Equals(object o)
return !(left == right);
}

readonly int _hashCode; // cache target's hashcode, lest it get GC'd out from under us
private readonly int _hashCode; // cache target's hashcode, lest it get GC'd out from under us
}

// This cleanup token will be immediately thrown away and as a result it will
// (a couple of GCs later) make it into the finalization queue and when finalized
// will kick off a thread-pool job that you can use to purge a weakref cache.
class GCNotificationToken
internal class GCNotificationToken
{
WaitCallback callback;
object state;
private WaitCallback callback;
private object state;

GCNotificationToken(WaitCallback callback, object state)
private GCNotificationToken(WaitCallback callback, object state)
{
this.callback = callback;
this.state = state;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ namespace MS.Internal.Xaml.Context
//This stack has the following features:
// 1) it recycles frames
// 2) it is <T>, and avoids activator.createinstance with the creationDelegate
class XamlContextStack<T> where T : XamlFrame
internal class XamlContextStack<T> where T : XamlFrame
{
private int _depth;
T _currentFrame;
T _recycledFrame;
Func<T> _creationDelegate;
private T _currentFrame;
private T _recycledFrame;
private Func<T> _creationDelegate;

public XamlContextStack(Func<T> creationDelegate)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace MS.Internal.Xaml.Context
{
abstract class XamlFrame
internal abstract class XamlFrame
{
private int _depth;
private XamlFrame _previous;
Expand Down
12 changes: 6 additions & 6 deletions src/Microsoft.DotNet.Wpf/src/Shared/MS/Utility/FrugalList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ internal enum FrugalListStoreState
Array
}

abstract class FrugalListBase<T>
internal abstract class FrugalListBase<T>
{
/// <summary>
/// Number of entries in this store
Expand Down Expand Up @@ -1592,9 +1592,9 @@ public override FrugalListBase<T> Finish()
return _targetStore;
}

ArrayItemList<T> _targetStore;
T[] _sourceArray;
T[] _targetArray;
private ArrayItemList<T> _targetStore;
private T[] _sourceArray;
private T[] _targetArray;
}

#endregion Compacter
Expand Down Expand Up @@ -1923,8 +1923,8 @@ public void Finish()
}
}

FrugalObjectList<T> _list;
FrugalListBase<T>.Compacter _storeCompacter;
private FrugalObjectList<T> _list;
private FrugalListBase<T>.Compacter _storeCompacter;
}
#endregion Compacter
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ namespace System.Windows.Markup
// if the passed in namespace is subsumed, then newXmlNamespace returns the subsuming namespace.
// </param>
internal delegate bool IsXmlNamespaceSupportedCallback(string xmlNamespace, out string newXmlNamespace);
delegate void HandleElementCallback(int elementDepth, ref bool more);
delegate void HandleAttributeCallback(int elementDepth);
internal delegate void HandleElementCallback(int elementDepth, ref bool more);
internal delegate void HandleAttributeCallback(int elementDepth);

internal sealed class XmlCompatibilityReader : XmlWrappingReader
{
Expand Down Expand Up @@ -1599,7 +1599,7 @@ private string CompatibilityUri
}
#endregion Private Properties
#region Nested Classes
struct NamespaceElementPair
private struct NamespaceElementPair
{
public string namespaceName;
public string itemName;
Expand All @@ -1618,18 +1618,18 @@ public NamespaceElementPair(string namespaceName, string itemName)
/// </summary>
private class CompatibilityScope
{
CompatibilityScope _previous;
int _depth;
bool _fallbackSeen;
bool _inAlternateContent;
bool _inProcessContent;
bool _choiceTaken;
bool _choiceSeen;
XmlCompatibilityReader _reader;
Dictionary<string, object> _ignorables;
Dictionary<string, ProcessContentSet> _processContents;
Dictionary<string, PreserveItemSet> _preserveElements;
Dictionary<string, PreserveItemSet> _preserveAttributes;
private CompatibilityScope _previous;
private int _depth;
private bool _fallbackSeen;
private bool _inAlternateContent;
private bool _inProcessContent;
private bool _choiceTaken;
private bool _choiceSeen;
private XmlCompatibilityReader _reader;
private Dictionary<string, object> _ignorables;
private Dictionary<string, ProcessContentSet> _processContents;
private Dictionary<string, PreserveItemSet> _preserveElements;
private Dictionary<string, PreserveItemSet> _preserveAttributes;

public CompatibilityScope(CompatibilityScope previous, int depth, XmlCompatibilityReader reader)
{
Expand Down Expand Up @@ -1908,12 +1908,12 @@ public void Verify()
}
}

class ProcessContentSet
private class ProcessContentSet
{
bool _all;
string _namespaceName;
XmlCompatibilityReader _reader;
HashSet<string> _names;
private bool _all;
private string _namespaceName;
private XmlCompatibilityReader _reader;
private HashSet<string> _names;

public ProcessContentSet(string namespaceName, XmlCompatibilityReader reader)
{
Expand Down Expand Up @@ -1963,12 +1963,12 @@ public void Add(string elementName)
}
}

class PreserveItemSet
private class PreserveItemSet
{
bool _all;
string _namespaceName;
XmlCompatibilityReader _reader;
Dictionary<string, string> _names;
private bool _all;
private string _namespaceName;
private XmlCompatibilityReader _reader;
private Dictionary<string, string> _names;

public PreserveItemSet(string namespaceName, XmlCompatibilityReader reader)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ namespace System.Xaml
{
public class AttachableMemberIdentifier : IEquatable<AttachableMemberIdentifier>
{
readonly Type declaringType;
readonly string memberName;
private readonly Type declaringType;
private readonly string memberName;

public AttachableMemberIdentifier(Type declaringType, string memberName)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace System.Xaml
{
public static class AttachablePropertyServices
{
static DefaultAttachedPropertyStore attachedProperties = new DefaultAttachedPropertyStore();
private static DefaultAttachedPropertyStore attachedProperties = new DefaultAttachedPropertyStore();

public static int GetAttachedPropertyCount(object instance)
{
Expand Down Expand Up @@ -121,9 +121,9 @@ public static bool TryGetProperty<T>(object instance, AttachableMemberIdentifier
// global attached properties for types which don't implement IAttachedProperties or DO/Dependency Property
// integration for their attached properties.

sealed class DefaultAttachedPropertyStore
private sealed class DefaultAttachedPropertyStore
{
Lazy<ConditionalWeakTable<object, Dictionary<AttachableMemberIdentifier, object>>> instanceStorage =
private Lazy<ConditionalWeakTable<object, Dictionary<AttachableMemberIdentifier, object>>> instanceStorage =
new Lazy<ConditionalWeakTable<object, Dictionary<AttachableMemberIdentifier, object>>>();

public void CopyPropertiesTo(object instance, KeyValuePair<AttachableMemberIdentifier, object>[] array, int index)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,26 @@ namespace MS.Internal.Xaml.Context
internal class NameFixupGraph
{
// Node -> out-edges (other objects the parent is dependent on)
Dictionary<object, FrugalObjectList<NameFixupToken>> _dependenciesByParentObject;
private Dictionary<object, FrugalObjectList<NameFixupToken>> _dependenciesByParentObject;

// Node -> in-edge (other object that is dependent on this child)
Dictionary<object, NameFixupToken> _dependenciesByChildObject;
private Dictionary<object, NameFixupToken> _dependenciesByChildObject;

// Node -> in-edges (other objects that are dependent on this name)
Dictionary<string, FrugalObjectList<NameFixupToken>> _dependenciesByName;
private Dictionary<string, FrugalObjectList<NameFixupToken>> _dependenciesByName;

// Queue of tokens whose dependencies have been resolved, and are awaiting processing
Queue<NameFixupToken> _resolvedTokensPendingProcessing;
private Queue<NameFixupToken> _resolvedTokensPendingProcessing;

// Token for a pending call to ProvideValue on the root object. Can't store this in
// _dependenciesByParentObject because it has no parent.
NameFixupToken _deferredRootProvideValue;
private NameFixupToken _deferredRootProvideValue;

// At the end of the parse, we start running reparses on partially initialized objects,
// and remove those dependencies. But we still want to be able to inform MEs/TCs that
// the named objects they're getting aren't actually fully initialized. So we save this list
// of incompletely initialized objects at the point we start completing references.
HashSet <object> _uninitializedObjectsAtParseEnd;
private HashSet <object> _uninitializedObjectsAtParseEnd;

public NameFixupGraph()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ XamlException IAddLineInfo.WithLineInfo(XamlException ex)

internal class NameFixupToken : IAddLineInfo
{
List<string> _names;
List<XAML3.INameScopeDictionary> _nameScopeDictionaryList;
private List<string> _names;
private List<XAML3.INameScopeDictionary> _nameScopeDictionaryList;

public NameFixupToken()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ internal class ObjectWriterContext : XamlContext

private object _rootInstance;

ServiceProviderContext _serviceProviderContext;
XamlRuntime _runtime;
int _savedDepth; // The depth of the "saved" part this context is based on.
bool _nameResolutionComplete;
XamlObjectWriterSettings _settings;
List<NameScopeInitializationCompleteSubscriber> _nameScopeInitializationCompleteSubscribers;
private ServiceProviderContext _serviceProviderContext;
private XamlRuntime _runtime;
private int _savedDepth; // The depth of the "saved" part this context is based on.
private bool _nameResolutionComplete;
private XamlObjectWriterSettings _settings;
private List<NameScopeInitializationCompleteSubscriber> _nameScopeInitializationCompleteSubscribers;

public ObjectWriterContext(XamlSavedContext savedContext,
XamlObjectWriterSettings settings, XAML3.INameScope rootNameScope, XamlRuntime runtime)
Expand Down Expand Up @@ -1030,7 +1030,7 @@ internal void RaiseNameScopeInitializationCompleteEvent()

internal class NameScopeInitializationCompleteSubscriber
{
List<XAML3.INameScopeDictionary> _nameScopeDictionaryList = new List<XAML3.INameScopeDictionary>();
private List<XAML3.INameScopeDictionary> _nameScopeDictionaryList = new List<XAML3.INameScopeDictionary>();

public EventHandler Handler
{
Expand All @@ -1045,7 +1045,7 @@ public List<XAML3.INameScopeDictionary> NameScopeDictionaryList

private class StackWalkNameResolver : IXamlNameResolver
{
List<XAML3.INameScopeDictionary> _nameScopeDictionaryList;
private List<XAML3.INameScopeDictionary> _nameScopeDictionaryList;

public StackWalkNameResolver(List<XAML3.INameScopeDictionary> nameScopeDictionaryList)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal class ServiceProviderContext : ITypeDescriptorContext, // derives from
IDestinationTypeProvider,
IXamlLineInfo
{
ObjectWriterContext _xamlContext;
private ObjectWriterContext _xamlContext;

public ServiceProviderContext(ObjectWriterContext context)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ namespace MS.Internal.Xaml.Context
{
internal class XamlObjectWriterFactory: IXamlObjectWriterFactory
{
XamlSavedContext _savedContext;
XamlObjectWriterSettings _parentSettings;
private XamlSavedContext _savedContext;
private XamlObjectWriterSettings _parentSettings;

public XamlObjectWriterFactory(ObjectWriterContext context)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ IEnumerable<AmbientPropertyValue> GetAllAmbientValues(IEnumerable<XamlType> ceil

public class AmbientPropertyValue
{
XamlMember _property;
object _value;
private XamlMember _property;
private object _value;

public AmbientPropertyValue(XamlMember property, object value)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ internal enum DeferringMode

internal class DeferringWriter : XamlWriter, IXamlLineInfoConsumer
{
DeferringMode _mode;
bool _handled;
ObjectWriterContext _context;
XamlNodeList _deferredList;
XamlWriter _deferredWriter;
IXamlLineInfoConsumer _deferredLineInfoConsumer;
int _deferredTreeDepth;
private DeferringMode _mode;
private bool _handled;
private ObjectWriterContext _context;
private XamlNodeList _deferredList;
private XamlWriter _deferredWriter;
private IXamlLineInfoConsumer _deferredLineInfoConsumer;
private int _deferredTreeDepth;

public DeferringWriter(ObjectWriterContext context)
{
Expand Down Expand Up @@ -71,7 +71,7 @@ public override void WriteStartObject(XamlType xamlType)
WriteObject(xamlType, false, "WriteStartObject");
}

void WriteObject(XamlType xamlType, bool fromMember, string methodName)
private void WriteObject(XamlType xamlType, bool fromMember, string methodName)
{
_handled = false;
switch (_mode)
Expand Down
Loading