Skip to content

Commit

Permalink
Fix StyleCop warnings SA1028 and SA1518 (trailing whitespace and blan…
Browse files Browse the repository at this point in the history
…k lines)

Commit migrated from dotnet/coreclr@f4ce6c7
  • Loading branch information
stephentoub committed Aug 9, 2019
1 parent 9392937 commit 6ed4a5e
Show file tree
Hide file tree
Showing 119 changed files with 548 additions and 719 deletions.
16 changes: 8 additions & 8 deletions src/coreclr/src/System.Private.CoreLib/Common/System/SR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace System
{
internal static partial class SR
{
// This method is used to decide if we need to append the exception message parameters to the message when calling SR.Format.
// This method is used to decide if we need to append the exception message parameters to the message when calling SR.Format.
// by default it returns false.
[MethodImpl(MethodImplOptions.NoInlining)]
private static bool UsingResourceKeys()
Expand Down Expand Up @@ -54,24 +54,24 @@ internal static string GetResourceString(string resourceKey, string? defaultStri
return key!;
}

// We have a somewhat common potential for infinite
// We have a somewhat common potential for infinite
// loops with mscorlib's ResourceManager. If "potentially dangerous"
// code throws an exception, we will get into an infinite loop
// inside the ResourceManager and this "potentially dangerous" code.
// Potentially dangerous code includes the IO package, CultureInfo,
// parts of the loader, some parts of Reflection, Security (including
// parts of the loader, some parts of Reflection, Security (including
// custom user-written permissions that may parse an XML file at
// class load time), assembly load event handlers, etc. Essentially,
// this is not a bounded set of code, and we need to fix the problem.
// Fortunately, this is limited to mscorlib's error lookups and is NOT
// a general problem for all user code using the ResourceManager.

// The solution is to make sure only one thread at a time can call
// GetResourceString. Also, since resource lookups can be
// The solution is to make sure only one thread at a time can call
// GetResourceString. Also, since resource lookups can be
// reentrant, if the same thread comes into GetResourceString
// twice looking for the exact same resource name before
// returning, we're going into an infinite loop and we should
// return a bogus string.
// twice looking for the exact same resource name before
// returning, we're going into an infinite loop and we should
// return a bogus string.

bool lockTaken = false;
try
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

Expand Down Expand Up @@ -171,7 +171,7 @@ public byte[][] GetBytes()

internal sealed class FlatDataTable
{
// If a codepoint does not have data, this specifies the default value.
// If a codepoint does not have data, this specifies the default value.
private readonly string DefaultValue;
private readonly Func<string, byte[]> GetValueBytesCallback;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

Expand Down Expand Up @@ -26,7 +26,7 @@ private static void Main(string[] args)
var numericIndexTable = new DataTable();
// Create a flat table for Unicode category and BiDi category
var categoriesValueTable = new FlatDataTable(defaultCategoryValues, GetCategoriesValueBytes);
// Create a flat table.
// Create a flat table.
// GetNumericValueBytes() is the callback used to generate the bytes of each item.
var numericValueTable = new FlatDataTable("-1", GetNumericValueBytes);
// Create a flat table for digit values
Expand Down Expand Up @@ -120,25 +120,25 @@ private static void Main(string[] args)
/// </summary>
private static readonly Dictionary<string, byte> BiDiCategory = new Dictionary<string, byte>
{
["L"] = 0, // Left-to-Right
["LRE"] = 1, // Left-to-Right Embedding
["LRO"] = 2, // Left-to-Right Override
["R"] = 3, // Right-to-Left
["AL"] = 4, // Right-to-Left Arabic
["RLE"] = 5, // Right-to-Left Embedding
["RLO"] = 6, // Right-to-Left Override
["PDF"] = 7, // Pop Directional Format
["EN"] = 8, // European Number
["ES"] = 9, // European Number Separator
["ET"] = 10, // European Number Terminator
["AN"] = 11, // Arabic Number
["CS"] = 12, // Common Number Separator
["NSM"] = 13, // Non-Spacing Mark
["BN"] = 14, // Boundary Neutral
["B"] = 15, // Paragraph Separator
["S"] = 16, // Segment Separator
["WS"] = 17, // Whitespace
["ON"] = 18, // Other Neutrals
["L"] = 0, // Left-to-Right
["LRE"] = 1, // Left-to-Right Embedding
["LRO"] = 2, // Left-to-Right Override
["R"] = 3, // Right-to-Left
["AL"] = 4, // Right-to-Left Arabic
["RLE"] = 5, // Right-to-Left Embedding
["RLO"] = 6, // Right-to-Left Override
["PDF"] = 7, // Pop Directional Format
["EN"] = 8, // European Number
["ES"] = 9, // European Number Separator
["ET"] = 10, // European Number Terminator
["AN"] = 11, // Arabic Number
["CS"] = 12, // Common Number Separator
["NSM"] = 13, // Non-Spacing Mark
["BN"] = 14, // Boundary Neutral
["B"] = 15, // Paragraph Separator
["S"] = 16, // Segment Separator
["WS"] = 17, // Whitespace
["ON"] = 18, // Other Neutrals
["LRI"] = 19, // LeftToRightIsolate
["RLI"] = 20, // RightToLeftIsolate
["FSI"] = 21, // FirstStrongIsolate
Expand Down Expand Up @@ -191,7 +191,7 @@ private static void ReadSourceFile(string sourceFileName, DataTable categoriesIn
// 0 Code value
// 1 Character name
// 2 General Category
//
//
// 3 Canonical Combining Classes
// 4 Bidirectional Category
// 5 Character Decomposition Mapping
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal static class ActivationFactoryLoader
// we don't need to share this dictionary with the COM activation dictionary
// since there will be no overlap.
private static readonly Dictionary<string, AssemblyLoadContext> s_assemblyLoadContexts = new Dictionary<string, AssemblyLoadContext>(StringComparer.InvariantCultureIgnoreCase);

private static AssemblyLoadContext GetALC(string assemblyPath)
{
AssemblyLoadContext? alc;
Expand Down Expand Up @@ -52,7 +52,7 @@ public unsafe static int GetActivationFactory(
}

AssemblyLoadContext context = GetALC(Marshal.PtrToStringUni((IntPtr)componentPath)!);

Type winRTType = context.LoadTypeForWinRTTypeNameInContext(typeName);

if (winRTType is null || !winRTType.IsExportedToWindowsRuntime)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static class ExceptionSupport
/// <returns>true if the error was reported, false if not (ie running on Win8)</returns>
public static bool ReportUnhandledError(Exception? ex)
{
return WindowsRuntimeMarshal.ReportUnhandledError(ex);
return WindowsRuntimeMarshal.ReportUnhandledError(ex);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
**
**
**
** Purpose: This class only exists to provide support for
** implenting IDispatch on managed objects. It is
** Purpose: This class only exists to provide support for
** implenting IDispatch on managed objects. It is
** used to provide OleAut style coercion rules.
**
**
**
===========================================================*/

namespace Microsoft.Win32
Expand Down Expand Up @@ -71,8 +71,8 @@ internal static class OAVariantLib
* Changes a Variant from one type to another, calling the OLE
* Automation VariantChangeTypeEx routine. Note the legal types here are
* restricted to the subset of what can be legally found in a VB
* Variant and the types that CLR supports explicitly in the
* CLR Variant class.
* Variant and the types that CLR supports explicitly in the
* CLR Variant class.
*/
internal static Variant ChangeType(Variant source, Type targetClass, short options, CultureInfo culture)
{
Expand Down
20 changes: 10 additions & 10 deletions src/coreclr/src/System.Private.CoreLib/src/System/ArgIterator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public ArgIterator(RuntimeArgumentHandle arglist) : this(arglist.Value)

[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern unsafe ArgIterator(IntPtr arglist, void *ptr);
// create an arg iterator that points just past 'firstArg'.

// create an arg iterator that points just past 'firstArg'.
// 'arglist' is the value returned by the ARGLIST instruction
// This is much like the C va_start macro

Expand Down Expand Up @@ -69,7 +69,7 @@ public TypedReference GetNextArg()
private extern unsafe void FCallGetNextArg(void * result);

// Alternate version of GetNextArg() intended primarily for IJW code
// generated by VC's "va_arg()" construct.
// generated by VC's "va_arg()" construct.
[CLSCompliant(false)]
public TypedReference GetNextArg(RuntimeTypeHandle rth)
{
Expand Down Expand Up @@ -108,31 +108,31 @@ public TypedReference GetNextArg(RuntimeTypeHandle rth)
public void End()
{
}
// How many arguments are left in the list

// How many arguments are left in the list
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern int GetRemainingCount();

// Gets the type of the current arg, does NOT advance the iterator
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern unsafe void* _GetNextArgType();

public unsafe RuntimeTypeHandle GetNextArgType()
public unsafe RuntimeTypeHandle GetNextArgType()
{
return new RuntimeTypeHandle(Type.GetTypeFromHandleUnsafe((IntPtr)_GetNextArgType()));
}

public override int GetHashCode()
{
return ValueType.GetHashCodeOfPtr(ArgCookie);
}

// Inherited from object
public override bool Equals(object? o)
{
throw new NotSupportedException(SR.NotSupported_NYI);
}
#else
#else
public ArgIterator(RuntimeArgumentHandle arglist)
{
throw new PlatformNotSupportedException(SR.PlatformNotSupported_ArgIterator); // https://github.com/dotnet/coreclr/issues/9204
Expand Down
26 changes: 13 additions & 13 deletions src/coreclr/src/System.Private.CoreLib/src/System/Array.CoreCLR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
namespace System
{
// Note that we make a T[] (single-dimensional w/ zero as the lower bound) implement both
// IList<U> and IReadOnlyList<U>, where T : U dynamically. See the SZArrayHelper class for details.
// IList<U> and IReadOnlyList<U>, where T : U dynamically. See the SZArrayHelper class for details.
public abstract partial class Array : ICloneable, IList, IStructuralComparable, IStructuralEquatable
{
// Create instance will create an array
Expand Down Expand Up @@ -88,9 +88,9 @@ public static unsafe Array CreateInstance(Type elementType, params int[] lengths
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_MustBeType, ExceptionArgument.elementType);

// Check to make sure the lengths are all positive. Note that we check this here to give
// a good exception message if they are not; however we check this again inside the execution
// engine's low level allocation function after having made a copy of the array to prevent a
// malicious caller from mutating the array after this check.
// a good exception message if they are not; however we check this again inside the execution
// engine's low level allocation function after having made a copy of the array to prevent a
// malicious caller from mutating the array after this check.
for (int i = 0; i < lengths.Length; i++)
if (lengths[i] < 0)
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.lengths, i, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
Expand All @@ -117,9 +117,9 @@ public static unsafe Array CreateInstance(Type elementType, int[] lengths, int[]
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_MustBeType, ExceptionArgument.elementType);

// Check to make sure the lenghts are all positive. Note that we check this here to give
// a good exception message if they are not; however we check this again inside the execution
// engine's low level allocation function after having made a copy of the array to prevent a
// malicious caller from mutating the array after this check.
// a good exception message if they are not; however we check this again inside the execution
// engine's low level allocation function after having made a copy of the array to prevent a
// malicious caller from mutating the array after this check.
for (int i = 0; i < lengths.Length; i++)
if (lengths[i] < 0)
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.lengths, i, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
Expand Down Expand Up @@ -153,7 +153,7 @@ public static void Copy(Array sourceArray, int sourceIndex, Array destinationArr
Copy(sourceArray, sourceIndex, destinationArray, destinationIndex, length, false);
}

// Reliability-wise, this method will either possibly corrupt your
// Reliability-wise, this method will either possibly corrupt your
// instance & might fail when called from within a CER, or if the
// reliable flag is true, it will either always succeed or always
// throw an exception with no side effects.
Expand All @@ -162,7 +162,7 @@ public static void Copy(Array sourceArray, int sourceIndex, Array destinationArr

// Provides a strong exception guarantee - either it succeeds, or
// it throws an exception with no side effects. The arrays must be
// compatible array types based on the array element type - this
// compatible array types based on the array element type - this
// method does not support casting, boxing, or primitive widening.
// It will up-cast, assuming the array types are correct.
public static void ConstrainedCopy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length)
Expand Down Expand Up @@ -386,7 +386,7 @@ public extern int Rank
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern bool TrySZSort(Array keys, Array? items, int left, int right);

// if this is an array of value classes and that value class has a default constructor
// if this is an array of value classes and that value class has a default constructor
// then this calls this default constructor on every element in the value class array.
// otherwise this is a no-op. Generally this method is called automatically by the compiler
[MethodImplAttribute(MethodImplOptions.InternalCall)]
Expand All @@ -395,12 +395,12 @@ public extern int Rank

//----------------------------------------------------------------------------------------
// ! READ THIS BEFORE YOU WORK ON THIS CLASS.
//
//
// The methods on this class must be written VERY carefully to avoid introducing security holes.
// That's because they are invoked with special "this"! The "this" object
// for all of these methods are not SZArrayHelper objects. Rather, they are of type U[]
// where U[] is castable to T[]. No actual SZArrayHelper object is ever instantiated. Thus, you will
// see a lot of expressions that cast "this" "T[]".
// see a lot of expressions that cast "this" "T[]".
//
// This class is needed to allow an SZ array of type T[] to expose IList<T>,
// IList<T.BaseType>, etc., etc. all the way up to IList<Object>. When the following call is
Expand All @@ -410,7 +410,7 @@ public extern int Rank
//
// the interface stub dispatcher treats this as a special case, loads up SZArrayHelper,
// finds the corresponding generic method (matched simply by method name), instantiates
// it for type <T> and executes it.
// it for type <T> and executes it.
//
// The "T" will reflect the interface used to invoke the method. The actual runtime "this" will be
// array that is castable to "T[]" (i.e. for primitivs and valuetypes, it will be exactly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ private static Attribute[] InternalParamGetCustomAttributes(ParameterInfo param,
Debug.Assert(param != null);

// For ParameterInfo's we need to make sure that we chain through all the MethodInfo's in the inheritance chain that
// have this ParameterInfo defined. .We pick up all the CustomAttributes for the starting ParameterInfo. We need to pick up only attributes
// have this ParameterInfo defined. .We pick up all the CustomAttributes for the starting ParameterInfo. We need to pick up only attributes
// that are marked inherited from the remainder of the MethodInfo's in the inheritance chain.
// For MethodInfo's on an interface we do not do an inheritance walk so the default ParameterInfo attributes are returned.
// For MethodInfo's on a class we walk up the inheritance chain but do not look at the MethodInfo's on the interfaces that the
Expand Down Expand Up @@ -320,7 +320,7 @@ private static bool InternalParamIsDefined(ParameterInfo param, Type type, bool
Debug.Assert(type != null);

// For ParameterInfo's we need to make sure that we chain through all the MethodInfo's in the inheritance chain.
// We pick up all the CustomAttributes for the starting ParameterInfo. We need to pick up only attributes
// We pick up all the CustomAttributes for the starting ParameterInfo. We need to pick up only attributes
// that are marked inherited from the remainder of the ParameterInfo's in the inheritance chain.
// For MethodInfo's on an interface we do not do an inheritance walk. For ParameterInfo's on a
// Class we walk up the inheritance chain but do not look at the MethodInfo's on the interfaces that the class inherits from.
Expand Down Expand Up @@ -404,7 +404,7 @@ private static void AddAttributesToList(List<Attribute> attributeList, Attribute
}
else if (usage.Inherited && usage.AllowMultiple)
{
// we saw this type already add it only if it is inheritable and it does allow multiple
// we saw this type already add it only if it is inheritable and it does allow multiple
attributeList.Add(attributes[i]);
}
}
Expand Down Expand Up @@ -608,7 +608,7 @@ public static bool IsDefined(ParameterInfo element, Type attributeType, bool inh

switch (member.MemberType)
{
case MemberTypes.Method: // We need to climb up the member hierarchy
case MemberTypes.Method: // We need to climb up the member hierarchy
return InternalParamIsDefined(element, attributeType, inherit);

case MemberTypes.Constructor:
Expand Down
Loading

0 comments on commit 6ed4a5e

Please sign in to comment.