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 4 #10126

Merged
merged 8 commits into from
Jan 2, 2025
Merged
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
21 changes: 0 additions & 21 deletions src/Microsoft.DotNet.Wpf/src/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -290,27 +290,6 @@ dotnet_diagnostic.IDE0300.severity = suggestion
# IDE1006: Naming Styles
dotnet_diagnostic.IDE1006.severity = suggestion

# SA1001: Commas should not be preceded by whitespace
dotnet_diagnostic.SA1001.severity = suggestion

# SA1005: Single line comment should begin with a space
dotnet_diagnostic.SA1005.severity = suggestion

# SA1014: Opening generic brackets should not be preceded by a space
dotnet_diagnostic.SA1014.severity = suggestion

# SA1027: Tabs and spaces should be used correctly
dotnet_diagnostic.SA1027.severity = suggestion

# SA1028: Code should not contain trailing whitespace
dotnet_diagnostic.SA1028.severity = suggestion

# SA1121: Use built-in type alias
dotnet_diagnostic.SA1121.severity = suggestion

# SA1129: Do not use default value type constructor
dotnet_diagnostic.SA1129.severity = suggestion

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,12 @@ static AssemblyName GetAssemblyName(Assembly assembly)
_assemblies = new Dictionary<object, AssemblyName>();
}
else
{
{
if (_assemblies.TryGetValue(key, out result))
{
return result;
}
}
}

//
// We use AssemblyName ctor here because GetName demands FileIOPermission
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace MS.Internal.Xaml.Context
{
//This stack has the following features:
// 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
Expand Down Expand Up @@ -59,7 +59,7 @@ public XamlContextStack(XamlContextStack<T> source, bool copy)
}
}

//allocate a new frame as the new currentFrame;
// allocate a new frame as the new currentFrame;
private void Grow()
{
T lastFrame = _currentFrame;
Expand Down Expand Up @@ -94,15 +94,15 @@ public T GetFrame(int depth)
return iteratorFrame;
}

//Consumers of this stack call PushScope, and we'll either allocate a new frame
// Consumers of this stack call PushScope, and we'll either allocate a new frame
// or we'll grab one from our recycled linked list.
public void PushScope()
{
if (_recycledFrame is null)
{
Grow();
}
else //use recycled frame
else // use recycled frame
{
T lastFrame = _currentFrame;
_currentFrame = _recycledFrame;
Expand All @@ -114,7 +114,7 @@ public void PushScope()
Debug.Assert(CurrentFrame.Depth == Depth);
}

//Consumers of this stack call PopScope, and we'll move the currentFrame from the main
// Consumers of this stack call PopScope, and we'll move the currentFrame from the main
// linked list to the recylced linked list and call .Reset
public void PopScope()
{
Expand All @@ -133,7 +133,7 @@ public int Depth
set { _depth = value; }
}

//In case the stack needs to survive and you don't want to keep the recylced frames around.
// In case the stack needs to survive and you don't want to keep the recylced frames around.
public void Trim()
{
_recycledFrame = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#nullable disable

// Description: Data model for the Bracket characters specified on a Markup Extension property.
// Description: Data model for the Bracket characters specified on a Markup Extension property.

using System;
using System.Collections.Generic;
Expand All @@ -31,7 +31,7 @@ internal SpecialBracketCharacters()
BeginInit();
}

internal SpecialBracketCharacters(IReadOnlyDictionary<char,char> attributeList)
internal SpecialBracketCharacters(IReadOnlyDictionary<char, char> attributeList)
{
BeginInit();
if (attributeList is not null && attributeList.Count > 0)
Expand All @@ -53,7 +53,7 @@ internal void AddBracketCharacters(char openingBracket, char closingBracket)
}
}

