Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed obsolete suppression of StringComparison. #1146

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions Src/ILGPU/Backends/PTX/PTXBackend.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ---------------------------------------------------------------------------------------
// ILGPU
// Copyright (c) 2018-2023 ILGPU Project
// Copyright (c) 2018-2024 ILGPU Project
// www.ilgpu.net
//
// File: PTXBackend.cs
Expand Down Expand Up @@ -305,11 +305,6 @@ protected override CompiledKernel CreateKernel(
ptxAssembly);
}

[SuppressMessage(
"Globalization",
"CA1307:Specify StringComparison",
Justification = "string.Replace(string, string, StringComparison) not " +
"available in net471")]
private unsafe void GenerateLibDeviceCode(
in BackendContext backendContext,
StringBuilder builder)
Expand Down Expand Up @@ -390,9 +385,12 @@ private unsafe void GenerateLibDeviceCode(
{
var compiledString =
compiledPTX.AsNotNull()
.Replace(".version", "//.version")
.Replace(".target", "//.target")
.Replace(".address_size", "//.address_size");
.Replace(".version", "//.version", StringComparison.Ordinal)
.Replace(".target", "//.target", StringComparison.Ordinal)
.Replace(
".address_size",
"//.address_size",
StringComparison.Ordinal);
builder.Append(compiledString);
}
}
Expand Down
7 changes: 1 addition & 6 deletions Src/ILGPU/Backends/PTX/PTXCodeGenerator.Values.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ---------------------------------------------------------------------------------------
// ILGPU
// Copyright (c) 2018-2023 ILGPU Project
// Copyright (c) 2018-2024 ILGPU Project
// www.ilgpu.net
//
// File: PTXCodeGenerator.Values.cs
Expand Down Expand Up @@ -1240,11 +1240,6 @@ public void GenerateCode(WriteToOutput writeToOutput) =>
writeToOutput.Assert(false);

/// <summary cref="IBackendCodeGenerator.GenerateCode(LanguageEmitValue)"/>
[SuppressMessage(
"Globalization",
"CA1307:Specify StringComparison",
Justification = "string.Replace(string, string, StringComparison) not " +
"available in net471")]
public void GenerateCode(LanguageEmitValue emit)
{
// Ignore non-PTX instructions.
Expand Down
10 changes: 3 additions & 7 deletions Src/ILGPU/Frontend/DebugInformation/LocalVariable.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ---------------------------------------------------------------------------------------
// ILGPU
// Copyright (c) 2018-2023 ILGPU Project
// Copyright (c) 2018-2024 ILGPU Project
// www.ilgpu.net
//
// File: LocalVariable.cs
Expand Down Expand Up @@ -80,12 +80,8 @@ public override bool Equals(object? obj) =>
/// Returns the hash code of this index.
/// </summary>
/// <returns>The hash code of this index.</returns>
[SuppressMessage(
"Globalization",
"CA1307:Specify StringComparison",
Justification = "string.GetHashCode(StringComparison) not " +
"available in net471")]
public override int GetHashCode() => Index.GetHashCode() ^ Name.GetHashCode();
public override int GetHashCode() =>
Index.GetHashCode() ^ Name.GetHashCode(StringComparison.Ordinal);

/// <summary>
/// Returns the string representation of this local variable.
Expand Down
9 changes: 2 additions & 7 deletions Src/ILGPU/IR/MethodHandle.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ---------------------------------------------------------------------------------------
// ILGPU
// Copyright (c) 2018-2023 ILGPU Project
// Copyright (c) 2018-2024 ILGPU Project
// www.ilgpu.net
//
// File: MethodHandle.cs
Expand Down Expand Up @@ -129,13 +129,8 @@ public override bool Equals(object? obj) =>
/// Returns the hash code of this handle.
/// </summary>
/// <returns>The hash code of this handle.</returns>
[SuppressMessage(
"Globalization",
"CA1307:Specify StringComparison",
Justification = "string.GetHashCode(StringComparison) not " +
"available in net471")]
public override int GetHashCode() =>
Id.GetHashCode() ^ Name?.GetHashCode() ?? 0;
Id.GetHashCode() ^ Name?.GetHashCode(StringComparison.Ordinal) ?? 0;

/// <summary>
/// Returns the string representation of this handle.
Expand Down
22 changes: 10 additions & 12 deletions Src/ILGPU/IR/Values/IOValues.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ---------------------------------------------------------------------------------------
// ILGPU
// Copyright (c) 2020-2023 ILGPU Project
// Copyright (c) 2020-2024 ILGPU Project
// www.ilgpu.net
//
// File: IOValues.cs
Expand All @@ -21,8 +21,6 @@
ILGPU.Util.FormatString.FormatExpression>;
using ValueList = ILGPU.Util.InlineList<ILGPU.IR.Values.ValueReference>;

#pragma warning disable CA1307 // Specify StringComparison for clarity

namespace ILGPU.IR.Values
{
/// <summary>
Expand Down Expand Up @@ -300,7 +298,8 @@ public string ToPrintFExpression()
result.Append(
expression.String.AsNotNull().Replace(
"%",
PrintFPercentFormat));
PrintFPercentFormat,
StringComparison.Ordinal));
}
}
return result.ToString();
Expand All @@ -311,11 +310,11 @@ public string ToPrintFExpression()
/// </summary>
public string ToEscapedPrintFExpression() =>
ToPrintFExpression()
.Replace("\t", @"\t")
.Replace("\r", @"\r")
.Replace("\n", @"\n")
.Replace("\"", "\\\"")
.Replace("\\", @"\\");
.Replace("\t", @"\t", StringComparison.Ordinal)
.Replace("\r", @"\r", StringComparison.Ordinal)
.Replace("\n", @"\n", StringComparison.Ordinal)
.Replace("\"", "\\\"", StringComparison.Ordinal)
.Replace("\\", @"\\", StringComparison.Ordinal);

