C#: Fix length/emptiness checks

This commit is contained in:
Tamas Vajk
2020-10-02 09:48:58 +02:00
parent 83d6d6041a
commit 2d3985742f
4 changed files with 5 additions and 5 deletions

View File

@@ -170,7 +170,7 @@ namespace Semmle.Autobuild.CSharp
{
return BuildScript.Bind(GetInstalledSdksScript(builder.Actions), (sdks, sdksRet) =>
{
if (sdksRet == 0 && sdks.Count() == 1 && sdks[0].StartsWith(version + " ", StringComparison.Ordinal))
if (sdksRet == 0 && sdks.Count == 1 && sdks[0].StartsWith(version + " ", StringComparison.Ordinal))
// The requested SDK is already installed (and no other SDKs are installed), so
// no need to reinstall
return BuildScript.Failure;

View File

@@ -555,7 +555,7 @@ namespace Semmle.Extraction.CIL.Entities
yield return Tuples.cil_method(this, Name, DeclaringType, constructedTypeSignature.ReturnType);
yield return Tuples.cil_method_source_declaration(this, SourceDeclaration);
if (typeParams.Count() != unboundMethod.GenericParameterCount)
if (typeParams.Length != unboundMethod.GenericParameterCount)
throw new InternalError("Method type parameter mismatch");
for (int p = 0; p < typeParams.Length; ++p)

View File

@@ -65,7 +65,7 @@ namespace Semmle.Extraction.CIL.Entities
static Namespace? createParentNamespace(Context cx, string fqn)
{
if (fqn == "") return null;
if (fqn.Length == 0) return null;
var i = fqn.LastIndexOf('.');
return i == -1 ? cx.GlobalNamespace : cx.Populate(new Namespace(cx, fqn.Substring(0, i)));
}

View File

@@ -70,9 +70,9 @@ namespace Semmle.Extraction.CSharp.Standalone
output.Log(Severity.Info, "Running C# standalone extractor");
using var a = new Analysis(output, options);
int sourceFiles = a.Extraction.Sources.Count();
int sourceFileCount = a.Extraction.Sources.Count;
if (sourceFiles == 0)
if (sourceFileCount == 0)
{
output.Log(Severity.Error, "No source files found");
return 1;