mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
C#: Address more review comments
This commit is contained in:
@@ -89,8 +89,7 @@ namespace Semmle.Extraction.Entities
|
||||
|
||||
public static string PathAsDatabaseString(string path) => path.Replace('\\', '/');
|
||||
|
||||
static readonly object cacheKey = new object();
|
||||
public static File Create(Context cx, string path) => FileFactory.Instance.CreateEntity(cx, (cacheKey, path), path);
|
||||
public static File Create(Context cx, string path) => FileFactory.Instance.CreateEntity(cx, (typeof(File), path), path);
|
||||
|
||||
public static File CreateGenerated(Context cx) => GeneratedFile.Create(cx);
|
||||
|
||||
@@ -112,7 +111,7 @@ namespace Semmle.Extraction.Entities
|
||||
}
|
||||
|
||||
public static GeneratedFile Create(Context cx) =>
|
||||
GeneratedFileFactory.Instance.CreateEntity(cx, cacheKey, null);
|
||||
GeneratedFileFactory.Instance.CreateEntity(cx, typeof(GeneratedFile), null);
|
||||
|
||||
class GeneratedFileFactory : ICachedEntityFactory<string?, GeneratedFile>
|
||||
{
|
||||
|
||||
@@ -28,8 +28,7 @@ namespace Semmle.Extraction.Entities
|
||||
|
||||
public override bool Equals(object? obj) => obj != null && obj.GetType() == typeof(GeneratedLocation);
|
||||
|
||||
static readonly object cacheKey = new object();
|
||||
public static GeneratedLocation Create(Context cx) => GeneratedLocationFactory.Instance.CreateEntity(cx, cacheKey, null);
|
||||
public static GeneratedLocation Create(Context cx) => GeneratedLocationFactory.Instance.CreateEntity(cx, typeof(GeneratedLocation), null);
|
||||
|
||||
class GeneratedLocationFactory : ICachedEntityFactory<string?, GeneratedLocation>
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.IO;
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
namespace Semmle.Extraction
|
||||
{
|
||||
@@ -75,4 +76,20 @@ namespace Semmle.Extraction
|
||||
|
||||
public abstract TrapStackBehaviour TrapStackBehaviour { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A class used to wrap an `ISymbol` object, which uses `SymbolEqualityComparer.Default`
|
||||
/// for comparison.
|
||||
/// </summary>
|
||||
public sealed class SymbolEqualityWrapper
|
||||
{
|
||||
public ISymbol Symbol { get; }
|
||||
|
||||
public SymbolEqualityWrapper(ISymbol symbol) { Symbol = symbol; }
|
||||
|
||||
public override bool Equals(object? other) =>
|
||||
other is SymbolEqualityWrapper sew && SymbolEqualityComparer.Default.Equals(Symbol, sew.Symbol);
|
||||
|
||||
public override int GetHashCode() => 11 * Symbol.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user