mirror of
https://github.com/github/codeql.git
synced 2026-04-27 09:45:15 +02:00
Merge pull request #4472 from tamasvajk/feature/cleanup-3
C#: Change public fields to properties
This commit is contained in:
@@ -20,15 +20,15 @@ namespace Semmle.Autobuild.CSharp.Tests
|
||||
/// <summary>
|
||||
/// List of strings passed to FileDelete.
|
||||
/// </summary>
|
||||
public readonly IList<string> FileDeleteIn = new List<string>();
|
||||
public IList<string> FileDeleteIn { get; } = new List<string>();
|
||||
|
||||
void IBuildActions.FileDelete(string file)
|
||||
{
|
||||
FileDeleteIn.Add(file);
|
||||
}
|
||||
|
||||
public readonly IList<string> FileExistsIn = new List<string>();
|
||||
public readonly IDictionary<string, bool> FileExists = new Dictionary<string, bool>();
|
||||
public IList<string> FileExistsIn { get; } = new List<string>();
|
||||
public IDictionary<string, bool> FileExists { get; } = new Dictionary<string, bool>();
|
||||
|
||||
bool IBuildActions.FileExists(string file)
|
||||
{
|
||||
@@ -42,12 +42,12 @@ namespace Semmle.Autobuild.CSharp.Tests
|
||||
throw new ArgumentException("Missing FileExists " + file);
|
||||
}
|
||||
|
||||
public readonly IList<string> RunProcessIn = new List<string>();
|
||||
public readonly IDictionary<string, int> RunProcess = new Dictionary<string, int>();
|
||||
public readonly IDictionary<string, string> RunProcessOut = new Dictionary<string, string>();
|
||||
public readonly IDictionary<string, string> RunProcessWorkingDirectory = new Dictionary<string, string>();
|
||||
public readonly HashSet<string> CreateDirectories = new HashSet<string>();
|
||||
public readonly HashSet<(string, string)> DownloadFiles = new HashSet<(string, string)>();
|
||||
public IList<string> RunProcessIn { get; } = new List<string>();
|
||||
public IDictionary<string, int> RunProcess { get; } = new Dictionary<string, int>();
|
||||
public IDictionary<string, string> RunProcessOut { get; } = new Dictionary<string, string>();
|
||||
public IDictionary<string, string> RunProcessWorkingDirectory { get; } = new Dictionary<string, string>();
|
||||
public HashSet<string> CreateDirectories { get; } = new HashSet<string>();
|
||||
public HashSet<(string, string)> DownloadFiles { get; } = new HashSet<(string, string)>();
|
||||
|
||||
int IBuildActions.RunProcess(string cmd, string args, string? workingDirectory, IDictionary<string, string>? env, out IList<string> stdOut)
|
||||
{
|
||||
@@ -85,14 +85,14 @@ namespace Semmle.Autobuild.CSharp.Tests
|
||||
return ret;
|
||||
}
|
||||
|
||||
public readonly IList<string> DirectoryDeleteIn = new List<string>();
|
||||
public IList<string> DirectoryDeleteIn { get; } = new List<string>();
|
||||
|
||||
void IBuildActions.DirectoryDelete(string dir, bool recursive)
|
||||
{
|
||||
DirectoryDeleteIn.Add(dir);
|
||||
}
|
||||
|
||||
public readonly IDictionary<string, bool> DirectoryExists = new Dictionary<string, bool>();
|
||||
public IDictionary<string, bool> DirectoryExists { get; } = new Dictionary<string, bool>();
|
||||
|
||||
bool IBuildActions.DirectoryExists(string dir)
|
||||
{
|
||||
@@ -102,7 +102,7 @@ namespace Semmle.Autobuild.CSharp.Tests
|
||||
return ret;
|
||||
}
|
||||
|
||||
public readonly IDictionary<string, string?> GetEnvironmentVariable = new Dictionary<string, string?>();
|
||||
public IDictionary<string, string?> GetEnvironmentVariable { get; } = new Dictionary<string, string?>();
|
||||
|
||||
string? IBuildActions.GetEnvironmentVariable(string name)
|
||||
{
|
||||
@@ -112,14 +112,14 @@ namespace Semmle.Autobuild.CSharp.Tests
|
||||
return ret;
|
||||
}
|
||||
|
||||
public string GetCurrentDirectory = "";
|
||||
public string GetCurrentDirectory { get; set; } = "";
|
||||
|
||||
string IBuildActions.GetCurrentDirectory()
|
||||
{
|
||||
return GetCurrentDirectory;
|
||||
}
|
||||
|
||||
public readonly IDictionary<string, string> EnumerateFiles = new Dictionary<string, string>();
|
||||
public IDictionary<string, string> EnumerateFiles { get; } = new Dictionary<string, string>();
|
||||
|
||||
IEnumerable<string> IBuildActions.EnumerateFiles(string dir)
|
||||
{
|
||||
@@ -129,7 +129,7 @@ namespace Semmle.Autobuild.CSharp.Tests
|
||||
return str.Split("\n").Select(p => PathCombine(dir, p));
|
||||
}
|
||||
|
||||
public readonly IDictionary<string, string> EnumerateDirectories = new Dictionary<string, string>();
|
||||
public IDictionary<string, string> EnumerateDirectories { get; } = new Dictionary<string, string>();
|
||||
|
||||
IEnumerable<string> IBuildActions.EnumerateDirectories(string dir)
|
||||
{
|
||||
@@ -141,7 +141,7 @@ namespace Semmle.Autobuild.CSharp.Tests
|
||||
: str.Split("\n").Select(p => PathCombine(dir, p));
|
||||
}
|
||||
|
||||
public bool IsWindows;
|
||||
public bool IsWindows { get; set; }
|
||||
|
||||
bool IBuildActions.IsWindows() => IsWindows;
|
||||
|
||||
@@ -164,7 +164,7 @@ namespace Semmle.Autobuild.CSharp.Tests
|
||||
{
|
||||
}
|
||||
|
||||
public readonly IDictionary<string, XmlDocument> LoadXml = new Dictionary<string, XmlDocument>();
|
||||
public IDictionary<string, XmlDocument> LoadXml { get; } = new Dictionary<string, XmlDocument>();
|
||||
|
||||
XmlDocument IBuildActions.LoadXml(string filename)
|
||||
{
|
||||
|
||||
@@ -227,6 +227,6 @@ namespace Semmle.Autobuild.Shared
|
||||
public void DownloadFile(string address, string fileName) =>
|
||||
DownloadFileAsync(address, fileName).Wait();
|
||||
|
||||
public static readonly IBuildActions Instance = new SystemBuildActions();
|
||||
public static IBuildActions Instance { get; } = new SystemBuildActions();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,13 +232,13 @@ namespace Semmle.Autobuild.Shared
|
||||
/// <summary>
|
||||
/// The empty build script that always returns exit code 0.
|
||||
/// </summary>
|
||||
public static readonly BuildScript Success = Create(actions => successCode);
|
||||
public static BuildScript Success { get; } = Create(actions => successCode);
|
||||
|
||||
private const int failureCode = 1;
|
||||
/// <summary>
|
||||
/// The empty build script that always returns exit code 1.
|
||||
/// </summary>
|
||||
public static readonly BuildScript Failure = Create(actions => failureCode);
|
||||
public static BuildScript Failure { get; } = Create(actions => failureCode);
|
||||
|
||||
private static bool Succeeded(int i) => i == successCode;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Semmle.Extraction.CIL.Driver
|
||||
/// </summary>
|
||||
internal class AssemblyInfo
|
||||
{
|
||||
public override string ToString() => filename;
|
||||
public override string ToString() => Filename;
|
||||
|
||||
private static AssemblyName CreateAssemblyName(MetadataReader mdReader, StringHandle name, System.Version version, StringHandle culture)
|
||||
{
|
||||
@@ -59,7 +59,7 @@ namespace Semmle.Extraction.CIL.Driver
|
||||
/// </exception>
|
||||
public AssemblyInfo(string path)
|
||||
{
|
||||
filename = path;
|
||||
Filename = path;
|
||||
|
||||
// Attempt to open the file and see if it's a valid assembly.
|
||||
using var stream = File.OpenRead(path);
|
||||
@@ -75,9 +75,9 @@ namespace Semmle.Extraction.CIL.Driver
|
||||
throw new InvalidAssemblyException();
|
||||
|
||||
// Get our own assembly name
|
||||
name = CreateAssemblyName(mdReader, mdReader.GetAssemblyDefinition());
|
||||
Name = CreateAssemblyName(mdReader, mdReader.GetAssemblyDefinition());
|
||||
|
||||
references = mdReader.AssemblyReferences
|
||||
References = mdReader.AssemblyReferences
|
||||
.Select(r => mdReader.GetAssemblyReference(r))
|
||||
.Select(ar => CreateAssemblyName(mdReader, ar))
|
||||
.ToArray();
|
||||
@@ -91,10 +91,10 @@ namespace Semmle.Extraction.CIL.Driver
|
||||
}
|
||||
}
|
||||
|
||||
public readonly AssemblyName name;
|
||||
public readonly string filename;
|
||||
public bool extract;
|
||||
public readonly AssemblyName[] references;
|
||||
public AssemblyName Name { get; }
|
||||
public string Filename { get; }
|
||||
public bool Extract { get; set; }
|
||||
public AssemblyName[] References { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -125,19 +125,19 @@ namespace Semmle.Extraction.CIL.Driver
|
||||
{
|
||||
var info = new AssemblyInfo(assemblyPath)
|
||||
{
|
||||
extract = extractAll
|
||||
Extract = extractAll
|
||||
};
|
||||
if (!assembliesRead.ContainsKey(info.name))
|
||||
assembliesRead.Add(info.name, info);
|
||||
if (!assembliesRead.ContainsKey(info.Name))
|
||||
assembliesRead.Add(info.Name, info);
|
||||
}
|
||||
catch (InvalidAssemblyException)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<AssemblyInfo> AssembliesToExtract => assembliesRead.Values.Where(info => info.extract);
|
||||
public IEnumerable<AssemblyInfo> AssembliesToExtract => assembliesRead.Values.Where(info => info.Extract);
|
||||
|
||||
private IEnumerable<AssemblyName> AssembliesToReference => AssembliesToExtract.SelectMany(info => info.references);
|
||||
private IEnumerable<AssemblyName> AssembliesToReference => AssembliesToExtract.SelectMany(info => info.References);
|
||||
|
||||
public void ResolveReferences()
|
||||
{
|
||||
@@ -148,22 +148,22 @@ namespace Semmle.Extraction.CIL.Driver
|
||||
var item = assembliesToReference.Pop();
|
||||
if (assembliesRead.TryGetValue(item, out var info))
|
||||
{
|
||||
if (!info.extract)
|
||||
if (!info.Extract)
|
||||
{
|
||||
info.extract = true;
|
||||
foreach (var reference in info.references)
|
||||
info.Extract = true;
|
||||
foreach (var reference in info.References)
|
||||
assembliesToReference.Push(reference);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
missingReferences.Add(item);
|
||||
MissingReferences.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private readonly HashSet<string> filesAnalyzed = new HashSet<string>();
|
||||
public readonly HashSet<AssemblyName> missingReferences = new HashSet<AssemblyName>();
|
||||
public HashSet<AssemblyName> MissingReferences {get;} = new HashSet<AssemblyName>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -235,7 +235,7 @@ namespace Semmle.Extraction.CIL.Driver
|
||||
/// extracted. This is not an error, it just means that the database is not
|
||||
/// as complete as it could be.
|
||||
/// </summary>
|
||||
public IEnumerable<AssemblyName> MissingReferences => assemblyList.missingReferences;
|
||||
public IEnumerable<AssemblyName> MissingReferences => assemblyList.MissingReferences;
|
||||
|
||||
private void ParseArgs(string[] args)
|
||||
{
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Semmle.Extraction.CIL.Driver
|
||||
using var logger = new ConsoleLogger(options.Verbosity);
|
||||
|
||||
var actions = options.AssembliesToExtract
|
||||
.Select(asm => asm.filename)
|
||||
.Select(asm => asm.Filename)
|
||||
.Select<string, Action>(filename =>
|
||||
() => ExtractAssembly(layout, filename, logger, options.NoCache, options.PDB, options.TrapCompression))
|
||||
.ToArray();
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// <summary>
|
||||
/// For each Payload, how many additional bytes in the bytestream need to be read.
|
||||
/// </summary>
|
||||
internal static readonly int[] payloadSizes = {
|
||||
private static readonly int[] payloadSizes = {
|
||||
0, 4, 4, 1, 4,
|
||||
4, 1, 1, 4, 1,
|
||||
2, 4, 8, 4, 8,
|
||||
@@ -46,7 +46,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
4, 2, 1, 4, 2, 4 };
|
||||
|
||||
// Maps opcodes to payloads for each instruction.
|
||||
public static readonly Dictionary<ILOpCode, Payload> opPayload = new Dictionary<ILOpCode, Payload>()
|
||||
private static readonly Dictionary<ILOpCode, Payload> opPayload = new Dictionary<ILOpCode, Payload>()
|
||||
{
|
||||
{ ILOpCode.Nop, Payload.None },
|
||||
{ ILOpCode.Break, Payload.None },
|
||||
@@ -268,10 +268,10 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
{ ILOpCode.Readonly, Payload.None }
|
||||
};
|
||||
|
||||
public readonly DefinitionMethod Method;
|
||||
public readonly ILOpCode OpCode;
|
||||
public readonly int Offset;
|
||||
public readonly int Index;
|
||||
public DefinitionMethod Method { get; }
|
||||
public ILOpCode OpCode { get; }
|
||||
public int Offset { get; }
|
||||
public int Index { get; }
|
||||
private readonly int payloadValue;
|
||||
private readonly uint unsignedPayloadValue;
|
||||
|
||||
|
||||
@@ -12,11 +12,11 @@ namespace Semmle.Extraction.CSharp.Standalone
|
||||
{
|
||||
public Extraction(string directory)
|
||||
{
|
||||
this.directory = directory;
|
||||
Directory = directory;
|
||||
}
|
||||
|
||||
public readonly string directory;
|
||||
public readonly List<string> Sources = new List<string>();
|
||||
public string Directory { get; }
|
||||
public List<string> Sources { get; } = new List<string>();
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
private class AccessorFactory : ICachedEntityFactory<IMethodSymbol, Accessor>
|
||||
{
|
||||
public static readonly AccessorFactory Instance = new AccessorFactory();
|
||||
public static AccessorFactory Instance { get; } = new AccessorFactory();
|
||||
|
||||
public Accessor Create(Context cx, IMethodSymbol init) => new Accessor(cx, init);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
private class CommentBlockFactory : ICachedEntityFactory<ICommentBlock, CommentBlock>
|
||||
{
|
||||
public static readonly CommentBlockFactory Instance = new CommentBlockFactory();
|
||||
public static CommentBlockFactory Instance { get; } = new CommentBlockFactory();
|
||||
|
||||
public CommentBlock Create(Context cx, ICommentBlock init) => new CommentBlock(cx, init);
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
private class CommentLineFactory : ICachedEntityFactory<(Microsoft.CodeAnalysis.Location, CommentLineType, string, string), CommentLine>
|
||||
{
|
||||
public static readonly CommentLineFactory Instance = new CommentLineFactory();
|
||||
public static CommentLineFactory Instance { get; } = new CommentLineFactory();
|
||||
|
||||
public CommentLine Create(Context cx, (Microsoft.CodeAnalysis.Location, CommentLineType, string, string) init) =>
|
||||
new CommentLine(cx, init.Item1, init.Item2, init.Item3, init.Item4);
|
||||
|
||||
@@ -147,7 +147,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
private class ConstructorFactory : ICachedEntityFactory<IMethodSymbol, Constructor>
|
||||
{
|
||||
public static readonly ConstructorFactory Instance = new ConstructorFactory();
|
||||
public static ConstructorFactory Instance { get; } = new ConstructorFactory();
|
||||
|
||||
public Constructor Create(Context cx, IMethodSymbol init) => new Constructor(cx, init);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
private class ConversionFactory : ICachedEntityFactory<IMethodSymbol, Conversion>
|
||||
{
|
||||
public static readonly ConversionFactory Instance = new ConversionFactory();
|
||||
public static ConversionFactory Instance { get; } = new ConversionFactory();
|
||||
|
||||
public Conversion Create(Context cx, IMethodSymbol init) => new Conversion(cx, init);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
private class DestructorFactory : ICachedEntityFactory<IMethodSymbol, Destructor>
|
||||
{
|
||||
public static readonly DestructorFactory Instance = new DestructorFactory();
|
||||
public static DestructorFactory Instance { get; } = new DestructorFactory();
|
||||
|
||||
public Destructor Create(Context cx, IMethodSymbol init) => new Destructor(cx, init);
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
private class EventFactory : ICachedEntityFactory<IEventSymbol, Event>
|
||||
{
|
||||
public static readonly EventFactory Instance = new EventFactory();
|
||||
public static EventFactory Instance { get; } = new EventFactory();
|
||||
|
||||
public Event Create(Context cx, IEventSymbol init) => new Event(cx, init);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
private class EventAccessorFactory : ICachedEntityFactory<IMethodSymbol, EventAccessor>
|
||||
{
|
||||
public static readonly EventAccessorFactory Instance = new EventAccessorFactory();
|
||||
public static EventAccessorFactory Instance { get; } = new EventAccessorFactory();
|
||||
|
||||
public EventAccessor Create(Context cx, IMethodSymbol init) => new EventAccessor(cx, init);
|
||||
}
|
||||
|
||||
@@ -20,9 +20,9 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
internal class Expression : FreshEntity, IExpressionParentEntity
|
||||
{
|
||||
private readonly IExpressionInfo info;
|
||||
public readonly AnnotatedType Type;
|
||||
public readonly Extraction.Entities.Location Location;
|
||||
public readonly ExprKind Kind;
|
||||
public AnnotatedType Type { get; }
|
||||
public Extraction.Entities.Location Location { get; }
|
||||
public ExprKind Kind { get; }
|
||||
|
||||
internal Expression(IExpressionInfo info)
|
||||
: base(info.Context)
|
||||
@@ -294,7 +294,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
internal abstract class Expression<TExpressionSyntax> : Expression
|
||||
where TExpressionSyntax : ExpressionSyntax
|
||||
{
|
||||
public readonly TExpressionSyntax Syntax;
|
||||
public TExpressionSyntax Syntax { get; }
|
||||
|
||||
protected Expression(ExpressionNodeInfo info)
|
||||
: base(info)
|
||||
|
||||
@@ -131,7 +131,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
private class FieldFactory : ICachedEntityFactory<IFieldSymbol, Field>
|
||||
{
|
||||
public static readonly FieldFactory Instance = new FieldFactory();
|
||||
public static FieldFactory Instance { get; } = new FieldFactory();
|
||||
|
||||
public Field Create(Context cx, IFieldSymbol init) => new Field(cx, init);
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
private class IndexerFactory : ICachedEntityFactory<IPropertySymbol, Indexer>
|
||||
{
|
||||
public static readonly IndexerFactory Instance = new IndexerFactory();
|
||||
public static IndexerFactory Instance { get; } = new IndexerFactory();
|
||||
|
||||
public Indexer Create(Context cx, IPropertySymbol init) => new Indexer(cx, init);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
private class LocalFunctionFactory : ICachedEntityFactory<IMethodSymbol, LocalFunction>
|
||||
{
|
||||
public static readonly LocalFunctionFactory Instance = new LocalFunctionFactory();
|
||||
public static LocalFunctionFactory Instance { get; } = new LocalFunctionFactory();
|
||||
|
||||
public LocalFunction Create(Context cx, IMethodSymbol init) => new LocalFunction(cx, init);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
private class LocalVariableFactory : ICachedEntityFactory<ISymbol, LocalVariable>
|
||||
{
|
||||
public static readonly LocalVariableFactory Instance = new LocalVariableFactory();
|
||||
public static LocalVariableFactory Instance { get; } = new LocalVariableFactory();
|
||||
|
||||
public LocalVariable Create(Context cx, ISymbol init) => new LocalVariable(cx, init);
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
private class ModifierFactory : ICachedEntityFactory<string, Modifier>
|
||||
{
|
||||
public static readonly ModifierFactory Instance = new ModifierFactory();
|
||||
public static ModifierFactory Instance { get; } = new ModifierFactory();
|
||||
|
||||
public Modifier Create(Context cx, string init) => new Modifier(cx, init);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
private class NamespaceFactory : ICachedEntityFactory<INamespaceSymbol, Namespace>
|
||||
{
|
||||
public static readonly NamespaceFactory Instance = new NamespaceFactory();
|
||||
public static NamespaceFactory Instance { get; } = new NamespaceFactory();
|
||||
|
||||
public Namespace Create(Context cx, INamespaceSymbol init) => new Namespace(cx, init);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
private class OrdinaryMethodFactory : ICachedEntityFactory<IMethodSymbol, OrdinaryMethod>
|
||||
{
|
||||
public static readonly OrdinaryMethodFactory Instance = new OrdinaryMethodFactory();
|
||||
public static OrdinaryMethodFactory Instance { get; } = new OrdinaryMethodFactory();
|
||||
|
||||
public OrdinaryMethod Create(Context cx, IMethodSymbol init) => new OrdinaryMethod(cx, init);
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
private class ParameterFactory : ICachedEntityFactory<(IParameterSymbol, IEntity, Parameter), Parameter>
|
||||
{
|
||||
public static readonly ParameterFactory Instance = new ParameterFactory();
|
||||
public static ParameterFactory Instance { get; } = new ParameterFactory();
|
||||
|
||||
public Parameter Create(Context cx, (IParameterSymbol, IEntity, Parameter) init) => new Parameter(cx, init.Item1, init.Item2, init.Item3);
|
||||
}
|
||||
@@ -212,7 +212,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
private class VarargsTypeFactory : ICachedEntityFactory<string, VarargsType>
|
||||
{
|
||||
public static readonly VarargsTypeFactory Instance = new VarargsTypeFactory();
|
||||
public static VarargsTypeFactory Instance { get; } = new VarargsTypeFactory();
|
||||
|
||||
public VarargsType Create(Context cx, string init) => new VarargsType(cx);
|
||||
}
|
||||
@@ -247,7 +247,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
private class VarargsParamFactory : ICachedEntityFactory<Method, VarargsParam>
|
||||
{
|
||||
public static readonly VarargsParamFactory Instance = new VarargsParamFactory();
|
||||
public static VarargsParamFactory Instance { get; } = new VarargsParamFactory();
|
||||
|
||||
public VarargsParam Create(Context cx, Method init) => new VarargsParam(cx, init);
|
||||
}
|
||||
@@ -275,7 +275,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
private class ExtensionParamFactory : ICachedEntityFactory<(Method, Parameter), ConstructedExtensionParameter>
|
||||
{
|
||||
public static readonly ExtensionParamFactory Instance = new ExtensionParamFactory();
|
||||
public static ExtensionParamFactory Instance { get; } = new ExtensionParamFactory();
|
||||
|
||||
public ConstructedExtensionParameter Create(Context cx, (Method, Parameter) init) =>
|
||||
new ConstructedExtensionParameter(cx, init.Item1, init.Item2);
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
private class PropertyFactory : ICachedEntityFactory<IPropertySymbol, Property>
|
||||
{
|
||||
public static readonly PropertyFactory Instance = new PropertyFactory();
|
||||
public static PropertyFactory Instance { get; } = new PropertyFactory();
|
||||
|
||||
public Property Create(Context cx, IPropertySymbol init) => new Property(cx, init);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Semmle.Extraction.CSharp.Entities.Statements
|
||||
internal class Switch : Statement<SwitchStatementSyntax>
|
||||
{
|
||||
private static readonly object nullLabel = new object();
|
||||
public static readonly object DefaultLabel = new object();
|
||||
public static object DefaultLabel { get; } = new object();
|
||||
|
||||
// Sometimes, the literal "null" is used as a label.
|
||||
// This is inconveniently represented by the "null" object.
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
private class ArrayTypeFactory : ICachedEntityFactory<IArrayTypeSymbol, ArrayType>
|
||||
{
|
||||
public static readonly ArrayTypeFactory Instance = new ArrayTypeFactory();
|
||||
public static ArrayTypeFactory Instance { get; } = new ArrayTypeFactory();
|
||||
|
||||
public ArrayType Create(Context cx, IArrayTypeSymbol init) => new ArrayType(cx, init);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
private class DynamicTypeFactory : ICachedEntityFactory<IDynamicTypeSymbol, DynamicType>
|
||||
{
|
||||
public static readonly DynamicTypeFactory Instance = new DynamicTypeFactory();
|
||||
public static DynamicTypeFactory Instance { get; } = new DynamicTypeFactory();
|
||||
|
||||
public DynamicType Create(Context cx, IDynamicTypeSymbol init) => new DynamicType(cx, init);
|
||||
}
|
||||
|
||||
@@ -176,14 +176,14 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
private class NamedTypeFactory : ICachedEntityFactory<INamedTypeSymbol, NamedType>
|
||||
{
|
||||
public static readonly NamedTypeFactory Instance = new NamedTypeFactory();
|
||||
public static NamedTypeFactory Instance { get; } = new NamedTypeFactory();
|
||||
|
||||
public NamedType Create(Context cx, INamedTypeSymbol init) => new NamedType(cx, init, false);
|
||||
}
|
||||
|
||||
private class UnderlyingTupleTypeFactory : ICachedEntityFactory<INamedTypeSymbol, NamedType>
|
||||
{
|
||||
public static readonly UnderlyingTupleTypeFactory Instance = new UnderlyingTupleTypeFactory();
|
||||
public static UnderlyingTupleTypeFactory Instance { get; } = new UnderlyingTupleTypeFactory();
|
||||
|
||||
public NamedType Create(Context cx, INamedTypeSymbol init) => new NamedType(cx, init, true);
|
||||
}
|
||||
@@ -213,7 +213,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
private class NamedTypeRefFactory : ICachedEntityFactory<INamedTypeSymbol, NamedTypeRef>
|
||||
{
|
||||
public static readonly NamedTypeRefFactory Instance = new NamedTypeRefFactory();
|
||||
public static NamedTypeRefFactory Instance { get; } = new NamedTypeRefFactory();
|
||||
|
||||
public NamedTypeRef Create(Context cx, INamedTypeSymbol init) => new NamedTypeRef(cx, init);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
private class NullTypeFactory : ICachedEntityFactory<ITypeSymbol, NullType>
|
||||
{
|
||||
public static readonly NullTypeFactory Instance = new NullTypeFactory();
|
||||
public static NullTypeFactory Instance { get; } = new NullTypeFactory();
|
||||
|
||||
public NullType Create(Context cx, ITypeSymbol init) => new NullType(cx);
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
private class NullabilityFactory : ICachedEntityFactory<Nullability, NullabilityEntity>
|
||||
{
|
||||
public static readonly NullabilityFactory Instance = new NullabilityFactory();
|
||||
public static NullabilityFactory Instance { get; } = new NullabilityFactory();
|
||||
|
||||
public NullabilityEntity Create(Context cx, Nullability init) => new NullabilityEntity(cx, init);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
private class PointerTypeFactory : ICachedEntityFactory<IPointerTypeSymbol, PointerType>
|
||||
{
|
||||
public static readonly PointerTypeFactory Instance = new PointerTypeFactory();
|
||||
public static PointerTypeFactory Instance { get; } = new PointerTypeFactory();
|
||||
|
||||
public PointerType Create(Context cx, IPointerTypeSymbol init) => new PointerType(cx, init);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
private class TupleTypeFactory : ICachedEntityFactory<INamedTypeSymbol, TupleType>
|
||||
{
|
||||
public static readonly TupleTypeFactory Instance = new TupleTypeFactory();
|
||||
public static TupleTypeFactory Instance { get; } = new TupleTypeFactory();
|
||||
|
||||
public TupleType Create(Context cx, INamedTypeSymbol init) => new TupleType(cx, init);
|
||||
}
|
||||
|
||||
@@ -305,7 +305,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
private class DelegateTypeParameterFactory : ICachedEntityFactory<(IParameterSymbol, IEntity, Parameter), DelegateTypeParameter>
|
||||
{
|
||||
public static readonly DelegateTypeParameterFactory Instance = new DelegateTypeParameterFactory();
|
||||
public static DelegateTypeParameterFactory Instance { get; } = new DelegateTypeParameterFactory();
|
||||
|
||||
public DelegateTypeParameter Create(Context cx, (IParameterSymbol, IEntity, Parameter) init) =>
|
||||
new DelegateTypeParameter(cx, init.Item1, init.Item2, init.Item3);
|
||||
|
||||
@@ -129,7 +129,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
private class TypeParameterFactory : ICachedEntityFactory<ITypeParameterSymbol, TypeParameter>
|
||||
{
|
||||
public static readonly TypeParameterFactory Instance = new TypeParameterFactory();
|
||||
public static TypeParameterFactory Instance { get; } = new TypeParameterFactory();
|
||||
|
||||
public TypeParameter Create(Context cx, ITypeParameterSymbol init) => new TypeParameter(cx, init);
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
private class UserOperatorFactory : ICachedEntityFactory<IMethodSymbol, UserOperator>
|
||||
{
|
||||
public static readonly UserOperatorFactory Instance = new UserOperatorFactory();
|
||||
public static UserOperatorFactory Instance { get; } = new UserOperatorFactory();
|
||||
|
||||
public UserOperator Create(Context cx, IMethodSymbol init) => new UserOperator(cx, init);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Semmle.Extraction.Entities
|
||||
|
||||
private class AssemblyConstructorFactory : ICachedEntityFactory<Microsoft.CodeAnalysis.Location?, Assembly>
|
||||
{
|
||||
public static readonly AssemblyConstructorFactory Instance = new AssemblyConstructorFactory();
|
||||
public static AssemblyConstructorFactory Instance { get; } = new AssemblyConstructorFactory();
|
||||
|
||||
public Assembly Create(Context cx, Microsoft.CodeAnalysis.Location? init) => new Assembly(cx, init);
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace Semmle.Extraction.Entities
|
||||
|
||||
private class GeneratedFileFactory : ICachedEntityFactory<string?, GeneratedFile>
|
||||
{
|
||||
public static readonly GeneratedFileFactory Instance = new GeneratedFileFactory();
|
||||
public static GeneratedFileFactory Instance { get; } = new GeneratedFileFactory();
|
||||
|
||||
public GeneratedFile Create(Context cx, string? init) => new GeneratedFile(cx);
|
||||
}
|
||||
@@ -88,7 +88,7 @@ namespace Semmle.Extraction.Entities
|
||||
|
||||
private class FileFactory : ICachedEntityFactory<string, File>
|
||||
{
|
||||
public static readonly FileFactory Instance = new FileFactory();
|
||||
public static FileFactory Instance { get; } = new FileFactory();
|
||||
|
||||
public File Create(Context cx, string init) => new File(cx, init);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Semmle.Extraction.Entities
|
||||
|
||||
private class FolderFactory : ICachedEntityFactory<PathTransformer.ITransformedPath, Folder>
|
||||
{
|
||||
public static readonly FolderFactory Instance = new FolderFactory();
|
||||
public static FolderFactory Instance { get; } = new FolderFactory();
|
||||
|
||||
public Folder Create(Context cx, PathTransformer.ITransformedPath init) => new Folder(cx, init);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Semmle.Extraction.Entities
|
||||
|
||||
private class GeneratedLocationFactory : ICachedEntityFactory<string?, GeneratedLocation>
|
||||
{
|
||||
public static readonly GeneratedLocationFactory Instance = new GeneratedLocationFactory();
|
||||
public static GeneratedLocationFactory Instance { get; } = new GeneratedLocationFactory();
|
||||
|
||||
public GeneratedLocation Create(Context cx, string? init) => new GeneratedLocation(cx);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace Semmle.Extraction.Entities
|
||||
|
||||
private class SourceLocationFactory : ICachedEntityFactory<Microsoft.CodeAnalysis.Location, SourceLocation>
|
||||
{
|
||||
public static readonly SourceLocationFactory Instance = new SourceLocationFactory();
|
||||
public static SourceLocationFactory Instance { get; } = new SourceLocationFactory();
|
||||
|
||||
public SourceLocation Create(Context cx, Microsoft.CodeAnalysis.Location init) => new NonGeneratedSourceLocation(cx, init);
|
||||
}
|
||||
|
||||
@@ -101,11 +101,6 @@ namespace Semmle.Extraction
|
||||
/// </summary>
|
||||
public class Extractor : IExtractor
|
||||
{
|
||||
/// <summary>
|
||||
/// The default number of threads to use for extraction.
|
||||
/// </summary>
|
||||
public static readonly int DefaultNumberOfThreads = Environment.ProcessorCount;
|
||||
|
||||
public bool Standalone
|
||||
{
|
||||
get; private set;
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace Semmle.Extraction
|
||||
|
||||
public int Value { get; private set; }
|
||||
|
||||
public static readonly Label InvalidLabel = new Label(0);
|
||||
public static Label InvalidLabel { get; } = new Label(0);
|
||||
|
||||
public bool Valid => Value > 0;
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ namespace Semmle.Extraction
|
||||
{
|
||||
private readonly List<FilePattern> filePatterns = new List<FilePattern>();
|
||||
|
||||
public readonly Layout.SubProject Directories;
|
||||
public Layout.SubProject Directories { get; }
|
||||
|
||||
private static string? ReadVariable(string name, string line)
|
||||
{
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Semmle.Extraction
|
||||
/// <summary>
|
||||
/// The specified number of threads, or the default if unspecified.
|
||||
/// </summary>
|
||||
public int Threads { get; private set; } = Extractor.DefaultNumberOfThreads;
|
||||
public int Threads { get; private set; } = System.Environment.ProcessorCount;
|
||||
|
||||
/// <summary>
|
||||
/// The verbosity used in output and logging.
|
||||
|
||||
Reference in New Issue
Block a user