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:
parent
9f67ad59b0
commit
6772a78d02
|
@ -485,6 +485,7 @@ struct struct_definition_generator
|
||||||
indent << scope_tab << "/// <summary>Get a hash code for this item.\n"
|
indent << scope_tab << "/// <summary>Get a hash code for this item.\n"
|
||||||
<< since_line
|
<< since_line
|
||||||
<< indent << scope_tab << "/// </summary>\n"
|
<< indent << scope_tab << "/// </summary>\n"
|
||||||
|
<< "#pragma warning disable CA1307\n"
|
||||||
<< indent << scope_tab << "public override int GetHashCode()\n"
|
<< indent << scope_tab << "public override int GetHashCode()\n"
|
||||||
<< indent << scope_tab << "{\n"
|
<< indent << scope_tab << "{\n"
|
||||||
).generate(sink, attributes::unused, context))
|
).generate(sink, attributes::unused, context))
|
||||||
|
@ -515,6 +516,7 @@ struct struct_definition_generator
|
||||||
|
|
||||||
if (!as_generator(
|
if (!as_generator(
|
||||||
indent << scope_tab << "}\n"
|
indent << scope_tab << "}\n"
|
||||||
|
<< "#pragma warning restore CA1307\n\n"
|
||||||
).generate(sink, attributes::unused, context))
|
).generate(sink, attributes::unused, context))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -201,7 +201,7 @@ public struct Error : IComparable<Error>, IEquatable<Error>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>A hash code.</returns>
|
/// <returns>A hash code.</returns>
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
=> code.GetHashCode() + Message.GetHashCode();
|
=> code.GetHashCode() + Message.GetHashCode(StringComparison.Ordinal);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Compare to a given error.
|
/// Compare to a given error.
|
||||||
|
|
|
@ -198,7 +198,7 @@ public class Stringshare : IEquatable<Stringshare>, IEquatable<string>
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
{
|
{
|
||||||
return Str.GetHashCode();
|
return Str.GetHashCode(StringComparison.Ordinal);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -92,7 +92,7 @@ public struct ObjectPath : IEquatable<ObjectPath>
|
||||||
/// <para>Since EFL 1.24.</para>
|
/// <para>Since EFL 1.24.</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>A hash code.</returns>
|
/// <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" />
|
/// <summary>Returns whether this <see cref="ObjectPath" />
|
||||||
/// is equal to the given <see cref="object" />.
|
/// is equal to the given <see cref="object" />.
|
||||||
|
@ -185,7 +185,7 @@ public struct SignatureString : IEquatable<SignatureString>
|
||||||
/// <para>Since EFL 1.24.</para>
|
/// <para>Since EFL 1.24.</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>A hash code.</returns>
|
/// <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" />
|
/// <summary>Returns whether this <see cref="SignatureString" />
|
||||||
/// is equal to the given <see cref="object" />.
|
/// is equal to the given <see cref="object" />.
|
||||||
|
|
|
@ -867,16 +867,17 @@ internal static class ClassRegister
|
||||||
{
|
{
|
||||||
throw new System.InvalidOperationException($"Could not get Native class name. Handle: {klass}");
|
throw new System.InvalidOperationException($"Could not get Native class name. Handle: {klass}");
|
||||||
}
|
}
|
||||||
|
#pragma warning disable CA1307
|
||||||
string name = Eina.StringConversion.NativeUtf8ToManagedString(namePtr)
|
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
|
// Check if this is an internal implementation of an abstract class
|
||||||
var abstract_impl_suffix = "Realized";
|
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);
|
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);
|
var klassName = name.Substring(lastDot + 1);
|
||||||
name += "+" + klassName + abstract_impl_suffix; // '+' is the separator for nested classes
|
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);
|
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)
|
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
|
name = name.Insert(pos + 1, "I"); // -1 if not found, inserts at 0 normally
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ internal struct ClassDescription : IEquatable<ClassDescription>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>A hash code.</returns>
|
/// <returns>A hash code.</returns>
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
=> version.GetHashCode() ^ name.GetHashCode()
|
=> version.GetHashCode() ^ name.GetHashCode(StringComparison.Ordinal)
|
||||||
^ class_type ^ data_size.GetHashCode();
|
^ class_type ^ data_size.GetHashCode();
|
||||||
|
|
||||||
/// <summary>Returns whether this <see cref="ClassDescription" />
|
/// <summary>Returns whether this <see cref="ClassDescription" />
|
||||||
|
|
|
@ -24,8 +24,8 @@ class TestMain
|
||||||
static Type[] GetTestCases(String name="")
|
static Type[] GetTestCases(String name="")
|
||||||
{
|
{
|
||||||
return Assembly.GetExecutingAssembly().GetTypes().Where(t => String.Equals(t.Namespace, "TestSuite", StringComparison.Ordinal) &&
|
return Assembly.GetExecutingAssembly().GetTypes().Where(t => String.Equals(t.Namespace, "TestSuite", StringComparison.Ordinal) &&
|
||||||
t.Name.StartsWith("Test") &&
|
t.Name.StartsWith("Test", StringComparison.Ordinal) &&
|
||||||
t.Name.Contains(name)).ToArray();
|
t.Name.Contains(name, StringComparison.Ordinal)).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int Main(string[] args)
|
static int Main(string[] args)
|
||||||
|
@ -45,7 +45,7 @@ class TestMain
|
||||||
String ckRunSuite = Environment.GetEnvironmentVariable("CK_RUN_SUITE");
|
String ckRunSuite = Environment.GetEnvironmentVariable("CK_RUN_SUITE");
|
||||||
String ckRunCase = Environment.GetEnvironmentVariable("CK_RUN_CASE");
|
String ckRunCase = Environment.GetEnvironmentVariable("CK_RUN_CASE");
|
||||||
|
|
||||||
if (ckRunSuite != null && !ckRunSuite.Equals("mono"))
|
if (ckRunSuite != null && !ckRunSuite.Equals("mono", StringComparison.Ordinal))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (ckRunCase == null)
|
if (ckRunCase == null)
|
||||||
|
|
Loading…
Reference in New Issue