diff --git a/eng/CodeAnalysis.src.globalconfig b/eng/CodeAnalysis.src.globalconfig index 21a53462cc5de3..a6859cfe01a142 100644 --- a/eng/CodeAnalysis.src.globalconfig +++ b/eng/CodeAnalysis.src.globalconfig @@ -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 diff --git a/src/coreclr/System.Private.CoreLib/src/System/OleAutBinder.cs b/src/coreclr/System.Private.CoreLib/src/System/OleAutBinder.cs index c52520e9c68f9d..258a1a6632c734 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/OleAutBinder.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/OleAutBinder.cs @@ -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 diff --git a/src/coreclr/tools/Common/CommandLineHelpers.cs b/src/coreclr/tools/Common/CommandLineHelpers.cs index 26d59f72d02b37..7f93e48a8949f6 100644 --- a/src/coreclr/tools/Common/CommandLineHelpers.cs +++ b/src/coreclr/tools/Common/CommandLineHelpers.cs @@ -56,7 +56,7 @@ public static List BuildPathList(IReadOnlyList tokens) public static TargetOS GetTargetOS(string token) { - if(string.IsNullOrEmpty(token)) + if (string.IsNullOrEmpty(token)) { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) return TargetOS.Windows; @@ -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 { diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs index c635b416708be2..70dde2b702ea3b 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs @@ -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]; diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoInstructionSet.cs b/src/coreclr/tools/Common/JitInterface/CorInfoInstructionSet.cs index e4f67b4070fe42..7752d65befc82c 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoInstructionSet.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoInstructionSet.cs @@ -497,17 +497,17 @@ 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; @@ -515,7 +515,7 @@ public static InstructionSet ConvertToImpliedInstructionSetForVectorInstructionS } break; case TargetArchitecture.X86: - switch(input) + switch (input) { case InstructionSet.X86_Vector128: return InstructionSet.X86_SSE; case InstructionSet.X86_Vector256: return InstructionSet.X86_AVX; @@ -984,7 +984,7 @@ private static InstructionSetFlags ExpandInstructionSetByReverseImplicationHelpe do { oldflags = resultflags; - switch(architecture) + switch (architecture) { case TargetArchitecture.ARM64: diff --git a/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemConstraintsHelpers.cs b/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemConstraintsHelpers.cs index 97bceb5b1b8362..67690ee960073b 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemConstraintsHelpers.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemConstraintsHelpers.cs @@ -162,7 +162,7 @@ private static bool CanCastConstraint(ref ArrayBuilder 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; diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/InteropStateManager.cs b/src/coreclr/tools/Common/TypeSystem/Interop/InteropStateManager.cs index 7147f65cbb681f..a7fe823d3df95d 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/InteropStateManager.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/InteropStateManager.cs @@ -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) diff --git a/src/coreclr/tools/SuperFileCheck/Program.cs b/src/coreclr/tools/SuperFileCheck/Program.cs index 540f1df989d8aa..b7803582051c4f 100644 --- a/src/coreclr/tools/SuperFileCheck/Program.cs +++ b/src/coreclr/tools/SuperFileCheck/Program.cs @@ -660,7 +660,7 @@ static async Task 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); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InterfaceDispatchMapNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InterfaceDispatchMapNode.cs index 8b1a535fdfca58..d87edb86db983f 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InterfaceDispatchMapNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InterfaceDispatchMapNode.cs @@ -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 ? diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InterfaceGenericVirtualMethodTableNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InterfaceGenericVirtualMethodTableNode.cs index 86d61a8f86f67e..8815fea96e9b56 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InterfaceGenericVirtualMethodTableNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InterfaceGenericVirtualMethodTableNode.cs @@ -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) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/MethodAssociatedDataNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/MethodAssociatedDataNode.cs index 17e61805721ea2..24f84ba902eef1 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/MethodAssociatedDataNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/MethodAssociatedDataNode.cs @@ -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; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TypeGVMEntriesNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TypeGVMEntriesNode.cs index 1ed3a086cb1a99..b5bb5760b5e29f 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TypeGVMEntriesNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TypeGVMEntriesNode.cs @@ -65,7 +65,7 @@ public override IEnumerable 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()) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ExportsFileWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ExportsFileWriter.cs index 49fc928c06eb93..f4645566fa52b8 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ExportsFileWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ExportsFileWriter.cs @@ -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}"); diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/AttributePresenceFilterNode.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/AttributePresenceFilterNode.cs index 2629c3960594b4..d12d18c4c0afa1 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/AttributePresenceFilterNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/AttributePresenceFilterNode.cs @@ -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) diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/DevirtualizationManager.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/DevirtualizationManager.cs index f6522b1492bd59..7d0275ff2eaaee 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/DevirtualizationManager.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/DevirtualizationManager.cs @@ -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; } diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ProfileData.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ProfileData.cs index 54d0c1968ea8f4..0cf6a8cb727638 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ProfileData.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ProfileData.cs @@ -126,7 +126,7 @@ private EmptyProfileData() { } - public override MibcConfig Config { get; } = new (); + public override MibcConfig Config { get; } = new(); public override bool PartialNGen => false; diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilation.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilation.cs index e1803a3f5d7931..6f7585c07e3ab8 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilation.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilation.cs @@ -801,7 +801,7 @@ void CompileMethodList(IEnumerable> methodList) void CompilationThread(object objThreadId) { - while(true) + while (true) { _compilationThreadSemaphore.Wait(); lock(this) diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IL/Stubs/PInvokeILEmitter.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IL/Stubs/PInvokeILEmitter.cs index b083e3ecc2d53f..ed05deb5f23581 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IL/Stubs/PInvokeILEmitter.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IL/Stubs/PInvokeILEmitter.cs @@ -24,7 +24,7 @@ public struct PInvokeILEmitter private readonly MethodDesc _targetMethod; private readonly Marshaller[] _marshallers; private readonly PInvokeMetadata _importMetadata; - private static readonly ConditionalWeakTable> s_contexts = new (); + private static readonly ConditionalWeakTable> s_contexts = new(); private PInvokeILEmitter(MethodDesc targetMethod) { diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs index 7cc3343a56d416..f58775b559198c 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs @@ -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) { @@ -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) @@ -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 @@ -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; } diff --git a/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/x86/GcSlotTable.cs b/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/x86/GcSlotTable.cs index 3c670f7d0f5a4f..534780b671834f 100644 --- a/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/x86/GcSlotTable.cs +++ b/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/x86/GcSlotTable.cs @@ -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(); diff --git a/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/AssemblyChecker.cs b/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/AssemblyChecker.cs index c62434f172dd2f..2f89b128c32ebe 100644 --- a/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/AssemblyChecker.cs +++ b/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/AssemblyChecker.cs @@ -1028,7 +1028,7 @@ private IEnumerable VerifyExportedTypes (AssemblyDefinition original, As protected virtual IEnumerable 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"; } @@ -1038,7 +1038,7 @@ protected virtual IEnumerable 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"; } @@ -1047,7 +1047,7 @@ protected virtual IEnumerable VerifyPseudoAttributes (TypeDefinition src protected virtual IEnumerable 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"; } @@ -1056,7 +1056,7 @@ protected virtual IEnumerable VerifyPseudoAttributes (FieldDefinition sr protected virtual IEnumerable 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"; } @@ -1066,7 +1066,7 @@ protected virtual IEnumerable VerifyPseudoAttributes (PropertyDefinition protected virtual IEnumerable 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"; } @@ -1077,7 +1077,7 @@ protected virtual IEnumerable 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"; } @@ -1091,7 +1091,7 @@ protected virtual IEnumerable VerifySecurityAttributes (ICustomAttribute var linkedAttrs = FilterLinkedSecurityAttributes (linked).ToList (); - if(!linkedAttrs.SequenceEqual(expectedAttrs)) + if (!linkedAttrs.SequenceEqual(expectedAttrs)) { yield return $"Security attributes on `{src}' are not matching"; } diff --git a/src/coreclr/tools/cdac-build-tool/ComposeCommand.cs b/src/coreclr/tools/cdac-build-tool/ComposeCommand.cs index 7305bcd08808c4..adb3675695941a 100644 --- a/src/coreclr/tools/cdac-build-tool/ComposeCommand.cs +++ b/src/coreclr/tools/cdac-build-tool/ComposeCommand.cs @@ -14,7 +14,7 @@ internal sealed class ComposeCommand : CliCommand private readonly CliOption outputFile = new("-o") { Arity = ArgumentArity.ExactlyOne, HelpName = "OUTPUT", Required = true, Description = "Output file" }; private readonly CliOption contractFile = new("-c") { Arity = ArgumentArity.ZeroOrMore, HelpName = "CONTRACT", Description = "Contract file (may be specified multiple times)" }; private readonly CliOption baselinePath = new("-b", "--baseline") { Arity = ArgumentArity.ExactlyOne, HelpName = "BASELINEPATH", Description = "Directory containing the baseline contracts"}; - private readonly CliOption templateFile = new ("-i", "--input-template") { Arity = ArgumentArity.ExactlyOne, HelpName = "TEMPLATE", Description = "Contract descriptor template to be filled in" }; + private readonly CliOption templateFile = new("-i", "--input-template") { Arity = ArgumentArity.ExactlyOne, HelpName = "TEMPLATE", Description = "Contract descriptor template to be filled in" }; private readonly CliOption _verboseOption; public ComposeCommand(CliOption verboseOption) : base("compose") { diff --git a/src/coreclr/tools/cdac-build-tool/Program.cs b/src/coreclr/tools/cdac-build-tool/Program.cs index 132c13d30fa119..bf86ebec0db4cd 100644 --- a/src/coreclr/tools/cdac-build-tool/Program.cs +++ b/src/coreclr/tools/cdac-build-tool/Program.cs @@ -10,7 +10,7 @@ public class Program { public static async Task Main(string[] args) { - CliRootCommand rootCommand = new (); + CliRootCommand rootCommand = new(); var verboseOption = new CliOption("-v", "--verbose") {Recursive = true, Description = "Verbose"}; rootCommand.Add(verboseOption); rootCommand.Add(new DiagramDirective()); diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.PERF_INFO.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.PERF_INFO.cs index a5436fbe0f22c3..90ccd89cc201a1 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.PERF_INFO.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.PERF_INFO.cs @@ -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)); } diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/DirectoryCatalog.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/DirectoryCatalog.cs index 75744ec2c1d30c..5c8490fc96cb0c 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/DirectoryCatalog.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/DirectoryCatalog.cs @@ -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 diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/DbDataAdapter.cs b/src/libraries/System.Data.Common/src/System/Data/Common/DbDataAdapter.cs index 74ddb68a640d17..fe94ac1455ddee 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/DbDataAdapter.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/DbDataAdapter.cs @@ -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 diff --git a/src/libraries/System.Management/src/System/Management/ManagementObjectCollection.cs b/src/libraries/System.Management/src/System/Management/ManagementObjectCollection.cs index b6006925a02c5c..cffcbcd103cde0 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementObjectCollection.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementObjectCollection.cs @@ -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"]); /// } diff --git a/src/libraries/System.Management/src/System/Management/MethodSet.cs b/src/libraries/System.Management/src/System/Management/MethodSet.cs index a87b28f46168fc..a6f5b36e2157e2 100644 --- a/src/libraries/System.Management/src/System/Management/MethodSet.cs +++ b/src/libraries/System.Management/src/System/Management/MethodSet.cs @@ -207,7 +207,7 @@ public MethodDataEnumerator GetEnumerator() /// ManagementClass diskClass = new ManagementClass("win32_logicaldisk"); /// MethodDataCollection.MethodDataEnumerator diskEnumerator = /// diskClass.Methods.GetEnumerator(); - /// while(diskEnumerator.MoveNext()) + /// while (diskEnumerator.MoveNext()) /// { /// MethodData method = diskEnumerator.Current; /// Console.WriteLine("Method = " + method.Name); diff --git a/src/libraries/System.Management/src/System/Management/PropertySet.cs b/src/libraries/System.Management/src/System/Management/PropertySet.cs index dbc3dc6ec88101..a4ca50720bea9e 100644 --- a/src/libraries/System.Management/src/System/Management/PropertySet.cs +++ b/src/libraries/System.Management/src/System/Management/PropertySet.cs @@ -214,7 +214,7 @@ public PropertyDataEnumerator GetEnumerator() /// public static int Main(string[] args) { /// ManagementObject disk = new ManagementObject("Win32_LogicalDisk.DeviceID='C:'"); /// PropertyDataCollection.PropertyDataEnumerator propertyEnumerator = disk.Properties.GetEnumerator(); - /// while(propertyEnumerator.MoveNext()) { + /// while (propertyEnumerator.MoveNext()) { /// PropertyData p = (PropertyData)propertyEnumerator.Current; /// Console.WriteLine("Property found: " + p.Name); /// } diff --git a/src/libraries/System.Management/src/System/Management/QualifierSet.cs b/src/libraries/System.Management/src/System/Management/QualifierSet.cs index a25f73559c3a79..190ce17ed2ba07 100644 --- a/src/libraries/System.Management/src/System/Management/QualifierSet.cs +++ b/src/libraries/System.Management/src/System/Management/QualifierSet.cs @@ -268,7 +268,7 @@ public QualifierDataEnumerator GetEnumerator() /// QualifierDataCollection diskQualifier = diskClass.Qualifiers; /// QualifierDataCollection.QualifierDataEnumerator /// qualifierEnumerator = diskQualifier.GetEnumerator(); - /// while(qualifierEnumerator.MoveNext()) { + /// while (qualifierEnumerator.MoveNext()) { /// Console.WriteLine(qualifierEnumerator.Current.Name + " = " + /// qualifierEnumerator.Current.Value); /// } diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/BrowserHttpHandler.cs b/src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/BrowserHttpHandler.cs index 6b74d5d9cafed8..32d6c10206df95 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/BrowserHttpHandler.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/BrowserHttpHandler.cs @@ -254,7 +254,7 @@ public async Task CallFetch() var closePromise = BrowserHttpInterop.TransformStreamClose(_jsController); await BrowserHttpInterop.CancellationHelper(closePromise, _cancellationToken, _jsController).ConfigureAwait(false); } - catch(JSException jse) when (jse.Message.Contains("BrowserHttpWriteStream.Rejected", StringComparison.Ordinal)) + catch (JSException jse) when (jse.Message.Contains("BrowserHttpWriteStream.Rejected", StringComparison.Ordinal)) { // any error from pushing bytes will also appear in the fetch promise result } diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttp.cs b/src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttp.cs index f527ad573b8f5d..3d63d27d73d9cf 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttp.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttp.cs @@ -69,7 +69,7 @@ internal Err AsErr } internal class Option { - private static Option none = new (); + private static Option none = new(); private Option() { diff --git a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketPal.Unix.cs b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketPal.Unix.cs index 88ee436cb8199e..bb961252205f8b 100644 --- a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketPal.Unix.cs +++ b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketPal.Unix.cs @@ -1073,7 +1073,7 @@ public static bool TryCompleteSendFile(SafeSocketHandle socket, SafeFileHandle h public static SocketError SetBlocking(SafeSocketHandle handle, bool shouldBlock, out bool willBlock) { - if(OperatingSystem.IsWasi() && shouldBlock) throw new PlatformNotSupportedException(); + if (OperatingSystem.IsWasi() && shouldBlock) throw new PlatformNotSupportedException(); handle.IsNonBlocking = !shouldBlock; willBlock = shouldBlock; diff --git a/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/BrowserWebSockets/BrowserWebSocket.cs b/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/BrowserWebSockets/BrowserWebSocket.cs index d21e80ba41fee5..f34c8ee6db72a0 100644 --- a/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/BrowserWebSockets/BrowserWebSocket.cs +++ b/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/BrowserWebSockets/BrowserWebSocket.cs @@ -588,7 +588,7 @@ private async Task CancellationHelper(Task promise, CancellationToken cancellati } if (ex is OperationCanceledException || cancellationToken.IsCancellationRequested || ex.Message == "Error: OperationCanceledException") { - if(state != WebSocketState.Closed) + if (state != WebSocketState.Closed) { FastState = WebSocketState.Aborted; } diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorSpan.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorSpan.cs index dcfeb47f9aab01..a71eaebac3822a 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorSpan.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorSpan.cs @@ -704,7 +704,7 @@ public TensorSpan Slice(params scoped ReadOnlySpan indexes) internal TensorSpan Slice(params scoped ReadOnlySpan lengths) { NRange[] ranges = new NRange[lengths.Length]; - for(int i = 0; i < lengths.Length; i++) + for (int i = 0; i < lengths.Length; i++) { ranges[i] = new NRange(0, lengths[i]); } diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs index b234e6d96ea3ed..24a3a4485b7ebd 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs @@ -1672,7 +1672,7 @@ private unsafe void Initialize(Guid eventSourceGuid, string eventSourceName, str // Register the provider with ETW Func eventSourceFactory = () => this; OverrideEventProvider? etwProvider = EventSourceInitHelper.TryGetPreregisteredEtwProvider(eventSourceGuid); - if(etwProvider == null) + if (etwProvider == null) { etwProvider = new OverrideEventProvider(eventSourceFactory, EventProviderType.ETW); etwProvider.Register(eventSourceGuid, eventSourceName); @@ -3879,7 +3879,7 @@ private bool SelfDescribingEvents #endif internal static void InitializeDefaultEventSources() { - if(!EventSource.IsSupported) + if (!EventSource.IsSupported) { return; } diff --git a/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.ByteMemOps.cs b/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.ByteMemOps.cs index 1b465c66590efb..de4b6e97e427dd 100644 --- a/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.ByteMemOps.cs +++ b/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.ByteMemOps.cs @@ -438,7 +438,7 @@ internal static void Fill(ref byte dest, byte value, nuint len) if (len >= (nuint)Vector.Count) { // We have enough data for at least one vectorized write. - Vector vector = new (value); + Vector vector = new(value); nuint stopLoopAtOffset = len & (nuint)(nint)(2 * (int)-Vector.Count); // intentional sign extension carries the negative bit nuint offset = 0; diff --git a/src/libraries/System.Private.CoreLib/src/System/String.cs b/src/libraries/System.Private.CoreLib/src/System/String.cs index b9a3a22130141d..01564cb1cb7aa6 100644 --- a/src/libraries/System.Private.CoreLib/src/System/String.cs +++ b/src/libraries/System.Private.CoreLib/src/System/String.cs @@ -739,7 +739,7 @@ public char this[int index] // // This is an intrinsic function so that the JIT can recognise it specially // and eliminate checks on character fetches in a loop like: - // for(int i = 0; i < str.Length; i++) str[i] + // for (int i = 0; i < str.Length; i++) str[i] // The actual code generated for this will be one instruction and will be inlined. // public int Length diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/Inference/Infer.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/Inference/Infer.cs index dfc8b6fe880df8..a08ac218adaa15 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/Inference/Infer.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/Inference/Infer.cs @@ -181,7 +181,7 @@ internal XmlSchemaSet InferSchema1(XmlReader instanceDocument, XmlSchemaSet sche schemas.Compile(); _schemaSet = schemas; //schemas = new Hashtable(); - //while(xtr.Read()) + //while (xtr.Read()) while (_xtr.NodeType != XmlNodeType.Element && _xtr.Read()) ; diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationReaderILGen.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationReaderILGen.cs index b81299df890b12..a017539611908c 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationReaderILGen.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationReaderILGen.cs @@ -2949,14 +2949,14 @@ private void WriteArray(string source, string? arrayName, ArrayMapping arrayMapp if (isNullable) { - ilg.ExitScope(); // if(!ReadNull()) { ExitScope + ilg.ExitScope(); // if (!ReadNull()) { ExitScope ilg.Else(); // } else { EnterScope ilg.EnterScope(); member.IsNullable = true; WriteMemberBegin(members); WriteMemberEnd(members); } - ilg.ExitScope(); // if(!ReadNull())/else ExitScope + ilg.ExitScope(); // if (!ReadNull())/else ExitScope ilg.EndIf(); } diff --git a/src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/ILGeneratorImpl.cs b/src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/ILGeneratorImpl.cs index 1ac507c16ee8b8..82416e72599516 100644 --- a/src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/ILGeneratorImpl.cs +++ b/src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/ILGeneratorImpl.cs @@ -57,7 +57,7 @@ internal ILGeneratorImpl(MethodBuilderImpl methodBuilder, int size) internal void AddExceptionBlocks() { - foreach(ExceptionHandlerInfo eb in _exceptionBlocks) + foreach (ExceptionHandlerInfo eb in _exceptionBlocks) { switch (eb.Kind) { diff --git a/src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/TypeBuilderImpl.cs b/src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/TypeBuilderImpl.cs index 2ca4e426be999e..cad80467440521 100644 --- a/src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/TypeBuilderImpl.cs +++ b/src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/TypeBuilderImpl.cs @@ -993,7 +993,7 @@ public override Type[] GetInterfaces() List interfaces = _interfaces ?? []; - if(_typeParent != null) + if (_typeParent != null) { interfaces.AddRange(_typeParent.GetInterfaces()); } diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Marshaling/JSMarshalerArgument.Task.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Marshaling/JSMarshalerArgument.Task.cs index 569b8318dbba3e..75da6680a5f449 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Marshaling/JSMarshalerArgument.Task.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Marshaling/JSMarshalerArgument.Task.cs @@ -134,7 +134,7 @@ public unsafe void ToManaged(out Task? value, ArgumentToManagedCallback else { marshaler(ref arg_3, out T result); - if(!tcs.TrySetResult(result)) + if (!tcs.TrySetResult(result)) { Environment.FailFast("Failed to set result to TaskCompletionSource (marshaler type is none)"); } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Utils/SyntaxFactoryExtensions.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Utils/SyntaxFactoryExtensions.cs index 81f316e8c452b5..bb0d13c1906809 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Utils/SyntaxFactoryExtensions.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Utils/SyntaxFactoryExtensions.cs @@ -107,13 +107,13 @@ public static ExpressionStatementSyntax AssignmentStatement(ExpressionSyntax lef /// /// Returns a for loop with no body: /// - /// for(int ; < ; ++) + /// for (int ; < ; ++) /// ; /// /// public static ForStatementSyntax ForLoop(string indexerIdentifier, ExpressionSyntax lengthExpression) { - // for(int = 0; < ; ++) + // for (int = 0; < ; ++) // ; return ForStatement(EmptyStatement()) .WithDeclaration( diff --git a/src/mono/browser/debugger/BrowserDebugProxy/DevToolsHelper.cs b/src/mono/browser/debugger/BrowserDebugProxy/DevToolsHelper.cs index 99a4185c5c3162..1c258588ef873f 100644 --- a/src/mono/browser/debugger/BrowserDebugProxy/DevToolsHelper.cs +++ b/src/mono/browser/debugger/BrowserDebugProxy/DevToolsHelper.cs @@ -518,7 +518,7 @@ public PerScopeCache() internal sealed class ConcurrentExecutionContextDictionary { - private ConcurrentDictionary> contexts = new (); + private ConcurrentDictionary> contexts = new(); public ExecutionContext GetCurrentContext(SessionId sessionId) => TryGetCurrentExecutionContextValue(sessionId, out ExecutionContext context) ? context diff --git a/src/mono/browser/debugger/BrowserDebugProxy/EvaluateExpression.cs b/src/mono/browser/debugger/BrowserDebugProxy/EvaluateExpression.cs index fc35a907385754..1f00048cf2548a 100644 --- a/src/mono/browser/debugger/BrowserDebugProxy/EvaluateExpression.cs +++ b/src/mono/browser/debugger/BrowserDebugProxy/EvaluateExpression.cs @@ -53,7 +53,7 @@ private sealed partial class ExpressionSyntaxReplacer : CSharpSyntaxWalker public bool hasMethodCalls; public bool hasElementAccesses; public bool hasStringExpressionStatement; - internal List variableDefinitions = new (); + internal List variableDefinitions = new(); public void VisitInternal(SyntaxNode node) { @@ -227,7 +227,7 @@ void AddLocalVariableWithValue(string idName, JObject value) if (localsSet.Contains(idName)) return; localsSet.Add(idName); - variableDefinitions.Add(new (idName, value, ConvertJSToCSharpLocalVariableAssignment(idName, value))); + variableDefinitions.Add(new(idName, value, ConvertJSToCSharpLocalVariableAssignment(idName, value))); } } } diff --git a/src/mono/browser/debugger/BrowserDebugProxy/MemberReferenceResolver.cs b/src/mono/browser/debugger/BrowserDebugProxy/MemberReferenceResolver.cs index 0498dd07cfd6fb..9798fd400d06d3 100644 --- a/src/mono/browser/debugger/BrowserDebugProxy/MemberReferenceResolver.cs +++ b/src/mono/browser/debugger/BrowserDebugProxy/MemberReferenceResolver.cs @@ -434,7 +434,7 @@ public async Task Resolve( if (!isMultidimensional && type == "string") { var eaExpressionFormatted = elementAccessStrExpression.Replace('.', '_'); // instance_str - variableDefinitions.Add(new (eaExpressionFormatted, rootObject, ExpressionEvaluator.ConvertJSToCSharpLocalVariableAssignment(eaExpressionFormatted, rootObject))); + variableDefinitions.Add(new(eaExpressionFormatted, rootObject, ExpressionEvaluator.ConvertJSToCSharpLocalVariableAssignment(eaExpressionFormatted, rootObject))); var eaFormatted = elementAccessStr.Replace('.', '_'); // instance_str[1] var variableDef = await ExpressionEvaluator.GetVariableDefinitions(this, variableDefinitions, invokeToStringInObject: false, token); return await ExpressionEvaluator.EvaluateSimpleExpression(this, eaFormatted, elementAccessStr, variableDef, logger, token); diff --git a/src/mono/browser/debugger/BrowserDebugProxy/MonoProxy.cs b/src/mono/browser/debugger/BrowserDebugProxy/MonoProxy.cs index 6437b97217fc82..08d34d0e35d93a 100644 --- a/src/mono/browser/debugger/BrowserDebugProxy/MonoProxy.cs +++ b/src/mono/browser/debugger/BrowserDebugProxy/MonoProxy.cs @@ -25,7 +25,7 @@ internal class MonoProxy : DevToolsProxy internal string CachePathSymbolServer { get; private set; } private readonly HashSet sessions = new HashSet(); private static readonly string[] s_executionContextIndependentCDPCommandNames = { "DotnetDebugger.setDebuggerProperty", "DotnetDebugger.runTests" }; - internal ConcurrentExecutionContextDictionary Contexts = new (); + internal ConcurrentExecutionContextDictionary Contexts = new(); public static HttpClient HttpClient => new HttpClient(); @@ -1468,7 +1468,7 @@ private Result AddCallStackInfoToException(Result _error, ExecutionContext conte { try { var retStackTrace = new JArray(); - foreach(var call in context.CallStack) + foreach (var call in context.CallStack) { if (call.Id < scopeId) continue; diff --git a/src/mono/browser/debugger/BrowserDebugProxy/MonoSDBHelper.cs b/src/mono/browser/debugger/BrowserDebugProxy/MonoSDBHelper.cs index e8e8b7916e9817..f249812a39bb0c 100644 --- a/src/mono/browser/debugger/BrowserDebugProxy/MonoSDBHelper.cs +++ b/src/mono/browser/debugger/BrowserDebugProxy/MonoSDBHelper.cs @@ -973,7 +973,7 @@ public void ResetStore(DebugStore store) } public void ResetTypes() { - this.types = new (); + this.types = new(); } public async Task GetAssemblyInfo(int assemblyId, CancellationToken token) diff --git a/src/mono/browser/debugger/DebuggerTestSuite/DevToolsClient.cs b/src/mono/browser/debugger/DebuggerTestSuite/DevToolsClient.cs index 64bf879715cc20..27633d74c49897 100644 --- a/src/mono/browser/debugger/DebuggerTestSuite/DevToolsClient.cs +++ b/src/mono/browser/debugger/DebuggerTestSuite/DevToolsClient.cs @@ -51,7 +51,7 @@ public Task ShutdownAsync(CancellationToken cancellationToken) protected async Task ConnectToWebServer(Uri uri, CancellationToken token) { // connects to the webserver to start the proxy - ClientWebSocket clientSocket = new (); + ClientWebSocket clientSocket = new(); clientSocket.Options.KeepAliveInterval = Timeout.InfiniteTimeSpan; logger.LogDebug("Client connecting to {0}", uri); await clientSocket.ConnectAsync(uri, token); diff --git a/src/mono/browser/debugger/DebuggerTestSuite/ExceptionTests.cs b/src/mono/browser/debugger/DebuggerTestSuite/ExceptionTests.cs index 184cbaae6fb9cf..f20d7d08349ea1 100644 --- a/src/mono/browser/debugger/DebuggerTestSuite/ExceptionTests.cs +++ b/src/mono/browser/debugger/DebuggerTestSuite/ExceptionTests.cs @@ -283,7 +283,7 @@ public async Task ExceptionTestAllWithReload(string entry_method_name, string cl // Hit resume to skip int count = 0; var taskWait = insp.WaitFor(Inspector.APP_READY); - while(true) + while (true) { await cli.SendCommand("Debugger.resume", null, token); count++; diff --git a/src/mono/browser/debugger/DebuggerTestSuite/Inspector.cs b/src/mono/browser/debugger/DebuggerTestSuite/Inspector.cs index 8ee9d62f9a2a0e..6a333cdd851bbe 100644 --- a/src/mono/browser/debugger/DebuggerTestSuite/Inspector.cs +++ b/src/mono/browser/debugger/DebuggerTestSuite/Inspector.cs @@ -24,9 +24,9 @@ class Inspector // https://console.spec.whatwg.org/#formatting-specifiers private static Regex _consoleArgsRegex = new(@"(%[sdifoOc])", RegexOptions.Compiled); - ConcurrentDictionary> notifications = new (); - ConcurrentDictionary>> eventListeners = new (); - ConcurrentQueue<(string, JObject)> nextNotifications = new (); //in a multithreaded runtime we can receive more than one pause at same time + ConcurrentDictionary> notifications = new(); + ConcurrentDictionary>> eventListeners = new(); + ConcurrentQueue<(string, JObject)> nextNotifications = new(); //in a multithreaded runtime we can receive more than one pause at same time public const string PAUSE = "pause"; public const string APP_READY = "app-ready"; public CancellationToken Token { get; set; } diff --git a/src/mono/browser/debugger/DebuggerTestSuite/MiscTests.cs b/src/mono/browser/debugger/DebuggerTestSuite/MiscTests.cs index 3b0d795dfe5f4d..555c23a79b6d3f 100644 --- a/src/mono/browser/debugger/DebuggerTestSuite/MiscTests.cs +++ b/src/mono/browser/debugger/DebuggerTestSuite/MiscTests.cs @@ -1166,7 +1166,7 @@ await StepAndCheck(StepKind.Resume, "dotnet://debugger-test.dll/debugger-test.cs public static TheoryData CountToTen() { var data = new TheoryData(); - for(int i=0;i<10;i++) + for (int i=0;i<10;i++) { data.Add(i); } diff --git a/src/mono/mono/mini/arrays.cs b/src/mono/mono/mini/arrays.cs index 2358acb0e7cb89..8f18682cc0957b 100644 --- a/src/mono/mono/mini/arrays.cs +++ b/src/mono/mono/mini/arrays.cs @@ -470,7 +470,7 @@ public static int test_100_4_dimensional_arrays () { public static int test_0_bug_71454 () { int[,] a = new int[4,4]; int[,] b = new int[4,4]; - for(int i = 0; i < 4; ++i) { + for (int i = 0; i < 4; ++i) { b[0,0] = a[0,i % 4]; } return 0; @@ -551,7 +551,7 @@ public static int test_0_invalid_new_array_size () { public static int test_0_multidym_array_with_negative_lower_bound () { int[,] x = (int[,]) Array.CreateInstance(typeof (int), new int[] { 2, 2 }, new int[] { -2, -3 }); - if(x.GetLowerBound (0) != -2) + if (x.GetLowerBound (0) != -2) return 1; if (x.GetLowerBound (1) != -3) return 2; @@ -762,7 +762,7 @@ public static int test_0_long_indices () { public static int test_0_ldelema_2_64bit () { bool[,] test = new bool[201,201]; int x,y; - for(x=-100;x<100;x++) for(y=-100;y<100;y++){ + for (x=-100;x<100;x++) for (y=-100;y<100;y++){ test[x+100,y+100] = true; } return 0; diff --git a/src/mono/mono/mini/bench.cs b/src/mono/mono/mini/bench.cs index 15cd67d60c6990..93648440e10f07 100644 --- a/src/mono/mono/mini/bench.cs +++ b/src/mono/mono/mini/bench.cs @@ -82,8 +82,8 @@ public static int test_0_logic_run () bool flag13 = true; // First set of tests. - for(iter = 0; iter < 2000000; ++iter) { - if((flag1 || flag2) && (flag3 || flag4) && + for (iter = 0; iter < 2000000; ++iter) { + if ((flag1 || flag2) && (flag3 || flag4) && (flag5 || flag6 || flag7)) { flag8 = !flag8; @@ -212,25 +212,25 @@ private int test_0_blur(int size) { int iterations = 1; - while(iterations-- > 0) { + while (iterations-- > 0) { // Draw fake picture - for(int i = 0; i < size; i++) { - for(int j = 0; j < size; j++) { + for (int i = 0; i < size; i++) { + for (int j = 0; j < size; j++) { arr1[i, j] = (byte) (i%255); } } - for(int n = 0; n < num; n++) { // num rounds of blurring - for(int i = 3; i < size-3; i++) // vertical blur arr1 -> arr2 - for(int j = 0; j < size; j++) + for (int n = 0; n < num; n++) { // num rounds of blurring + for (int i = 3; i < size-3; i++) // vertical blur arr1 -> arr2 + for (int j = 0; j < size; j++) arr2[i, j] = (byte)((arr1[i-3, j] + arr1[i+3, j] + 6*(arr1[i-2, j]+arr1[i+2, j]) + 15*(arr1[i-1, j]+arr1[i+1, j]) + 20*arr1[i, j] + 32)>>6); - for(int j = 3; j < size-3; j++) // horizontal blur arr1 -> arr2 - for(int i = 0; i < size; i++) + for (int j = 3; j < size-3; j++) // horizontal blur arr1 -> arr2 + for (int i = 0; i < size; i++) arr1[i, j] = (byte)((arr2[i, j-3] + arr2[i, j+3] + 6*(arr2[i, j-2]+arr2[i, j+2]) + 15*(arr2[i, j-1]+arr2[i, j+1]) diff --git a/src/mono/mono/mini/devirtualization.cs b/src/mono/mono/mini/devirtualization.cs index 20ca3bdb70adf1..de11baa414c223 100644 --- a/src/mono/mono/mini/devirtualization.cs +++ b/src/mono/mono/mini/devirtualization.cs @@ -161,35 +161,35 @@ static public int test_0_npe_still_happens() { try { y.method1(); return 1; - } catch(NullReferenceException e) { + } catch (NullReferenceException e) { ;//ok } try { y.method2(); return 2; - } catch(NullReferenceException e) { + } catch (NullReferenceException e) { ;//ok } try { y.method3(); return 3; - } catch(NullReferenceException e) { + } catch (NullReferenceException e) { ;//ok } try { x.method4(); return 4; - } catch(NullReferenceException e) { + } catch (NullReferenceException e) { ;//ok } try { x.method5(); return 5; - } catch(NullReferenceException e) { + } catch (NullReferenceException e) { ;//ok } diff --git a/src/mono/mono/mini/generics.cs b/src/mono/mono/mini/generics.cs index 0c6346c63d48da..fe68180f715e59 100644 --- a/src/mono/mono/mini/generics.cs +++ b/src/mono/mono/mini/generics.cs @@ -496,7 +496,7 @@ public static int test_0_inline_infinite_polymorphic_recursion () { } private static void f(int i) { - if(i==42) f>(i); + if (i==42) f>(i); } // This cannot be made to work with full-aot, since there it is impossible to diff --git a/src/mono/sample/wasm/browser-logprofile/Program.cs b/src/mono/sample/wasm/browser-logprofile/Program.cs index 6bebd913c0592b..ab40a9a1d366b8 100644 --- a/src/mono/sample/wasm/browser-logprofile/Program.cs +++ b/src/mono/sample/wasm/browser-logprofile/Program.cs @@ -21,7 +21,7 @@ public static void TakeHeapshot() { } [JSExport] public static int TestMeaning() { - for(int i=0; i<100; i++){ + for (int i=0; i<100; i++){ var r = new int[1000]; } diff --git a/src/mono/wasi/Wasi.Build.Tests/InvariantTests.cs b/src/mono/wasi/Wasi.Build.Tests/InvariantTests.cs index a7a2785e65bfdd..f41172255e1d11 100644 --- a/src/mono/wasi/Wasi.Build.Tests/InvariantTests.cs +++ b/src/mono/wasi/Wasi.Build.Tests/InvariantTests.cs @@ -24,7 +24,7 @@ public void ConsolePublishAndRunForSingleFileBundle_InvariantTimeZone(string con { string extraProperties = invariantTimezone ? "true" : ""; CommandResult res = ConsolePublishAndRunForSingleFileBundleInternal(config, "InvariantTimezones.cs", aot, extraProperties: extraProperties); - if(invariantTimezone) + if (invariantTimezone) Assert.Contains("Could not find Asia/Tokyo", res.Output); else Assert.Contains("Asia/Tokyo BaseUtcOffset is 09:00:00", res.Output); diff --git a/src/mono/wasi/Wasi.Build.Tests/PInvokeTableGeneratorTests.cs b/src/mono/wasi/Wasi.Build.Tests/PInvokeTableGeneratorTests.cs index 1405ec20bb7157..709fad553ca3bc 100644 --- a/src/mono/wasi/Wasi.Build.Tests/PInvokeTableGeneratorTests.cs +++ b/src/mono/wasi/Wasi.Build.Tests/PInvokeTableGeneratorTests.cs @@ -21,7 +21,7 @@ public PInvokeTableGeneratorTests(ITestOutputHelper output, SharedBuildPerTestCl [MemberData(nameof(TestDataForConsolePublishAndRunRelease))] public void InteropSupportForUnmanagedEntryPointWithoutDelegate(bool singleFileBundle, bool aot) { - if(aot) + if (aot) { // Active issue https://github.com/dotnet/runtime/issues/101276 return; diff --git a/src/mono/wasm/Wasm.Build.Tests/IcuTestsBase.cs b/src/mono/wasm/Wasm.Build.Tests/IcuTestsBase.cs index 1bf7e100314e5b..daf9b7ea597176 100644 --- a/src/mono/wasm/Wasm.Build.Tests/IcuTestsBase.cs +++ b/src/mono/wasm/Wasm.Build.Tests/IcuTestsBase.cs @@ -83,7 +83,7 @@ protected string GetProgramText(string testedLocales, bool onlyPredefinedCulture continue; }} }} - catch(CultureNotFoundException cnfe) when (ctorShouldFail && cnfe.Message.Contains($""{{testLocale.Code}} is an invalid culture identifier."")) + catch (CultureNotFoundException cnfe) when (ctorShouldFail && cnfe.Message.Contains($""{{testLocale.Code}} is an invalid culture identifier."")) {{ Console.WriteLine($""{{testLocale.Code}}: Success. .ctor failed as expected.""); continue; @@ -130,7 +130,7 @@ protected ProjectInfo CreateIcuProject( string programText = GetProgramText(testedLocales, onlyPredefinedCultures); File.WriteAllText(programPath, programText); _testOutput.WriteLine($"----- Program: -----{Environment.NewLine}{programText}{Environment.NewLine}-------"); - + UpdateBrowserMainJs(); return info; } @@ -160,7 +160,7 @@ protected async Task PublishAndRunIcuTest( RunResult runOutput = await RunForPublishWithWebServer(runOptions); return $"{buildOutput}\n{runOutput.TestOutput}"; } - catch(Exception ex) + catch (Exception ex) { Console.WriteLine($"Exception: {ex}; _testOutput={_testOutput}"); throw; diff --git a/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs b/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs index 752f6ebf8a4d80..3b70408b34732d 100644 --- a/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs +++ b/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs @@ -35,7 +35,7 @@ public WasmTemplateTestsBase(ITestOutputHelper output, SharedBuildPerTestClassFi private Dictionary browserProgramReplacements = new Dictionary { - { "while(true)", $"int i = 0;{Environment.NewLine}while(i++ < 0)" }, // the test has to be fast, skip the loop + { "while (true)", $"int i = 0;{Environment.NewLine}while (i++ < 0)" }, // the test has to be fast, skip the loop { "partial class StopwatchSample", $"return 42;{Environment.NewLine}partial class StopwatchSample" }, { "Hello, Browser!", "TestOutput -> Hello, Browser!" } }; @@ -219,7 +219,7 @@ protected void ReplaceFile(string pathRelativeToProjectDir, string pathWithNewCo protected void DeleteFile(string pathRelativeToProjectDir) { var deletedFilePath = Path.Combine(_projectDir, pathRelativeToProjectDir); - if(File.Exists(deletedFilePath)) + if (File.Exists(deletedFilePath)) { File.Delete(deletedFilePath); } diff --git a/src/mono/wasm/templates/templates/browser/Program.cs b/src/mono/wasm/templates/templates/browser/Program.cs index a9726e67fd6aca..563b061eb60d7c 100644 --- a/src/mono/wasm/templates/templates/browser/Program.cs +++ b/src/mono/wasm/templates/templates/browser/Program.cs @@ -8,7 +8,7 @@ if (args.Length == 1 && args[0] == "start") StopwatchSample.Start(); -while(true) +while (true) { StopwatchSample.Render(); await Task.Delay(1000); diff --git a/src/native/managed/cdacreader/Microsoft.Diagnostics.DataContractReader/CachingContractRegistry.cs b/src/native/managed/cdacreader/Microsoft.Diagnostics.DataContractReader/CachingContractRegistry.cs index f2602ce5e1e6ca..7655335bec0f9b 100644 --- a/src/native/managed/cdacreader/Microsoft.Diagnostics.DataContractReader/CachingContractRegistry.cs +++ b/src/native/managed/cdacreader/Microsoft.Diagnostics.DataContractReader/CachingContractRegistry.cs @@ -24,7 +24,7 @@ public CachingContractRegistry(Target target, TryGetContractVersionDelegate tryG { _target = target; _tryGetContractVersion = tryGetContractVersion; - _factories = new () { + _factories = new() { [typeof(IException)] = new ExceptionFactory(), [typeof(ILoader)] = new LoaderFactory(), [typeof(IEcmaMetadata)] = new EcmaMetadataFactory(), diff --git a/src/native/managed/cdacreader/src/Legacy/TypeNameBuilder.cs b/src/native/managed/cdacreader/src/Legacy/TypeNameBuilder.cs index 5ed2083de4cf24..1688f34db24d15 100644 --- a/src/native/managed/cdacreader/src/Legacy/TypeNameBuilder.cs +++ b/src/native/managed/cdacreader/src/Legacy/TypeNameBuilder.cs @@ -327,7 +327,7 @@ private static void AppendTypeCore(ref TypeNameBuilder tnb, Contracts.TypeHandle // The following flags in the FormatFlags argument are significant: FormatNamespace FormatFullInst FormatAssembly FormatNoVersion private static void AppendInst(Target target, StringBuilder stringBuilder, ReadOnlySpan inst, TypeNameFormat format) { - TypeNameBuilder tnb = new (stringBuilder, target, format, initialStateIsName: true); + TypeNameBuilder tnb = new(stringBuilder, target, format, initialStateIsName: true); AppendInst(ref tnb, inst, format); } diff --git a/src/tasks/AotCompilerTask/MonoAOTCompiler.cs b/src/tasks/AotCompilerTask/MonoAOTCompiler.cs index 7ae3255fac5bee..23f51f761ae630 100644 --- a/src/tasks/AotCompilerTask/MonoAOTCompiler.cs +++ b/src/tasks/AotCompilerTask/MonoAOTCompiler.cs @@ -547,7 +547,7 @@ private bool ExecuteInternal() if (be9 is not null) allowedParallelism = be9.RequestCores(allowedParallelism); } - catch(NotImplementedException) + catch (NotImplementedException) { // RequestCores is not implemented in TaskHostFactory be9 = null; diff --git a/src/tasks/AppleAppBuilder/AppleAppBuilder.cs b/src/tasks/AppleAppBuilder/AppleAppBuilder.cs index 2c1304b0dc3600..e13a84c02f6b22 100644 --- a/src/tasks/AppleAppBuilder/AppleAppBuilder.cs +++ b/src/tasks/AppleAppBuilder/AppleAppBuilder.cs @@ -316,7 +316,7 @@ public override bool Execute() } List extraLinkerArgs = new List(); - foreach(ITaskItem item in ExtraLinkerArguments) + foreach (ITaskItem item in ExtraLinkerArguments) { extraLinkerArgs.Add(item.ItemSpec); } diff --git a/src/tasks/LibraryBuilder/LibraryBuilder.cs b/src/tasks/LibraryBuilder/LibraryBuilder.cs index 1ad0a3cbae7f37..c9e621a13f702f 100644 --- a/src/tasks/LibraryBuilder/LibraryBuilder.cs +++ b/src/tasks/LibraryBuilder/LibraryBuilder.cs @@ -289,7 +289,7 @@ private void WriteAutoInitializationFromTemplate() { string dataSymbol = "NULL"; string dataLenSymbol = "0"; - StringBuilder externBundledResourcesSymbols = new ("#if defined(BUNDLED_RESOURCES)\nextern void mono_register_resources_bundle (void);"); + StringBuilder externBundledResourcesSymbols = new("#if defined(BUNDLED_RESOURCES)\nextern void mono_register_resources_bundle (void);"); if (BundledRuntimeConfig?.ItemSpec != null) { dataSymbol = BundledRuntimeConfig.GetMetadata("DataSymbol"); diff --git a/src/tasks/MobileBuildTasks/Android/AndroidProject.cs b/src/tasks/MobileBuildTasks/Android/AndroidProject.cs index a71c39add20b02..c1935a6be12e14 100644 --- a/src/tasks/MobileBuildTasks/Android/AndroidProject.cs +++ b/src/tasks/MobileBuildTasks/Android/AndroidProject.cs @@ -95,30 +95,30 @@ private static string BuildClangArgs(ClangBuildOptions buildOptions) { StringBuilder ret = new StringBuilder(); - foreach(string compilerArg in buildOptions.CompilerArguments) + foreach (string compilerArg in buildOptions.CompilerArguments) { ret.Append(compilerArg); ret.Append(' '); } - foreach(string includeDir in buildOptions.IncludePaths) + foreach (string includeDir in buildOptions.IncludePaths) { ret.Append($"-I {includeDir} "); } - foreach(string linkerArg in buildOptions.LinkerArguments) + foreach (string linkerArg in buildOptions.LinkerArguments) { ret.Append($"-Xlinker {linkerArg} "); } - foreach(string source in buildOptions.Sources) + foreach (string source in buildOptions.Sources) { ret.Append(source); ret.Append(' '); } HashSet libDirs = new HashSet(); - foreach(string lib in buildOptions.NativeLibraryPaths) + foreach (string lib in buildOptions.NativeLibraryPaths) { string rootPath = Path.GetDirectoryName(lib)!; string libName = Path.GetFileName(lib); diff --git a/src/tasks/MobileBuildTasks/Android/Ndk/Ndk.cs b/src/tasks/MobileBuildTasks/Android/Ndk/Ndk.cs index b0e242353cc90c..3828448dcaef77 100644 --- a/src/tasks/MobileBuildTasks/Android/Ndk/Ndk.cs +++ b/src/tasks/MobileBuildTasks/Android/Ndk/Ndk.cs @@ -48,7 +48,7 @@ private static string GetNdkPath(IEnumerable probingPaths) { string ret = ""; - foreach(string path in probingPaths) + foreach (string path in probingPaths) { if (Directory.Exists(path)) { @@ -104,7 +104,7 @@ private static NdkVersion ReadVersion() var splitChars = new char[] {'='}; string? ver = null; - foreach(string l in File.ReadAllLines(sourcePropertiesPath)) + foreach (string l in File.ReadAllLines(sourcePropertiesPath)) { string line = l.Trim (); if (!line.StartsWith("Pkg.Revision", StringComparison.Ordinal)) diff --git a/src/tasks/MobileBuildTasks/Android/Ndk/NdkTools.cs b/src/tasks/MobileBuildTasks/Android/Ndk/NdkTools.cs index 0741e92dfe8116..862afffacfdeec 100644 --- a/src/tasks/MobileBuildTasks/Android/Ndk/NdkTools.cs +++ b/src/tasks/MobileBuildTasks/Android/Ndk/NdkTools.cs @@ -119,7 +119,7 @@ private void ValidateRequiredProps(string hostOS) { string host = validHosts[hostOS]; } - catch(KeyNotFoundException) + catch (KeyNotFoundException) { throw new Exception("An invalid HostOS value was supplied. Only windows, osx, and linux are supported."); } diff --git a/src/tasks/MobileBuildTasks/Android/Ndk/NdkVersion.cs b/src/tasks/MobileBuildTasks/Android/Ndk/NdkVersion.cs index d45e88d2d16892..cc1243d6fbd3bc 100644 --- a/src/tasks/MobileBuildTasks/Android/Ndk/NdkVersion.cs +++ b/src/tasks/MobileBuildTasks/Android/Ndk/NdkVersion.cs @@ -17,7 +17,7 @@ public NdkVersion(string? version) string? ver = version?.Trim(); if (string.IsNullOrEmpty(ver)) { - throw new ArgumentException ("must be a non-empty string", nameof (version)); + throw new ArgumentException ("must be a non-empty string", nameof(version)); } int tagIdx = ver!.IndexOf('-'); diff --git a/src/tasks/MobileBuildTasks/Apple/AppleProject.cs b/src/tasks/MobileBuildTasks/Apple/AppleProject.cs index 6a0f61c1968c41..4f3219a8fc6829 100644 --- a/src/tasks/MobileBuildTasks/Apple/AppleProject.cs +++ b/src/tasks/MobileBuildTasks/Apple/AppleProject.cs @@ -82,23 +82,23 @@ private string BuildClangArgs(ClangBuildOptions buildOptions, string minOSVersio buildOptions.CompilerArguments.Add($"-arch {targetAbi}"); } - foreach(string compilerArg in buildOptions.CompilerArguments) + foreach (string compilerArg in buildOptions.CompilerArguments) { ret.Append(compilerArg); ret.Append(' '); } - foreach(string includeDir in buildOptions.IncludePaths) + foreach (string includeDir in buildOptions.IncludePaths) { ret.Append($"-I {includeDir} "); } - foreach(string linkerArg in buildOptions.LinkerArguments) + foreach (string linkerArg in buildOptions.LinkerArguments) { ret.Append($"{linkerArg} "); } - foreach(string source in buildOptions.Sources) + foreach (string source in buildOptions.Sources) { string ext = Path.GetExtension(source); @@ -115,7 +115,7 @@ private string BuildClangArgs(ClangBuildOptions buildOptions, string minOSVersio } HashSet libDirs = new HashSet(); - foreach(string lib in buildOptions.NativeLibraryPaths) + foreach (string lib in buildOptions.NativeLibraryPaths) { string rootPath = Path.GetDirectoryName(lib)!; string libName = Path.GetFileName(lib); diff --git a/src/tasks/MonoTargetsTasks/EmitBundleTask/EmitBundleBase.cs b/src/tasks/MonoTargetsTasks/EmitBundleTask/EmitBundleBase.cs index 40aac49edb70bf..c2c813c495d362 100644 --- a/src/tasks/MonoTargetsTasks/EmitBundleTask/EmitBundleBase.cs +++ b/src/tasks/MonoTargetsTasks/EmitBundleTask/EmitBundleBase.cs @@ -160,7 +160,7 @@ public override bool Execute() if (be9 is not null) allowedParallelism = be9.RequestCores(allowedParallelism); } - catch(NotImplementedException) + catch (NotImplementedException) { // RequestCores is not implemented in TaskHostFactory be9 = null; @@ -289,8 +289,8 @@ private static byte[] InitLookupTable() private string GatherUniqueExportedResourceDataSymbols(List uniqueDestinationFiles) { - StringBuilder resourceSymbols = new (); - HashSet resourcesAdded = new (); // Different Timezone resources may have the same contents + StringBuilder resourceSymbols = new(); + HashSet resourcesAdded = new(); // Different Timezone resources may have the same contents foreach (var uniqueDestinationFile in uniqueDestinationFiles) { string registeredName = uniqueDestinationFile.GetMetadata(RegisteredName); @@ -308,16 +308,16 @@ private string GatherUniqueExportedResourceDataSymbols(List uniqueDes private static void GenerateBundledResourcePreallocationAndRegistration(string resourceSymbols, string bundleRegistrationFunctionName, ICollection<(string resourceType, string registeredName, string resourceName, string resourceDataSymbol, string culture, string? resourceSymbolName)> files, StreamWriter outputUtf8Writer) { - List preallocatedSource = new (); + List preallocatedSource = new(); string assemblyTemplate = Utils.GetEmbeddedResource("mono-bundled-assembly.template"); string satelliteAssemblyTemplate = Utils.GetEmbeddedResource("mono-bundled-satellite-assembly.template"); string symbolDataTemplate = Utils.GetEmbeddedResource("mono-bundled-data.template"); var preallocatedResources = new StringBuilder(); - List preallocatedAssemblies = new (); - List preallocatedSatelliteAssemblies = new (); - List preallocatedData = new (); + List preallocatedAssemblies = new(); + List preallocatedSatelliteAssemblies = new(); + List preallocatedData = new(); int assembliesCount = 0; int satelliteAssembliesCount = 0; int dataCount = 0; @@ -377,7 +377,7 @@ private static void GenerateBundledResourcePreallocationAndRegistration(string r .Replace("%Len%", $"{resourceDataSymbol}_data_len_val")); } - List addPreallocatedResources = new (); + List addPreallocatedResources = new(); if (assembliesCount != 0) { preallocatedResources.AppendLine($"MonoBundledResource *{bundleRegistrationFunctionName}_assembly_resources[] = {{\n{string.Join(",\n", preallocatedAssemblies)}\n}};"); addPreallocatedResources.Add($" mono_bundled_resources_add ({bundleRegistrationFunctionName}_assembly_resources, {assembliesCount});"); diff --git a/src/tasks/MonoTargetsTasks/ILStrip/ILStrip.cs b/src/tasks/MonoTargetsTasks/ILStrip/ILStrip.cs index 288c7ef3711c8a..9976b737b56463 100644 --- a/src/tasks/MonoTargetsTasks/ILStrip/ILStrip.cs +++ b/src/tasks/MonoTargetsTasks/ILStrip/ILStrip.cs @@ -80,7 +80,7 @@ public override bool Execute() if (be9 is not null) allowedParallelism = be9.RequestCores(allowedParallelism); } - catch(NotImplementedException) + catch (NotImplementedException) { // RequestCores is not implemented in TaskHostFactory be9 = null; diff --git a/src/tasks/MonoTargetsTasks/MarshalingPInvokeScanner/MarshalingPInvokeScanner.cs b/src/tasks/MonoTargetsTasks/MarshalingPInvokeScanner/MarshalingPInvokeScanner.cs index 31cb896cf68fa2..dd77ae97fcd135 100644 --- a/src/tasks/MonoTargetsTasks/MarshalingPInvokeScanner/MarshalingPInvokeScanner.cs +++ b/src/tasks/MonoTargetsTasks/MarshalingPInvokeScanner/MarshalingPInvokeScanner.cs @@ -82,7 +82,7 @@ private void ResolveInconclusiveTypes(HashSet incompatible, string assyP MetadataReader mdtReader = peReader.GetMetadataReader(); string assyName = mdtReader.GetString(mdtReader.GetAssemblyDefinition().Name); HashSet inconclusiveTypes = mmtcp.GetInconclusiveTypesForAssembly(assyName); - if(inconclusiveTypes.Count == 0) + if (inconclusiveTypes.Count == 0) return; SignatureDecoder decoder = new(mmtcp, mdtReader, null!); @@ -113,18 +113,18 @@ private bool IsAssemblyIncompatible(string assyPath, MinimalMarshalingTypeCompat MetadataReader mdtReader = peReader.GetMetadataReader(); - foreach(CustomAttributeHandle attrHandle in mdtReader.CustomAttributes) + foreach (CustomAttributeHandle attrHandle in mdtReader.CustomAttributes) { CustomAttribute attr = mdtReader.GetCustomAttribute(attrHandle); - if(attr.Constructor.Kind == HandleKind.MethodDefinition) + if (attr.Constructor.Kind == HandleKind.MethodDefinition) { MethodDefinitionHandle mdh = (MethodDefinitionHandle)attr.Constructor; MethodDefinition md = mdtReader.GetMethodDefinition(mdh); TypeDefinitionHandle tdh = md.GetDeclaringType(); TypeDefinition td = mdtReader.GetTypeDefinition(tdh); - if(mdtReader.GetString(td.Namespace) == "System.Runtime.CompilerServices" && + if (mdtReader.GetString(td.Namespace) == "System.Runtime.CompilerServices" && mdtReader.GetString(td.Name) == "DisableRuntimeMarshallingAttribute") return false; } @@ -136,17 +136,17 @@ private bool IsAssemblyIncompatible(string assyPath, MinimalMarshalingTypeCompat string ns = mdtReader.GetString(typeDef.Namespace); string name = mdtReader.GetString(typeDef.Name); - foreach(MethodDefinitionHandle mthDefHandle in typeDef.GetMethods()) + foreach (MethodDefinitionHandle mthDefHandle in typeDef.GetMethods()) { MethodDefinition mthDef = mdtReader.GetMethodDefinition(mthDefHandle); - if(!mthDef.Attributes.HasFlag(MethodAttributes.PinvokeImpl)) + if (!mthDef.Attributes.HasFlag(MethodAttributes.PinvokeImpl)) continue; BlobReader sgnBlobReader = mdtReader.GetBlobReader(mthDef.Signature); SignatureDecoder decoder = new(mmtcp, mdtReader, null!); MethodSignature sgn = decoder.DecodeMethodSignature(ref sgnBlobReader); - if(sgn.ReturnType == Compatibility.Incompatible || sgn.ParameterTypes.Any(p => p == Compatibility.Incompatible)) + if (sgn.ReturnType == Compatibility.Incompatible || sgn.ParameterTypes.Any(p => p == Compatibility.Incompatible)) { Log.LogMessage(MessageImportance.Low, string.Format("Assembly {0} requires marshal-ilgen for method {1}.{2}:{3} (first pass).", assyPath, ns, name, mdtReader.GetString(mthDef.Name))); diff --git a/src/tasks/MonoTargetsTasks/MarshalingPInvokeScanner/MinimalMarshalingTypeCompatibilityProvider.cs b/src/tasks/MonoTargetsTasks/MarshalingPInvokeScanner/MinimalMarshalingTypeCompatibilityProvider.cs index 8916c1d674c138..3e06e646c9805f 100644 --- a/src/tasks/MonoTargetsTasks/MarshalingPInvokeScanner/MinimalMarshalingTypeCompatibilityProvider.cs +++ b/src/tasks/MonoTargetsTasks/MarshalingPInvokeScanner/MinimalMarshalingTypeCompatibilityProvider.cs @@ -40,7 +40,7 @@ public void Add(string assyName, string namespaceName, string typeName) { HashSet? incAssyTypes; - if(!_data.TryGetValue(assyName, out incAssyTypes)) + if (!_data.TryGetValue(assyName, out incAssyTypes)) { incAssyTypes = new(); _data.Add(assyName, incAssyTypes); @@ -51,7 +51,7 @@ public void Add(string assyName, string namespaceName, string typeName) public HashSet EnumerateForAssembly(string assyName) { - if(_data.TryGetValue(assyName, out HashSet? incAssyTypes)) + if (_data.TryGetValue(assyName, out HashSet? incAssyTypes)) return incAssyTypes!; return new HashSet(); @@ -124,7 +124,7 @@ public Compatibility GetTypeFromDefinition(MetadataReader reader, TypeDefinition return GetTypeFromDefinition(reader, handleInner, rawTypeKind); } } - catch(BadImageFormatException ex) + catch (BadImageFormatException ex) { _log.LogMessage(MessageImportance.Low, ex.Message); } diff --git a/src/tasks/WasmAppBuilder/EmccCompile.cs b/src/tasks/WasmAppBuilder/EmccCompile.cs index 52a06ed6f306e9..e93e77203ae30b 100644 --- a/src/tasks/WasmAppBuilder/EmccCompile.cs +++ b/src/tasks/WasmAppBuilder/EmccCompile.cs @@ -137,7 +137,7 @@ private bool ExecuteActual() if (be9 is not null) allowedParallelism = be9.RequestCores(allowedParallelism); } - catch(NotImplementedException) + catch (NotImplementedException) { // RequestCores is not implemented in TaskHostFactory be9 = null; diff --git a/src/tasks/WasmAppBuilder/InterpToNativeGenerator.cs b/src/tasks/WasmAppBuilder/InterpToNativeGenerator.cs index ad8a6a7df38745..4890b2b708d308 100644 --- a/src/tasks/WasmAppBuilder/InterpToNativeGenerator.cs +++ b/src/tasks/WasmAppBuilder/InterpToNativeGenerator.cs @@ -54,7 +54,7 @@ static IEnumerable Args (string signature) } static (bool isVoid, string nativeType) Result (string signature) - => new (SignatureMapper.IsVoidSignature(signature), SignatureMapper.CharToNativeType(signature[0])); + => new(SignatureMapper.IsVoidSignature(signature), SignatureMapper.CharToNativeType(signature[0])); w.Write( """ diff --git a/src/tasks/WasmAppBuilder/PInvokeCollector.cs b/src/tasks/WasmAppBuilder/PInvokeCollector.cs index c8dcf571fad147..ad6bc414adc056 100644 --- a/src/tasks/WasmAppBuilder/PInvokeCollector.cs +++ b/src/tasks/WasmAppBuilder/PInvokeCollector.cs @@ -246,7 +246,7 @@ public PInvokeCallback(MethodInfo method) { if (attr.AttributeType.Name == "UnmanagedCallersOnlyAttribute") { - foreach(var arg in attr.NamedArguments) + foreach (var arg in attr.NamedArguments) { if (arg.MemberName == "EntryPoint") { diff --git a/src/tools/illink/.editorconfig b/src/tools/illink/.editorconfig index caefe7822fe779..22971f0d78c1e1 100644 --- a/src/tools/illink/.editorconfig +++ b/src/tools/illink/.editorconfig @@ -39,6 +39,9 @@ file_header_template = Copyright (c) .NET Foundation and contributors. All right ### Code Style Analyzers +# Spacing around keywords +dotnet_diagnostic.SA1000.severity = none + # Access modifier must be declared dotnet_diagnostic.SA1400.severity = none