Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
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
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 @@ -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 @@ -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 @@ -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
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 @@ -69,7 +69,7 @@ internal Err AsErr
}

internal class Option<T> {
private static Option<T> none = new ();
private static Option<T> none = new();

private Option()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ public TensorSpan<T> Slice(params scoped ReadOnlySpan<NIndex> indexes)
internal TensorSpan<T> Slice(params scoped ReadOnlySpan<nint> 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]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1672,7 +1672,7 @@ private unsafe void Initialize(Guid eventSourceGuid, string eventSourceName, str
// Register the provider with ETW
Func<EventSource?> eventSourceFactory = () => this;
OverrideEventProvider? etwProvider = EventSourceInitHelper.TryGetPreregisteredEtwProvider(eventSourceGuid);
if(etwProvider == null)
if (etwProvider == null)
{
etwProvider = new OverrideEventProvider(eventSourceFactory, EventProviderType.ETW);
etwProvider.Register(eventSourceGuid, eventSourceName);
Expand Down Expand Up @@ -3879,7 +3879,7 @@ private bool SelfDescribingEvents
#endif
internal static void InitializeDefaultEventSources()
{
if(!EventSource.IsSupported)
if (!EventSource.IsSupported)
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ internal static void Fill(ref byte dest, byte value, nuint len)
if (len >= (nuint)Vector<byte>.Count)
{
// We have enough data for at least one vectorized write.
Vector<byte> vector = new (value);
Vector<byte> vector = new(value);
nuint stopLoopAtOffset = len & (nuint)(nint)(2 * (int)-Vector<byte>.Count); // intentional sign extension carries the negative bit
nuint offset = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ public override Type[] GetInterfaces()

List<Type> interfaces = _interfaces ?? [];

if(_typeParent != null)
if (_typeParent != null)
{
interfaces.AddRange(_typeParent.GetInterfaces());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ public PerScopeCache()

internal sealed class ConcurrentExecutionContextDictionary
{
private ConcurrentDictionary<SessionId, ConcurrentBag<ExecutionContext>> contexts = new ();
private ConcurrentDictionary<SessionId, ConcurrentBag<ExecutionContext>> contexts = new();
public ExecutionContext GetCurrentContext(SessionId sessionId)
=> TryGetCurrentExecutionContextValue(sessionId, out ExecutionContext context)
? context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private sealed partial class ExpressionSyntaxReplacer : CSharpSyntaxWalker
public bool hasMethodCalls;
public bool hasElementAccesses;
public bool hasStringExpressionStatement;
internal List<VariableDefinition> variableDefinitions = new ();
internal List<VariableDefinition> variableDefinitions = new();

public void VisitInternal(SyntaxNode node)
{
Expand Down Expand Up @@ -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)));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ public async Task<JObject> 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);
Expand Down
4 changes: 2 additions & 2 deletions src/mono/browser/debugger/BrowserDebugProxy/MonoProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal class MonoProxy : DevToolsProxy
internal string CachePathSymbolServer { get; private set; }
private readonly HashSet<SessionId> sessions = new HashSet<SessionId>();
private static readonly string[] s_executionContextIndependentCDPCommandNames = { "DotnetDebugger.setDebuggerProperty", "DotnetDebugger.runTests" };
internal ConcurrentExecutionContextDictionary Contexts = new ();
internal ConcurrentExecutionContextDictionary Contexts = new();

public static HttpClient HttpClient => new HttpClient();

Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@ public void ResetStore(DebugStore store)
}

public void ResetTypes() {
this.types = new ();
this.types = new();
}

public async Task<AssemblyInfo> GetAssemblyInfo(int assemblyId, CancellationToken token)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public Task ShutdownAsync(CancellationToken cancellationToken)
protected async Task<ClientWebSocket> 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);
Expand Down
6 changes: 3 additions & 3 deletions src/mono/browser/debugger/DebuggerTestSuite/Inspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class Inspector
// https://console.spec.whatwg.org/#formatting-specifiers
private static Regex _consoleArgsRegex = new(@"(%[sdifoOc])", RegexOptions.Compiled);

ConcurrentDictionary<string, TaskCompletionSource<JObject>> notifications = new ();
ConcurrentDictionary<string, Func<JObject, CancellationToken, Task<ProtocolEventHandlerReturn>>> eventListeners = new ();
ConcurrentQueue<(string, JObject)> nextNotifications = new (); //in a multithreaded runtime we can receive more than one pause at same time
ConcurrentDictionary<string, TaskCompletionSource<JObject>> notifications = new();
ConcurrentDictionary<string, Func<JObject, CancellationToken, Task<ProtocolEventHandlerReturn>>> 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; }
Expand Down
Loading
Loading