private void Tokenize(IReadOnlyDictionary<char,char> attributeList)
private void Tokenize(IReadOnlyDictionary<char, char> attributeList)
{
if (_initializing)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
using MS.Internal.WindowsBase;
#endif

//using MS.Internal.PresentationCore;
//using SR=MS.Internal.WindowsBase.SR;
// using MS.Internal.PresentationCore;
// using SR=MS.Internal.WindowsBase.SR;

// These classes implement a frugal storage model for lists of type <T>.
// Performance measurements show that Avalon has many lists that contain
Expand Down Expand Up @@ -2289,7 +2289,7 @@ public void CopyTo(T[] array, int index)

public FrugalStructList<T> Clone()
{
FrugalStructList<T> myClone = new FrugalStructList<T>();
FrugalStructList<T> myClone = default(FrugalStructList<T>);

if (_listStore is not null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#nullable disable

// Description: Specifies that the whitespace surrounding an element should be trimmed.
// Description: Specifies that the whitespace surrounding an element should be trimmed.

using System;
using System.IO;
Expand Down Expand Up @@ -333,7 +333,7 @@ private static string GetCustomAttributeData(CustomAttributeData cad,
if (constructorArguments.Count == 1 && !noArgs)
{
CustomAttributeTypedArgument tca = constructorArguments[0];
attrValue = tca.Value as String;
attrValue = tca.Value as string;
#if PBTCOMPILER
if (attrValue == null && allowTypeAlso && tca.ArgumentType == GetMscorlibType(typeof(Type)))
#else
Expand Down Expand Up @@ -433,12 +433,12 @@ private static Assembly LoadAssemblyHelper(string assemblyGivenName, string asse
// Check if the current AppDomain has this assembly loaded for some other reason.
// If so, then just use that assembly and don't attempt to load another copy of it.
// Only do this if no path is provided.
if (String.IsNullOrEmpty(assemblyPath))
if (string.IsNullOrEmpty(assemblyPath))
retassem = SafeSecurityHelper.GetLoadedAssembly(assemblyName);

if (retassem is null)
{
if (!String.IsNullOrEmpty(assemblyPath))
if (!string.IsNullOrEmpty(assemblyPath))
{
// assemblyPath is set, Load the assembly from this specified place.
// the path must be full file path which contains directory, file name and extension.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

// Description: Specifies that the whitespace surrounding an element should be trimmed.
// Description: Specifies that the whitespace surrounding an element should be trimmed.

using System;
using System.Reflection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public override bool Read()
ScanForEndCompatibility(previousElementDepth);
}

bool more = Reader.Read(); //passed as ref arg to ReadStartElement and ReadEndElement
bool more = Reader.Read(); // passed as ref arg to ReadStartElement and ReadEndElement
bool result = false;

while (more)
Expand Down Expand Up @@ -327,7 +327,7 @@ private bool ReadEndElement(ref bool more)
}

_depthOffset--;
PopScope(); //we know we can pop, so no need to scan
PopScope(); // we know we can pop, so no need to scan
more = Reader.Read();
}
else
Expand Down Expand Up @@ -821,7 +821,7 @@ private string MapNewNamespace(string namespaceName)
{
AddKnownNamespace(namespaceName);

if (String.IsNullOrEmpty(mappedNamespace) || namespaceName == mappedNamespace)
if (string.IsNullOrEmpty(mappedNamespace) || namespaceName == mappedNamespace)
{
_namespaceMap[namespaceName] = namespaceName;
}
Expand Down Expand Up @@ -958,7 +958,7 @@ private IEnumerable<NamespaceElementPair> ParseContentToNamespaceElementPair(str
foreach (string pair in content.Trim().Split(' '))
{
// check each non-null, non-empty space-delineated namespace/element pair
if (!String.IsNullOrEmpty(pair))
if (!string.IsNullOrEmpty(pair))
{
int colonIndex = pair.IndexOf(':');
int length = pair.Length;
Expand Down Expand Up @@ -1006,7 +1006,7 @@ private IEnumerable<string> PrefixesToNamespaces(string prefixes)
foreach (string prefix in prefixes.Trim().Split(' '))
{
// check each non-null, non-empty space-delineated prefix
if (!String.IsNullOrEmpty(prefix))
if (!string.IsNullOrEmpty(prefix))
{
string namespaceUri = LookupNamespace(prefix);

Expand Down Expand Up @@ -1220,7 +1220,7 @@ private void HandleChoice(int elementDepth, ref bool more)
Error(SR.XCRRequiresAttribNotFound);
}

if (String.IsNullOrEmpty(requiresValue))
if (string.IsNullOrEmpty(requiresValue))
{
// Requires attribute may not be empty
Error(SR.XCRInvalidRequiresAttribute);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ string IXmlNamespaceResolver.LookupPrefix( string namespaceName )
return (_readerAsResolver is null) ? null : _readerAsResolver.LookupPrefix( namespaceName );
}

IDictionary<string,string> IXmlNamespaceResolver.GetNamespacesInScope ( XmlNamespaceScope scope )
IDictionary<string, string> IXmlNamespaceResolver.GetNamespacesInScope ( XmlNamespaceScope scope )
{
return (_readerAsResolver is null) ? null : _readerAsResolver.GetNamespacesInScope( scope );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

// New since v4 RTM:

//this is used by subclasses, bad FxCop detection
// this is used by subclasses, bad FxCop detection
[assembly: SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Scope = "type", Target = "System.Xaml.MS.Impl.FrugalObjectList`1+Compacter", Justification = "Non-Breaking")]
#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo c
}

string name = value as string;
if (String.IsNullOrEmpty(name))
if (string.IsNullOrEmpty(name))
{
throw new InvalidOperationException(SR.MustHaveName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public override object ProvideValue(IServiceProvider serviceProvider)
throw new InvalidOperationException(SR.MissingNameResolver);
}

if (String.IsNullOrEmpty(Name))
if (string.IsNullOrEmpty(Name))
{
throw new InvalidOperationException(SR.MustHaveName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ private bool GetFieldOrPropertyValue(Type type, string name, out object value)
PropertyInfo prop = currentType.GetProperty(name, BindingFlags.Public | BindingFlags.Static);
if (prop is not null)
{
value = prop.GetValue(null,null);
value = prop.GetValue(null, null);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace System.Windows.Markup
/// An attribute that specifies which property the xml:lang value should
/// be directed to.
/// Example:
// [XmlLangProperty("Language")]
// [XmlLangProperty("Language")]
// public class ExampleFrameworkElement
//
// Means that when the parser sees:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ internal class NameFixupGraph
// 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;
HashSet<object> _uninitializedObjectsAtParseEnd;

public NameFixupGraph()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public List<XAML3.INameScopeDictionary> NameScopeDictionaryList
get { return _nameScopeDictionaryList; }
}

public List<String> NeededNames
public List<string> NeededNames
{
get { return _names; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ internal XamlObjectWriterSettings ServiceProvider_GetSettings()

// ----- abstracts overriden from XamlContext.

public override void AddNamespacePrefix(String prefix, string xamlNS)
public override void AddNamespacePrefix(string prefix, string xamlNS)
{
_stack.CurrentFrame.AddNamespace(prefix, xamlNS);
}
Expand Down Expand Up @@ -768,7 +768,7 @@ public object RootInstance
{
get
{
//evaluate if _rootInstance should just always look at _rootFrame.Instance instead of caching an instance
// evaluate if _rootInstance should just always look at _rootFrame.Instance instead of caching an instance
if (_rootInstance is null)
{
ObjectWriterFrame rootFrame = GetTopFrame();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal class XamlSavedContext

public XamlSavedContext(SavedContextType savedContextType, ObjectWriterContext owContext, XamlContextStack<ObjectWriterFrame> stack)
{
//We should harvest all information necessary from the xamlContext so that we can answer all ServiceProvider based questions.
// We should harvest all information necessary from the xamlContext so that we can answer all ServiceProvider based questions.
_savedContextType = savedContextType;
_context = owContext.SchemaContext;
_stack = stack;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public string GetAttributeNamespace(XamlPropertyName propName, string tagNamespa
// If prefix is "" then
// Normal Properties resolve to the ownerType namespace
// Attachable properties resolve to the actual "" namespace
if (String.IsNullOrEmpty(propName.Prefix) && !propName.IsDotted)
if (string.IsNullOrEmpty(propName.Prefix) && !propName.IsDotted)
{
ns = tagNamespace;
}
Expand Down
Loading