#endregion

Expand All @@ -329,11 +328,10 @@ public string ToEscapedPrintFExpression() =>
protected override string ToArgString() =>
ToPrintFExpression().Replace(
Environment.NewLine,
string.Empty) +
string.Empty,
StringComparison.Ordinal) +
" " + base.ToArgString();

#endregion
}
}

#pragma warning restore CA1307 // Specify StringComparison for clarity
10 changes: 3 additions & 7 deletions Src/ILGPU/IR/Values/LanguageValues.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ---------------------------------------------------------------------------------------
// ILGPU
// Copyright (c) 2021-2022 ILGPU Project
// Copyright (c) 2021-2024 ILGPU Project
// www.ilgpu.net
//
// File: LanguageValues.cs
Expand Down Expand Up @@ -176,15 +176,11 @@ protected internal override Value Rebuild(
protected override string ToPrefixString() => "emit";

/// <summary cref="Value.ToArgString"/>
[SuppressMessage(
"Globalization",
"CA1307:Specify StringComparison",
Justification = "string.Replace(string, string, StringComparison) not " +
"available in net471")]
protected override string ToArgString() =>
ToStringExpression().Replace(
Environment.NewLine,
string.Empty) +
string.Empty,
StringComparison.Ordinal) +
" " + base.ToArgString();

/// <summary>
Expand Down
15 changes: 6 additions & 9 deletions Src/ILGPU/Runtime/OpenCL/CLDevice.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ---------------------------------------------------------------------------------------
// ILGPU
// Copyright (c) 2021-2023 ILGPU Project
// Copyright (c) 2021-2024 ILGPU Project
// www.ilgpu.net
//
// File: CLDevice.cs
Expand Down Expand Up @@ -318,11 +318,6 @@ private void InitGridInfo()
/// <summary>
/// Init vendor-specific features.
/// </summary>
[SuppressMessage(
"Globalization",
"CA1307:Specify StringComparison",
Justification = "string.GetHashCode(StringComparison) not " +
"available in net471")]
[MemberNotNull(nameof(VendorName))]
private void InitVendorAndWarpSizeInfo()
{
Expand Down Expand Up @@ -360,9 +355,11 @@ private void InitVendorAndWarpSizeInfo()
}
else
{
Vendor = VendorName.Contains(CLDeviceVendor.Intel.ToString()) ?
CLDeviceVendor.Intel :
CLDeviceVendor.Other;
Vendor = VendorName.Contains(
CLDeviceVendor.Intel.ToString(),
StringComparison.Ordinal)
? CLDeviceVendor.Intel
: CLDeviceVendor.Other;

// Warp size cannot be resolve at this point
WarpSize = 0;
Expand Down
Loading