csharp: Specifying StringComparison.

Summary: ref T8405

Reviewers: lauromoura, felipealmeida, YOhoho, segfaultxavi

Reviewed By: lauromoura

Subscribers: segfaultxavi, cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T8405

Differential Revision: https://phab.enlightenment.org/D10650
This commit is contained in:
Bruno da Silva Belo 2019-11-20 16:57:14 -03:00 committed by Lauro Moura
parent 9f67ad59b0
commit 6772a78d02
7 changed files with 16 additions and 13 deletions

View File

@ -485,6 +485,7 @@ struct struct_definition_generator
indent << scope_tab << "/// <summary>Get a hash code for this item.\n"
<< since_line
<< indent << scope_tab << "/// </summary>\n"
<< "#pragma warning disable CA1307\n"
<< indent << scope_tab << "public override int GetHashCode()\n"
<< indent << scope_tab << "{\n"
).generate(sink, attributes::unused, context))
@ -515,6 +516,7 @@ struct struct_definition_generator
if (!as_generator(
indent << scope_tab << "}\n"
<< "#pragma warning restore CA1307\n\n"
).generate(sink, attributes::unused, context))
return false;

View File

@ -201,7 +201,7 @@ public struct Error : IComparable<Error>, IEquatable<Error>
/// </summary>
/// <returns>A hash code.</returns>
public override int GetHashCode()
=> code.GetHashCode() + Message.GetHashCode();
=> code.GetHashCode() + Message.GetHashCode(StringComparison.Ordinal);
/// <summary>
/// Compare to a given error.

View File

@ -198,7 +198,7 @@ public class Stringshare : IEquatable<Stringshare>, IEquatable<string>
/// </returns>
public override int GetHashCode()
{
return Str.GetHashCode();
return Str.GetHashCode(StringComparison.Ordinal);
}
/// <summary>

View File

@ -92,7 +92,7 @@ public struct ObjectPath : IEquatable<ObjectPath>
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <returns>A hash code.</returns>
public override int GetHashCode() => value.GetHashCode();
public override int GetHashCode() => value.GetHashCode(StringComparison.Ordinal);
/// <summary>Returns whether this <see cref="ObjectPath" />
/// is equal to the given <see cref="object" />.
@ -185,7 +185,7 @@ public struct SignatureString : IEquatable<SignatureString>
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <returns>A hash code.</returns>
public override int GetHashCode() => value.GetHashCode();
public override int GetHashCode() => value.GetHashCode(StringComparison.Ordinal);
/// <summary>Returns whether this <see cref="SignatureString" />
/// is equal to the given <see cref="object" />.

View File

@ -867,16 +867,17 @@ internal static class ClassRegister
{
throw new System.InvalidOperationException($"Could not get Native class name. Handle: {klass}");
}
#pragma warning disable CA1307
string name = Eina.StringConversion.NativeUtf8ToManagedString(namePtr)
.Replace("_", ""); // Convert Efl C name to C# name
.Replace("_", ""); // Convert Efl C name to C# name
#pragma warning restore CA1307
// Check if this is an internal implementation of an abstract class
var abstract_impl_suffix = "Realized";
if (name.EndsWith(abstract_impl_suffix))
if (name.EndsWith(abstract_impl_suffix, StringComparison.Ordinal))
{
name = name.Substring(0, name.Length - abstract_impl_suffix.Length);
var lastDot = name.LastIndexOf(".");
var lastDot = name.LastIndexOf(".", StringComparison.Ordinal);
var klassName = name.Substring(lastDot + 1);
name += "+" + klassName + abstract_impl_suffix; // '+' is the separator for nested classes
}
@ -885,7 +886,7 @@ internal static class ClassRegister
var klass_type = Efl.Eo.Globals.efl_class_type_get(klass);
if (klass_type == Efl.Eo.Globals.EflClassType.Interface || klass_type == Efl.Eo.Globals.EflClassType.Mixin)
{
var pos = name.LastIndexOf(".");
var pos = name.LastIndexOf(".", StringComparison.Ordinal);
name = name.Insert(pos + 1, "I"); // -1 if not found, inserts at 0 normally
}

View File

@ -44,7 +44,7 @@ internal struct ClassDescription : IEquatable<ClassDescription>
/// </summary>
/// <returns>A hash code.</returns>
public override int GetHashCode()
=> version.GetHashCode() ^ name.GetHashCode()
=> version.GetHashCode() ^ name.GetHashCode(StringComparison.Ordinal)
^ class_type ^ data_size.GetHashCode();
/// <summary>Returns whether this <see cref="ClassDescription" />

View File

@ -24,8 +24,8 @@ class TestMain
static Type[] GetTestCases(String name="")
{
return Assembly.GetExecutingAssembly().GetTypes().Where(t => String.Equals(t.Namespace, "TestSuite", StringComparison.Ordinal) &&
t.Name.StartsWith("Test") &&
t.Name.Contains(name)).ToArray();
t.Name.StartsWith("Test", StringComparison.Ordinal) &&
t.Name.Contains(name, StringComparison.Ordinal)).ToArray();
}
static int Main(string[] args)
@ -45,7 +45,7 @@ class TestMain
String ckRunSuite = Environment.GetEnvironmentVariable("CK_RUN_SUITE");
String ckRunCase = Environment.GetEnvironmentVariable("CK_RUN_CASE");
if (ckRunSuite != null && !ckRunSuite.Equals("mono"))
if (ckRunSuite != null && !ckRunSuite.Equals("mono", StringComparison.Ordinal))
return 0;
if (ckRunCase == null)