Skip to content

Enable SA1000: Spacing around keywords #112302

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

Merged
merged 11 commits into from
Feb 10, 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
3 changes: 1 addition & 2 deletions eng/CodeAnalysis.src.globalconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1139,8 +1139,7 @@ dotnet_diagnostic.RS2008.severity = warning
dotnet_diagnostic.SA0001.severity = none

# SA1000: Spacing around keywords
# suggestion until https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3478 is resolved
dotnet_diagnostic.SA1000.severity = suggestion
dotnet_diagnostic.SA1000.severity = warning

# SA1001: Commas should not be preceded by whitespace
dotnet_diagnostic.SA1001.severity = warning
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public override object ChangeType(object value, Type type, CultureInfo? cultureI
return RetObj;
}
#if DISPLAY_DEBUG_INFO
catch(NotSupportedException e)
catch (NotSupportedException e)
#else
catch (NotSupportedException)
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/tools/Common/CommandLineHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static List<string> BuildPathList(IReadOnlyList<CliToken> tokens)

public static TargetOS GetTargetOS(string token)
{
if(string.IsNullOrEmpty(token))
if (string.IsNullOrEmpty(token))
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
return TargetOS.Windows;
Expand Down Expand Up @@ -87,7 +87,7 @@ public static TargetOS GetTargetOS(string token)

public static TargetArchitecture GetTargetArchitecture(string token)
{
if(string.IsNullOrEmpty(token))
if (string.IsNullOrEmpty(token))
{
return RuntimeInformation.ProcessArchitecture switch
{
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,9 @@ IntPtr LocalObjectToHandle(object input)

bool isType = nativeSchema[index + 1].InstrumentationKind == PgoInstrumentationKind.HandleHistogramTypes;

fixed(PgoInstrumentationSchema* pSchema = &nativeSchema[index])
fixed (PgoInstrumentationSchema* pSchema = &nativeSchema[index])
{
fixed(byte* pInstrumentationData = &instrumentationData[0])
fixed (byte* pInstrumentationData = &instrumentationData[0])
{
// We're going to store only the most popular type/method to reduce size of the profile
LikelyClassMethodRecord* likelyClassMethods = stackalloc LikelyClassMethodRecord[1];
Expand Down
10 changes: 5 additions & 5 deletions src/coreclr/tools/Common/JitInterface/CorInfoInstructionSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -497,25 +497,25 @@ public void ExpandInstructionSetByImplication(TargetArchitecture architecture)

public static InstructionSet ConvertToImpliedInstructionSetForVectorInstructionSets(TargetArchitecture architecture, InstructionSet input)
{
switch(architecture)
switch (architecture)
{
case TargetArchitecture.ARM64:
switch(input)
switch (input)
{
case InstructionSet.ARM64_Vector64: return InstructionSet.ARM64_AdvSimd;
case InstructionSet.ARM64_Vector128: return InstructionSet.ARM64_AdvSimd;
}
break;
case TargetArchitecture.X64:
switch(input)
switch (input)
{
case InstructionSet.X64_Vector128: return InstructionSet.X64_SSE;
case InstructionSet.X64_Vector256: return InstructionSet.X64_AVX;
case InstructionSet.X64_Vector512: return InstructionSet.X64_AVX512F;
}
break;
case TargetArchitecture.X86:
switch(input)
switch (input)
{
case InstructionSet.X86_Vector128: return InstructionSet.X86_SSE;
case InstructionSet.X86_Vector256: return InstructionSet.X86_AVX;
Expand Down Expand Up @@ -984,7 +984,7 @@ private static InstructionSetFlags ExpandInstructionSetByReverseImplicationHelpe
do
{
oldflags = resultflags;
switch(architecture)
switch (architecture)
{

case TargetArchitecture.ARM64:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private static bool CanCastConstraint(ref ArrayBuilder<TypeDesc> instantiatedCon

public static bool CheckValidInstantiationArguments(this Instantiation instantiation)
{
foreach(var arg in instantiation)
foreach (var arg in instantiation)
{
if (arg.IsPointer || arg.IsByRef || arg.IsGenericParameter || arg.IsVoid)
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public TypeDesc GetInlineArrayType(InlineArrayCandidate candidate)

public FieldDesc GetPInvokeLazyFixupField(MethodDesc method, MethodSignature nativeSig)
{
return _pInvokeLazyFixupFieldHashtable.GetOrCreateValue(new (method, nativeSig));
return _pInvokeLazyFixupFieldHashtable.GetOrCreateValue(new(method, nativeSig));
}

public MethodDesc GetPInvokeCalliStub(MethodSignature signature, ModuleDesc moduleContext)
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/tools/SuperFileCheck/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ static async Task<int> Main(string[] args)
Console.Write(String.Join(' ', methodDeclInfos.Select(x => x.FullyQualifiedName)));
return 0;
}
catch(Exception ex)
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(ex.Message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ private void EmitDispatchMap(ref ObjectDataBuilder builder, NodeFactory factory)
if (!declMethod.Signature.IsStatic && !needsEntriesForInstanceInterfaceMethodImpls)
continue;

if(!interfaceType.IsTypeDefinition)
if (!interfaceType.IsTypeDefinition)
declMethod = factory.TypeSystemContext.GetMethodForInstantiatedType(declMethod.GetTypicalMethodDefinition(), (InstantiatedType)definitionInterfaceType);

var implMethod = declMethod.Signature.IsStatic ?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static void GetGenericVirtualMethodImplementationDependencies(ref Depende

if (!openImplementationType.IsInterface)
{
for(int index = 0; index < openImplementationType.RuntimeInterfaces.Length; index++)
for (int index = 0; index < openImplementationType.RuntimeInterfaces.Length; index++)
{
if (openImplementationType.RuntimeInterfaces[index] == callingMethod.OwningType)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static bool MethodHasAssociatedData(IMethodNode methodNode)
{
// Instantiating unboxing stubs. We need to store their non-unboxing target pointer (looked up by runtime)
ISpecialUnboxThunkNode unboxThunk = methodNode as ISpecialUnboxThunkNode;
if(unboxThunk != null && unboxThunk.IsSpecialUnboxingThunk)
if (unboxThunk != null && unboxThunk.IsSpecialUnboxingThunk)
return true;

return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public override IEnumerable<DependencyListEntry> GetStaticDependencies(NodeFacto
{
_staticDependencies = new DependencyList();

foreach(var entry in ScanForGenericVirtualMethodEntries())
foreach (var entry in ScanForGenericVirtualMethodEntries())
GenericVirtualMethodTableNode.GetGenericVirtualMethodImplementationDependencies(ref _staticDependencies, context, entry.CallingMethod, entry.ImplementationMethod);

foreach (var entry in ScanForInterfaceGenericVirtualMethodEntries())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void EmitExportedMethods()
foreach (var method in _methods)
streamWriter.WriteLine($" {method.GetUnmanagedCallersOnlyExportName()}");
}
else if(_context.Target.IsApplePlatform)
else if (_context.Target.IsApplePlatform)
{
foreach (string symbol in _exportSymbols)
streamWriter.WriteLine($"_{symbol}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false)
bucketCount *= 2;
}
}
while(tryAgainWithBiggerTable && ((countOfRetries++) < 2));
while (tryAgainWithBiggerTable && ((countOfRetries++) < 2));

byte[] result;
if (tryAgainWithBiggerTable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ protected override MethodDesc ResolveVirtualMethod(MethodDesc declMethod, DefTyp
if (!implType.IsObject)
{
TypeDesc typeThatDerivesFromObject = implType;
while(!typeThatDerivesFromObject.BaseType.IsObject)
while (!typeThatDerivesFromObject.BaseType.IsObject)
{
typeThatDerivesFromObject = typeThatDerivesFromObject.BaseType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private EmptyProfileData()
{
}

public override MibcConfig Config { get; } = new ();
public override MibcConfig Config { get; } = new();

public override bool PartialNGen => false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ void CompileMethodList(IEnumerable<DependencyNodeCore<NodeFactory>> methodList)

void CompilationThread(object objThreadId)
{
while(true)
while (true)
{
_compilationThreadSemaphore.Wait();
lock(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public struct PInvokeILEmitter
private readonly MethodDesc _targetMethod;
private readonly Marshaller[] _marshallers;
private readonly PInvokeMetadata _importMetadata;
private static readonly ConditionalWeakTable<TypeSystemContext, ConcurrentDictionary<MethodDesc, PInvokeTargetNativeMethod>> s_contexts = new ();
private static readonly ConditionalWeakTable<TypeSystemContext, ConcurrentDictionary<MethodDesc, PInvokeTargetNativeMethod>> s_contexts = new();

private PInvokeILEmitter(MethodDesc targetMethod)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ TypeDesc HandleContext(IEcmaModule module, EntityHandle handle, TypeDesc methodT
{
derivesFromTypeDefinition = currentType.GetTypeDefinition() == tokenOnlyOwningType;
currentType = currentType.BaseType;
} while(currentType != null && !derivesFromTypeDefinition);
} while (currentType != null && !derivesFromTypeDefinition);

if (derivesFromTypeDefinition)
{
Expand Down Expand Up @@ -311,7 +311,7 @@ public override bool Equals(object obj)

public override int GetHashCode()
{
return Method.GetHashCode() ^ unchecked(17 * Token.GetHashCode()) ^ unchecked (39 * (ConstrainedType?.GetHashCode() ?? 0));
return Method.GetHashCode() ^ unchecked(17 * Token.GetHashCode()) ^ unchecked(39 * (ConstrainedType?.GetHashCode() ?? 0));
}

public bool Equals(MethodWithToken methodWithToken)
Expand Down Expand Up @@ -2113,7 +2113,7 @@ private void ceeInfoGetCallInfo(
// of shared generic code calling a shared generic implementation method, which should be rare.
//
// An alternative design would be to add a new generic dictionary entry kind to hold the MethodDesc
// of the constrained target instead, and use that in some circumstances; however, implementation of
// of the constrained target instead, and use that in some circumstances; however, implementation of
// that design requires refactoring variuos parts of the JIT interface as well as
// TryResolveConstraintMethodApprox. In particular we would need to be abled to embed a constrained lookup
// via EmbedGenericHandle, as well as decide in TryResolveConstraintMethodApprox if the call can be made
Expand Down Expand Up @@ -3152,7 +3152,7 @@ private void setEHinfo(uint EHnumber, ref CORINFO_EH_CLAUSE clause)

// Currently, the only place we are using a token here is for a COM-to-CLR exception-to-HRESULT
// mapping catch clause. We want this catch clause to catch all exceptions, so we override the
// token to be mdTypeRefNil, which used by the EH system to mean catch(...)
// token to be mdTypeRefNil, which used by the EH system to mean catch (...)
Debug.Assert(clauseType.IsObject);
clause.ClassTokenOrOffset = 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public override string ToString()
sb.Append($" LowBits: ");
if ((Flags & GcSlotFlags.GC_SLOT_UNTRACKED) != 0)
{
if((LowBits & pinned_OFFSET_FLAG) != 0) sb.Append("pinned ");
if ((LowBits & pinned_OFFSET_FLAG) != 0) sb.Append("pinned ");
if ((LowBits & byref_OFFSET_FLAG) != 0) sb.Append("byref ");
}
sb.AppendLine();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@ private IEnumerable<string> VerifyExportedTypes (AssemblyDefinition original, As
protected virtual IEnumerable<string> VerifyPseudoAttributes (MethodDefinition src, MethodDefinition linked)
{
var expected = (MethodAttributes) GetExpectedPseudoAttributeValue (src, (uint) src.Attributes);
if(!linked.Attributes.Equals(expected))
if (!linked.Attributes.Equals(expected))
{
yield return $"Method `{src}' pseudo attributes did not match expected";
}
Expand All @@ -1038,7 +1038,7 @@ protected virtual IEnumerable<string> VerifyPseudoAttributes (TypeDefinition src
{
var expected = (TypeAttributes) GetExpectedPseudoAttributeValue (src, (uint) src.Attributes);

if(!linked.Attributes.Equals(expected))
if (!linked.Attributes.Equals(expected))
{
yield return $"Type `{src}' pseudo attributes did not match expected";
}
Expand All @@ -1047,7 +1047,7 @@ protected virtual IEnumerable<string> VerifyPseudoAttributes (TypeDefinition src
protected virtual IEnumerable<string> VerifyPseudoAttributes (FieldDefinition src, FieldDefinition linked)
{
var expected = (FieldAttributes) GetExpectedPseudoAttributeValue (src, (uint) src.Attributes);
if(!linked.Attributes.Equals(expected))
if (!linked.Attributes.Equals(expected))
{
yield return $"Field `{src}' pseudo attributes did not match expected";
}
Expand All @@ -1056,7 +1056,7 @@ protected virtual IEnumerable<string> VerifyPseudoAttributes (FieldDefinition sr
protected virtual IEnumerable<string> VerifyPseudoAttributes (PropertyDefinition src, PropertyDefinition linked)
{
var expected = (PropertyAttributes) GetExpectedPseudoAttributeValue (src, (uint) src.Attributes);
if(!linked.Attributes.Equals(expected))
if (!linked.Attributes.Equals(expected))
{
yield return $"Property `{src}' pseudo attributes did not match expected";
}
Expand All @@ -1066,7 +1066,7 @@ protected virtual IEnumerable<string> VerifyPseudoAttributes (PropertyDefinition
protected virtual IEnumerable<string> VerifyPseudoAttributes (EventDefinition src, EventDefinition linked)
{
var expected = (EventAttributes) GetExpectedPseudoAttributeValue (src, (uint) src.Attributes);
if(!linked.Attributes.Equals(expected))
if (!linked.Attributes.Equals(expected))
{
yield return $"Event `{src}' pseudo attributes did not match expected";
}
Expand All @@ -1077,7 +1077,7 @@ protected virtual IEnumerable<string> VerifyCustomAttributes (ICustomAttributePr
var expectedAttrs = GetExpectedAttributes (src).ToList ();
var linkedAttrs = FilterLinkedAttributes (linked).ToList ();

if(!linkedAttrs.SequenceEqual(expectedAttrs))
if (!linkedAttrs.SequenceEqual(expectedAttrs))
{
yield return $"Custom attributes on `{src}' are not matching";
}
Expand All @@ -1091,7 +1091,7 @@ protected virtual IEnumerable<string> VerifySecurityAttributes (ICustomAttribute

var linkedAttrs = FilterLinkedSecurityAttributes (linked).ToList ();

if(!linkedAttrs.SequenceEqual(expectedAttrs))
if (!linkedAttrs.SequenceEqual(expectedAttrs))
{
yield return $"Security attributes on `{src}' are not matching";
}
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/tools/cdac-build-tool/ComposeCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal sealed class ComposeCommand : CliCommand
private readonly CliOption<string> outputFile = new("-o") { Arity = ArgumentArity.ExactlyOne, HelpName = "OUTPUT", Required = true, Description = "Output file" };
private readonly CliOption<string[]> contractFile = new("-c") { Arity = ArgumentArity.ZeroOrMore, HelpName = "CONTRACT", Description = "Contract file (may be specified multiple times)" };
private readonly CliOption<string> baselinePath = new("-b", "--baseline") { Arity = ArgumentArity.ExactlyOne, HelpName = "BASELINEPATH", Description = "Directory containing the baseline contracts"};
private readonly CliOption<string> templateFile = new ("-i", "--input-template") { Arity = ArgumentArity.ExactlyOne, HelpName = "TEMPLATE", Description = "Contract descriptor template to be filled in" };
private readonly CliOption<string> templateFile = new("-i", "--input-template") { Arity = ArgumentArity.ExactlyOne, HelpName = "TEMPLATE", Description = "Contract descriptor template to be filled in" };
private readonly CliOption<bool> _verboseOption;
public ComposeCommand(CliOption<bool> verboseOption) : base("compose")
{
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/tools/cdac-build-tool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class Program
{
public static async Task<int> Main(string[] args)
{
CliRootCommand rootCommand = new ();
CliRootCommand rootCommand = new();
var verboseOption = new CliOption<bool>("-v", "--verbose") {Recursive = true, Description = "Verbose"};
rootCommand.Add(verboseOption);
rootCommand.Add(new DiagramDirective());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public readonly void Validate(int bufferSize)
ByteLength > bufferSize ||
NameOffset < 0 ||
NameLength < 0 ||
checked (NameOffset + NameLength) > ByteLength)
checked(NameOffset + NameLength) > ByteLength)
{
ThrowInvalidOperationException(typeof(PERF_INSTANCE_DEFINITION));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ public void Refresh()
// Lastly complete any changes added to the atomicComposition during the change event
atomicComposition.Complete();

// Break out of the while(true)
// Break out of the while (true)
break;
} // WriteLock
} // AtomicComposition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1545,7 +1545,7 @@ private void UpdateRowExecute(RowUpdatedEventArgs rowUpdatedEvent, IDbCommand da
}
finally
{
// using Close which can optimize its { while(dataReader.NextResult()); } loop
// using Close which can optimize its { while (dataReader.NextResult()); } loop
dataReader.Close();

// RecordsAffected is available after Close, but don't trust it after Dispose
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ IEnumerator IEnumerable.GetEnumerator()
/// ManagementObjectCollection disks = diskClass.GetInstances();
/// ManagementObjectCollection.ManagementObjectEnumerator disksEnumerator =
/// disks.GetEnumerator();
/// while(disksEnumerator.MoveNext()) {
/// while (disksEnumerator.MoveNext()) {
/// ManagementObject disk = (ManagementObject)disksEnumerator.Current;
/// Console.WriteLine("Disk found: " + disk["deviceid"]);
/// }
Expand Down
Loading
Loading