Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix SA1000
  • Loading branch information
xtqqczze committed Feb 8, 2025
commit 57a6156b965e66e0dea0c72c9f133fed7ff20848
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
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 @@ -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 @@ -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
2 changes: 1 addition & 1 deletion src/tasks/AotCompilerTask/MonoAOTCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/tasks/AppleAppBuilder/AppleAppBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ public override bool Execute()
}

List<string> extraLinkerArgs = new List<string>();
foreach(ITaskItem item in ExtraLinkerArguments)
foreach (ITaskItem item in ExtraLinkerArguments)
{
extraLinkerArgs.Add(item.ItemSpec);
}
Expand Down
10 changes: 5 additions & 5 deletions src/tasks/MobileBuildTasks/Android/AndroidProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> libDirs = new HashSet<string>();
foreach(string lib in buildOptions.NativeLibraryPaths)
foreach (string lib in buildOptions.NativeLibraryPaths)
{
string rootPath = Path.GetDirectoryName(lib)!;
string libName = Path.GetFileName(lib);
Expand Down
4 changes: 2 additions & 2 deletions src/tasks/MobileBuildTasks/Android/Ndk/Ndk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private static string GetNdkPath(IEnumerable<string> probingPaths)
{
string ret = "";

foreach(string path in probingPaths)
foreach (string path in probingPaths)
{
if (Directory.Exists(path))
{
Expand Down Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion src/tasks/MobileBuildTasks/Android/Ndk/NdkTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
Expand Down
2 changes: 1 addition & 1 deletion src/tasks/MobileBuildTasks/Android/Ndk/NdkVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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('-');
Expand Down
10 changes: 5 additions & 5 deletions src/tasks/MobileBuildTasks/Apple/AppleProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -115,7 +115,7 @@ private string BuildClangArgs(ClangBuildOptions buildOptions, string minOSVersio
}

HashSet<string> libDirs = new HashSet<string>();
foreach(string lib in buildOptions.NativeLibraryPaths)
foreach (string lib in buildOptions.NativeLibraryPaths)
{
string rootPath = Path.GetDirectoryName(lib)!;
string libName = Path.GetFileName(lib);
Expand Down
16 changes: 8 additions & 8 deletions src/tasks/MonoTargetsTasks/EmitBundleTask/EmitBundleBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -289,8 +289,8 @@ private static byte[] InitLookupTable()

private string GatherUniqueExportedResourceDataSymbols(List<ITaskItem> uniqueDestinationFiles)
{
StringBuilder resourceSymbols = new ();
HashSet<string> resourcesAdded = new (); // Different Timezone resources may have the same contents
StringBuilder resourceSymbols = new();
HashSet<string> resourcesAdded = new(); // Different Timezone resources may have the same contents
foreach (var uniqueDestinationFile in uniqueDestinationFiles)
{
string registeredName = uniqueDestinationFile.GetMetadata(RegisteredName);
Expand All @@ -308,16 +308,16 @@ private string GatherUniqueExportedResourceDataSymbols(List<ITaskItem> 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<string> preallocatedSource = new ();
List<string> 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<string> preallocatedAssemblies = new ();
List<string> preallocatedSatelliteAssemblies = new ();
List<string> preallocatedData = new ();
List<string> preallocatedAssemblies = new();
List<string> preallocatedSatelliteAssemblies = new();
List<string> preallocatedData = new();
int assembliesCount = 0;
int satelliteAssembliesCount = 0;
int dataCount = 0;
Expand Down Expand Up @@ -377,7 +377,7 @@ private static void GenerateBundledResourcePreallocationAndRegistration(string r
.Replace("%Len%", $"{resourceDataSymbol}_data_len_val"));
}

List<string> addPreallocatedResources = new ();
List<string> 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});");
Expand Down
2 changes: 1 addition & 1 deletion src/tasks/MonoTargetsTasks/ILStrip/ILStrip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private void ResolveInconclusiveTypes(HashSet<string> incompatible, string assyP
MetadataReader mdtReader = peReader.GetMetadataReader();
string assyName = mdtReader.GetString(mdtReader.GetAssemblyDefinition().Name);
HashSet<string> inconclusiveTypes = mmtcp.GetInconclusiveTypesForAssembly(assyName);
if(inconclusiveTypes.Count == 0)
if (inconclusiveTypes.Count == 0)
return;

SignatureDecoder<Compatibility, object> decoder = new(mmtcp, mdtReader, null!);
Expand Down Expand Up @@ -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;
}
Expand All @@ -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<Compatibility, object> decoder = new(mmtcp, mdtReader, null!);

MethodSignature<Compatibility> 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)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void Add(string assyName, string namespaceName, string typeName)
{
HashSet<string>? incAssyTypes;

if(!_data.TryGetValue(assyName, out incAssyTypes))
if (!_data.TryGetValue(assyName, out incAssyTypes))
{
incAssyTypes = new();
_data.Add(assyName, incAssyTypes);
Expand All @@ -51,7 +51,7 @@ public void Add(string assyName, string namespaceName, string typeName)

public HashSet<string> EnumerateForAssembly(string assyName)
{
if(_data.TryGetValue(assyName, out HashSet<string>? incAssyTypes))
if (_data.TryGetValue(assyName, out HashSet<string>? incAssyTypes))
return incAssyTypes!;

return new HashSet<string>();
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/tasks/WasmAppBuilder/EmccCompile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/tasks/WasmAppBuilder/InterpToNativeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static IEnumerable<char> 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(
"""
Expand Down
2 changes: 1 addition & 1 deletion src/tasks/WasmAppBuilder/PInvokeCollector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
{
Expand Down
Loading