mirror of
https://github.com/github/codeql.git
synced 2026-04-18 21:44:02 +02:00
C#: Add declaration visibility modifiers
This commit is contained in:
@@ -15,7 +15,7 @@ namespace Semmle.Autobuild.CSharp.Tests
|
||||
/// - an IList to capture the the arguments passed to it
|
||||
/// - an IDictionary of possible return values.
|
||||
/// </summary>
|
||||
class TestActions : IBuildActions
|
||||
internal class TestActions : IBuildActions
|
||||
{
|
||||
/// <summary>
|
||||
/// List of strings passed to FileDelete.
|
||||
@@ -197,7 +197,7 @@ namespace Semmle.Autobuild.CSharp.Tests
|
||||
/// <summary>
|
||||
/// A fake solution to build.
|
||||
/// </summary>
|
||||
class TestSolution : ISolution
|
||||
internal class TestSolution : ISolution
|
||||
{
|
||||
public IEnumerable<SolutionConfigurationInSolution> Configurations => throw new NotImplementedException();
|
||||
|
||||
@@ -219,21 +219,21 @@ namespace Semmle.Autobuild.CSharp.Tests
|
||||
|
||||
public class BuildScriptTests
|
||||
{
|
||||
readonly TestActions Actions = new TestActions();
|
||||
private readonly TestActions Actions = new TestActions();
|
||||
|
||||
// Records the arguments passed to StartCallback.
|
||||
readonly IList<string> StartCallbackIn = new List<string>();
|
||||
private readonly IList<string> StartCallbackIn = new List<string>();
|
||||
|
||||
void StartCallback(string s, bool silent)
|
||||
private void StartCallback(string s, bool silent)
|
||||
{
|
||||
StartCallbackIn.Add(s);
|
||||
}
|
||||
|
||||
// Records the arguments passed to EndCallback
|
||||
readonly IList<string> EndCallbackIn = new List<string>();
|
||||
readonly IList<int> EndCallbackReturn = new List<int>();
|
||||
private readonly IList<string> EndCallbackIn = new List<string>();
|
||||
private readonly IList<int> EndCallbackReturn = new List<int>();
|
||||
|
||||
void EndCallback(int ret, string s, bool silent)
|
||||
private void EndCallback(int ret, string s, bool silent)
|
||||
{
|
||||
EndCallbackReturn.Add(ret);
|
||||
EndCallbackIn.Add(s);
|
||||
@@ -372,7 +372,7 @@ namespace Semmle.Autobuild.CSharp.Tests
|
||||
Assert.Equal(0, BuildScript.Try(BuildScript.Failure).Run(Actions, StartCallback, EndCallback));
|
||||
}
|
||||
|
||||
CSharpAutobuilder CreateAutoBuilder(bool isWindows,
|
||||
private CSharpAutobuilder CreateAutoBuilder(bool isWindows,
|
||||
string? buildless = null, string? solution = null, string? buildCommand = null, string? ignoreErrors = null,
|
||||
string? msBuildArguments = null, string? msBuildPlatform = null, string? msBuildConfiguration = null, string? msBuildTarget = null,
|
||||
string? dotnetArguments = null, string? dotnetVersion = null, string? vsToolsVersion = null,
|
||||
@@ -572,7 +572,7 @@ Microsoft.NETCore.App 2.2.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.Ap
|
||||
TestAutobuilderScript(autobuilder, 0, 1);
|
||||
}
|
||||
|
||||
void SkipVsWhere()
|
||||
private void SkipVsWhere()
|
||||
{
|
||||
Actions.FileExists[@"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe"] = false;
|
||||
Actions.FileExists[@"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"] = false;
|
||||
@@ -581,7 +581,7 @@ Microsoft.NETCore.App 2.2.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.Ap
|
||||
Actions.FileExists[@"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"] = false;
|
||||
}
|
||||
|
||||
void TestAutobuilderScript(Autobuilder autobuilder, int expectedOutput, int commandsRun)
|
||||
private void TestAutobuilderScript(Autobuilder autobuilder, int expectedOutput, int commandsRun)
|
||||
{
|
||||
Assert.Equal(expectedOutput, autobuilder.GetBuildScript().Run(Actions, StartCallback, EndCallback));
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace Semmle.Autobuild.CSharp
|
||||
/// Gets the build strategy that the autobuilder should apply, based on the
|
||||
/// options in the `lgtm.yml` file.
|
||||
/// </summary>
|
||||
CSharpBuildStrategy GetCSharpBuildStrategy()
|
||||
private CSharpBuildStrategy GetCSharpBuildStrategy()
|
||||
{
|
||||
if (Options.BuildCommand != null)
|
||||
return CSharpBuildStrategy.CustomBuildCommand;
|
||||
@@ -112,7 +112,7 @@ namespace Semmle.Autobuild.CSharp
|
||||
return CSharpBuildStrategy.Auto;
|
||||
}
|
||||
|
||||
enum CSharpBuildStrategy
|
||||
private enum CSharpBuildStrategy
|
||||
{
|
||||
CustomBuildCommand,
|
||||
Buildless,
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Semmle.Autobuild.CSharp
|
||||
/// A build rule where the build command is of the form "dotnet build".
|
||||
/// Currently unused because the tracer does not work with dotnet.
|
||||
/// </summary>
|
||||
class DotNetRule : IBuildRule
|
||||
internal class DotNetRule : IBuildRule
|
||||
{
|
||||
public BuildScript Analyse(Autobuilder builder, bool auto)
|
||||
{
|
||||
@@ -57,7 +57,7 @@ namespace Semmle.Autobuild.CSharp
|
||||
});
|
||||
}
|
||||
|
||||
static BuildScript WithDotNet(Autobuilder builder, Func<string?, IDictionary<string, string>?, bool, BuildScript> f)
|
||||
private static BuildScript WithDotNet(Autobuilder builder, Func<string?, IDictionary<string, string>?, bool, BuildScript> f)
|
||||
{
|
||||
string? installDir = builder.Actions.PathCombine(builder.Options.RootDirectory, ".dotnet");
|
||||
var installScript = DownloadDotNet(builder, installDir);
|
||||
@@ -129,7 +129,7 @@ namespace Semmle.Autobuild.CSharp
|
||||
/// .NET Core SDK. The SDK(s) will be installed at <code>installDir</code>
|
||||
/// (provided that the script succeeds).
|
||||
/// </summary>
|
||||
static BuildScript DownloadDotNet(Autobuilder builder, string installDir)
|
||||
private static BuildScript DownloadDotNet(Autobuilder builder, string installDir)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(builder.Options.DotNetVersion))
|
||||
// Specific version supplied in configuration: always use that
|
||||
@@ -166,7 +166,7 @@ namespace Semmle.Autobuild.CSharp
|
||||
///
|
||||
/// See https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script.
|
||||
/// </summary>
|
||||
static BuildScript DownloadDotNetVersion(Autobuilder builder, string path, string version)
|
||||
private static BuildScript DownloadDotNetVersion(Autobuilder builder, string path, string version)
|
||||
{
|
||||
return BuildScript.Bind(GetInstalledSdksScript(builder.Actions), (sdks, sdksRet) =>
|
||||
{
|
||||
@@ -257,7 +257,7 @@ Invoke-Command -ScriptBlock $ScriptBlock";
|
||||
});
|
||||
}
|
||||
|
||||
static BuildScript GetInstalledSdksScript(IBuildActions actions)
|
||||
private static BuildScript GetInstalledSdksScript(IBuildActions actions)
|
||||
{
|
||||
var listSdks = new CommandBuilder(actions, silent: true).
|
||||
RunCommand("dotnet").
|
||||
@@ -265,10 +265,10 @@ Invoke-Command -ScriptBlock $ScriptBlock";
|
||||
return listSdks.Script;
|
||||
}
|
||||
|
||||
static string DotNetCommand(IBuildActions actions, string? dotNetPath) =>
|
||||
private static string DotNetCommand(IBuildActions actions, string? dotNetPath) =>
|
||||
dotNetPath != null ? actions.PathCombine(dotNetPath, "dotnet") : "dotnet";
|
||||
|
||||
static BuildScript GetInfoCommand(IBuildActions actions, string? dotNetPath, IDictionary<string, string>? environment)
|
||||
private static BuildScript GetInfoCommand(IBuildActions actions, string? dotNetPath, IDictionary<string, string>? environment)
|
||||
{
|
||||
var info = new CommandBuilder(actions, null, environment).
|
||||
RunCommand(DotNetCommand(actions, dotNetPath)).
|
||||
@@ -276,7 +276,7 @@ Invoke-Command -ScriptBlock $ScriptBlock";
|
||||
return info.Script;
|
||||
}
|
||||
|
||||
static CommandBuilder GetCleanCommand(IBuildActions actions, string? dotNetPath, IDictionary<string, string>? environment)
|
||||
private static CommandBuilder GetCleanCommand(IBuildActions actions, string? dotNetPath, IDictionary<string, string>? environment)
|
||||
{
|
||||
var clean = new CommandBuilder(actions, null, environment).
|
||||
RunCommand(DotNetCommand(actions, dotNetPath)).
|
||||
@@ -284,7 +284,7 @@ Invoke-Command -ScriptBlock $ScriptBlock";
|
||||
return clean;
|
||||
}
|
||||
|
||||
static CommandBuilder GetRestoreCommand(IBuildActions actions, string? dotNetPath, IDictionary<string, string>? environment)
|
||||
private static CommandBuilder GetRestoreCommand(IBuildActions actions, string? dotNetPath, IDictionary<string, string>? environment)
|
||||
{
|
||||
var restore = new CommandBuilder(actions, null, environment).
|
||||
RunCommand(DotNetCommand(actions, dotNetPath)).
|
||||
@@ -292,7 +292,7 @@ Invoke-Command -ScriptBlock $ScriptBlock";
|
||||
return restore;
|
||||
}
|
||||
|
||||
static BuildScript GetInstalledRuntimesScript(IBuildActions actions, string? dotNetPath, IDictionary<string, string>? environment)
|
||||
private static BuildScript GetInstalledRuntimesScript(IBuildActions actions, string? dotNetPath, IDictionary<string, string>? environment)
|
||||
{
|
||||
var listSdks = new CommandBuilder(actions, environment: environment, silent: true).
|
||||
RunCommand(DotNetCommand(actions, dotNetPath)).
|
||||
@@ -309,7 +309,7 @@ Invoke-Command -ScriptBlock $ScriptBlock";
|
||||
/// hence the need for CLR tracing), by adding a
|
||||
/// `/p:UseSharedCompilation=false` argument.
|
||||
/// </summary>
|
||||
static BuildScript GetBuildScript(Autobuilder builder, string? dotNetPath, IDictionary<string, string>? environment, bool compatibleClr, string projOrSln)
|
||||
private static BuildScript GetBuildScript(Autobuilder builder, string? dotNetPath, IDictionary<string, string>? environment, bool compatibleClr, string projOrSln)
|
||||
{
|
||||
var build = new CommandBuilder(builder.Actions, null, environment);
|
||||
var script = builder.MaybeIndex(build, DotNetCommand(builder.Actions, dotNetPath)).
|
||||
|
||||
@@ -3,9 +3,9 @@ using Semmle.Autobuild.Shared;
|
||||
|
||||
namespace Semmle.Autobuild.CSharp
|
||||
{
|
||||
class Program
|
||||
public static class Program
|
||||
{
|
||||
static int Main()
|
||||
public static int Main()
|
||||
{
|
||||
|
||||
try
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Semmle.Autobuild.CSharp
|
||||
/// <summary>
|
||||
/// Build using standalone extraction.
|
||||
/// </summary>
|
||||
class StandaloneBuildRule : IBuildRule
|
||||
internal class StandaloneBuildRule : IBuildRule
|
||||
{
|
||||
public BuildScript Analyse(Autobuilder builder, bool auto)
|
||||
{
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace Semmle.Autobuild.Shared
|
||||
Select(s => AsStringWithExpandedEnvVars(s, actions)).ToArray();
|
||||
}
|
||||
|
||||
static readonly Regex linuxEnvRegEx = new Regex(@"\$([a-zA-Z_][a-zA-Z_0-9]*)", RegexOptions.Compiled);
|
||||
private static readonly Regex linuxEnvRegEx = new Regex(@"\$([a-zA-Z_][a-zA-Z_0-9]*)", RegexOptions.Compiled);
|
||||
|
||||
public static string AsStringWithExpandedEnvVars(this string value, IBuildActions actions)
|
||||
{
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Semmle.Autobuild.Shared
|
||||
/// by distance in ascending order.
|
||||
/// </summary>
|
||||
public IEnumerable<(string, int)> Paths => pathsLazy.Value;
|
||||
readonly Lazy<IEnumerable<(string, int)>> pathsLazy;
|
||||
private readonly Lazy<IEnumerable<(string, int)>> pathsLazy;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of paths matching a set of extensions (including the "."),
|
||||
@@ -91,7 +91,7 @@ namespace Semmle.Autobuild.Shared
|
||||
/// <returns>True iff the path was found.</returns>
|
||||
public bool HasPath(string path) => Paths.Any(p => path == p.Item1);
|
||||
|
||||
void FindFiles(string dir, int depth, int maxDepth, IList<(string, int)> results)
|
||||
private void FindFiles(string dir, int depth, int maxDepth, IList<(string, int)> results)
|
||||
{
|
||||
foreach (var f in Actions.EnumerateFiles(dir))
|
||||
{
|
||||
@@ -110,7 +110,7 @@ namespace Semmle.Autobuild.Shared
|
||||
/// <summary>
|
||||
/// The root of the source directory.
|
||||
/// </summary>
|
||||
string RootDirectory => Options.RootDirectory;
|
||||
private string RootDirectory => Options.RootDirectory;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the supplied build configuration.
|
||||
@@ -123,7 +123,7 @@ namespace Semmle.Autobuild.Shared
|
||||
/// </summary>
|
||||
public IBuildActions Actions { get; }
|
||||
|
||||
IEnumerable<IProjectOrSolution>? FindFiles(string extension, Func<string, ProjectOrSolution> create)
|
||||
private IEnumerable<IProjectOrSolution>? FindFiles(string extension, Func<string, ProjectOrSolution> create)
|
||||
{
|
||||
var matchingFiles = GetExtensions(extension)
|
||||
.Select(p => (ProjectOrSolution: create(p.Item1), DistanceFromRoot: p.Item2))
|
||||
@@ -209,7 +209,7 @@ namespace Semmle.Autobuild.Shared
|
||||
|
||||
protected string SourceArchiveDir { get; }
|
||||
|
||||
readonly ILogger logger = new ConsoleLogger(Verbosity.Info);
|
||||
private readonly ILogger logger = new ConsoleLogger(Verbosity.Info);
|
||||
|
||||
/// <summary>
|
||||
/// Log a given build event to the console.
|
||||
|
||||
@@ -150,7 +150,7 @@ namespace Semmle.Autobuild.Shared
|
||||
|
||||
bool IBuildActions.FileExists(string file) => File.Exists(file);
|
||||
|
||||
static ProcessStartInfo GetProcessStartInfo(string exe, string arguments, string? workingDirectory, IDictionary<string, string>? environment, bool redirectStandardOutput)
|
||||
private static ProcessStartInfo GetProcessStartInfo(string exe, string arguments, string? workingDirectory, IDictionary<string, string>? environment, bool redirectStandardOutput)
|
||||
{
|
||||
var pi = new ProcessStartInfo(exe, arguments)
|
||||
{
|
||||
@@ -215,7 +215,7 @@ namespace Semmle.Autobuild.Shared
|
||||
|
||||
public string EnvironmentExpandEnvironmentVariables(string s) => Environment.ExpandEnvironmentVariables(s);
|
||||
|
||||
static async Task DownloadFileAsync(string address, string filename)
|
||||
private static async Task DownloadFileAsync(string address, string filename)
|
||||
{
|
||||
using var httpClient = new HttpClient();
|
||||
using var request = new HttpRequestMessage(HttpMethod.Get, address);
|
||||
|
||||
@@ -16,18 +16,18 @@ namespace Semmle.Autobuild.Shared
|
||||
this.withDotNet = withDotNet;
|
||||
}
|
||||
|
||||
readonly IEnumerable<string> winExtensions = new List<string> {
|
||||
private readonly IEnumerable<string> winExtensions = new List<string> {
|
||||
".bat",
|
||||
".cmd",
|
||||
".exe"
|
||||
};
|
||||
|
||||
readonly IEnumerable<string> linuxExtensions = new List<string> {
|
||||
private readonly IEnumerable<string> linuxExtensions = new List<string> {
|
||||
"",
|
||||
".sh"
|
||||
};
|
||||
|
||||
readonly IEnumerable<string> buildScripts = new List<string> {
|
||||
private readonly IEnumerable<string> buildScripts = new List<string> {
|
||||
"build"
|
||||
};
|
||||
|
||||
|
||||
@@ -46,12 +46,12 @@ namespace Semmle.Autobuild.Shared
|
||||
/// <returns>The exit code from this build script.</returns>
|
||||
public abstract int Run(IBuildActions actions, Action<string, bool> startCallback, Action<int, string, bool> exitCallBack, out IList<string> stdout);
|
||||
|
||||
class BuildCommand : BuildScript
|
||||
private class BuildCommand : BuildScript
|
||||
{
|
||||
readonly string exe, arguments;
|
||||
readonly string? workingDirectory;
|
||||
readonly IDictionary<string, string>? environment;
|
||||
readonly bool silent;
|
||||
private readonly string exe, arguments;
|
||||
private readonly string? workingDirectory;
|
||||
private readonly IDictionary<string, string>? environment;
|
||||
private readonly bool silent;
|
||||
|
||||
/// <summary>
|
||||
/// Create a simple build command.
|
||||
@@ -112,9 +112,9 @@ namespace Semmle.Autobuild.Shared
|
||||
|
||||
}
|
||||
|
||||
class ReturnBuildCommand : BuildScript
|
||||
private class ReturnBuildCommand : BuildScript
|
||||
{
|
||||
readonly Func<IBuildActions, int> func;
|
||||
private readonly Func<IBuildActions, int> func;
|
||||
public ReturnBuildCommand(Func<IBuildActions, int> func)
|
||||
{
|
||||
this.func = func;
|
||||
@@ -129,11 +129,12 @@ namespace Semmle.Autobuild.Shared
|
||||
}
|
||||
}
|
||||
|
||||
class BindBuildScript : BuildScript
|
||||
private class BindBuildScript : BuildScript
|
||||
{
|
||||
readonly BuildScript s1;
|
||||
readonly Func<IList<string>, int, BuildScript>? s2a;
|
||||
readonly Func<int, BuildScript>? s2b;
|
||||
private readonly BuildScript s1;
|
||||
private readonly Func<IList<string>, int, BuildScript>? s2a;
|
||||
private readonly Func<int, BuildScript>? s2b;
|
||||
|
||||
public BindBuildScript(BuildScript s1, Func<IList<string>, int, BuildScript> s2)
|
||||
{
|
||||
this.s1 = s1;
|
||||
@@ -227,19 +228,19 @@ namespace Semmle.Autobuild.Shared
|
||||
public static BuildScript Bind(BuildScript s1, Func<IList<string>, int, BuildScript> s2) =>
|
||||
new BindBuildScript(s1, s2);
|
||||
|
||||
const int SuccessCode = 0;
|
||||
private const int SuccessCode = 0;
|
||||
/// <summary>
|
||||
/// The empty build script that always returns exit code 0.
|
||||
/// </summary>
|
||||
public static readonly BuildScript Success = Create(actions => SuccessCode);
|
||||
|
||||
const int FailureCode = 1;
|
||||
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);
|
||||
|
||||
static bool Succeeded(int i) => i == SuccessCode;
|
||||
private static bool Succeeded(int i) => i == SuccessCode;
|
||||
|
||||
public static BuildScript operator &(BuildScript s1, BuildScript s2) =>
|
||||
new BindBuildScript(s1, ret1 => Succeeded(ret1) ? s2 : Create(actions => ret1));
|
||||
|
||||
@@ -9,15 +9,15 @@ namespace Semmle.Autobuild.Shared
|
||||
/// </summary>
|
||||
public class CommandBuilder
|
||||
{
|
||||
enum EscapeMode { Process, Cmd };
|
||||
private enum EscapeMode { Process, Cmd };
|
||||
|
||||
readonly StringBuilder arguments;
|
||||
bool firstCommand;
|
||||
string? executable;
|
||||
readonly EscapeMode escapingMode;
|
||||
readonly string? workingDirectory;
|
||||
readonly IDictionary<string, string>? environment;
|
||||
readonly bool silent;
|
||||
private readonly StringBuilder arguments;
|
||||
private bool firstCommand;
|
||||
private string? executable;
|
||||
private readonly EscapeMode escapingMode;
|
||||
private readonly string? workingDirectory;
|
||||
private readonly IDictionary<string, string>? environment;
|
||||
private readonly bool silent;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="T:Semmle.Autobuild.CommandBuilder"/> class.
|
||||
@@ -45,7 +45,7 @@ namespace Semmle.Autobuild.Shared
|
||||
this.silent = silent;
|
||||
}
|
||||
|
||||
void OdasaIndex(string odasa)
|
||||
private void OdasaIndex(string odasa)
|
||||
{
|
||||
RunCommand(odasa, "index --auto");
|
||||
}
|
||||
@@ -74,8 +74,8 @@ namespace Semmle.Autobuild.Shared
|
||||
return this;
|
||||
}
|
||||
|
||||
static readonly char[] specialChars = { ' ', '\t', '\n', '\v', '\"' };
|
||||
static readonly char[] cmdMetacharacter = { '(', ')', '%', '!', '^', '\"', '<', '>', '&', '|' };
|
||||
private static readonly char[] specialChars = { ' ', '\t', '\n', '\v', '\"' };
|
||||
private static readonly char[] cmdMetacharacter = { '(', ')', '%', '!', '^', '\"', '<', '>', '&', '|' };
|
||||
|
||||
/// <summary>
|
||||
/// Appends the given argument to the command line.
|
||||
@@ -88,7 +88,7 @@ namespace Semmle.Autobuild.Shared
|
||||
/// This implementation is copied from
|
||||
/// https://blogs.msdn.microsoft.com/twistylittlepassagesallalike/2011/04/23/everyone-quotes-command-line-arguments-the-wrong-way/
|
||||
/// </remarks>
|
||||
void ArgvQuote(string argument, bool force)
|
||||
private void ArgvQuote(string argument, bool force)
|
||||
{
|
||||
bool cmd = escapingMode == EscapeMode.Cmd;
|
||||
if (!force &&
|
||||
@@ -153,7 +153,7 @@ namespace Semmle.Autobuild.Shared
|
||||
return this;
|
||||
}
|
||||
|
||||
void NextArgument()
|
||||
private void NextArgument()
|
||||
{
|
||||
if (arguments.Length > 0)
|
||||
arguments.Append(' ');
|
||||
@@ -169,7 +169,7 @@ namespace Semmle.Autobuild.Shared
|
||||
return this;
|
||||
}
|
||||
|
||||
void NextCommand()
|
||||
private void NextCommand()
|
||||
{
|
||||
if (firstCommand)
|
||||
firstCommand = false;
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Semmle.Autobuild.Shared
|
||||
/// <summary>
|
||||
/// The name of the msbuild command.
|
||||
/// </summary>
|
||||
const string MsBuild = "msbuild";
|
||||
private const string MsBuild = "msbuild";
|
||||
|
||||
public BuildScript Analyse(Autobuilder builder, bool auto)
|
||||
{
|
||||
@@ -155,7 +155,7 @@ namespace Semmle.Autobuild.Shared
|
||||
/// <summary>
|
||||
/// Returns a script for downloading `nuget.exe` from nuget.org.
|
||||
/// </summary>
|
||||
static BuildScript DownloadNugetExe(Autobuilder builder, string path) =>
|
||||
private static BuildScript DownloadNugetExe(Autobuilder builder, string path) =>
|
||||
BuildScript.Create(_ =>
|
||||
{
|
||||
builder.Log(Severity.Info, "Attempting to download nuget.exe");
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Semmle.Autobuild.Shared
|
||||
|
||||
public Version ToolsVersion { get; private set; }
|
||||
|
||||
readonly Lazy<List<Project>> includedProjectsLazy;
|
||||
private readonly Lazy<List<Project>> includedProjectsLazy;
|
||||
public override IEnumerable<IProjectOrSolution> IncludedProjects => includedProjectsLazy.Value;
|
||||
|
||||
public Project(Autobuilder builder, string path) : base(builder, path)
|
||||
|
||||
@@ -40,11 +40,11 @@ namespace Semmle.Autobuild.Shared
|
||||
/// <summary>
|
||||
/// A solution file on the filesystem, read using Microsoft.Build.
|
||||
/// </summary>
|
||||
class Solution : ProjectOrSolution, ISolution
|
||||
internal class Solution : ProjectOrSolution, ISolution
|
||||
{
|
||||
readonly SolutionFile? solution;
|
||||
private readonly SolutionFile? solution;
|
||||
|
||||
readonly IEnumerable<Project> includedProjects;
|
||||
private readonly IEnumerable<Project> includedProjects;
|
||||
public override IEnumerable<IProjectOrSolution> IncludedProjects => includedProjects;
|
||||
|
||||
public IEnumerable<SolutionConfigurationInSolution> Configurations =>
|
||||
@@ -84,7 +84,7 @@ namespace Semmle.Autobuild.Shared
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
IEnumerable<Version> ToolsVersions => includedProjects.Where(p => p.ValidToolsVersion).Select(p => p.ToolsVersion);
|
||||
private IEnumerable<Version> ToolsVersions => includedProjects.Where(p => p.ValidToolsVersion).Select(p => p.ToolsVersion);
|
||||
|
||||
public Version ToolsVersion => ToolsVersions.Any() ? ToolsVersions.Max() : new Version();
|
||||
}
|
||||
|
||||
@@ -14,11 +14,11 @@ namespace Semmle.Extraction.CIL.Driver
|
||||
/// Information about a single assembly.
|
||||
/// In particular, provides references between assemblies.
|
||||
/// </summary>
|
||||
class AssemblyInfo
|
||||
internal class AssemblyInfo
|
||||
{
|
||||
public override string ToString() => filename;
|
||||
|
||||
static AssemblyName CreateAssemblyName(MetadataReader mdReader, StringHandle name, System.Version version, StringHandle culture)
|
||||
private static AssemblyName CreateAssemblyName(MetadataReader mdReader, StringHandle name, System.Version version, StringHandle culture)
|
||||
{
|
||||
var cultureString = mdReader.GetString(culture);
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Semmle.Extraction.CIL.Driver
|
||||
return assemblyName;
|
||||
}
|
||||
|
||||
static AssemblyName CreateAssemblyName(MetadataReader mdReader, AssemblyReference ar)
|
||||
private static AssemblyName CreateAssemblyName(MetadataReader mdReader, AssemblyReference ar)
|
||||
{
|
||||
var an = CreateAssemblyName(mdReader, ar.Name, ar.Version, ar.Culture);
|
||||
if (!ar.PublicKeyOrToken.IsNil)
|
||||
@@ -42,7 +42,7 @@ namespace Semmle.Extraction.CIL.Driver
|
||||
return an;
|
||||
}
|
||||
|
||||
static AssemblyName CreateAssemblyName(MetadataReader mdReader, AssemblyDefinition ad)
|
||||
private static AssemblyName CreateAssemblyName(MetadataReader mdReader, AssemblyDefinition ad)
|
||||
{
|
||||
var an = CreateAssemblyName(mdReader, ad.Name, ad.Version, ad.Culture);
|
||||
if (!ad.PublicKey.IsNil)
|
||||
@@ -100,9 +100,9 @@ namespace Semmle.Extraction.CIL.Driver
|
||||
/// Resolves references between assemblies and determines which
|
||||
/// additional assemblies need to be extracted.
|
||||
/// </summary>
|
||||
class AssemblyList
|
||||
internal class AssemblyList
|
||||
{
|
||||
class AssemblyNameComparer : IEqualityComparer<AssemblyName>
|
||||
private class AssemblyNameComparer : IEqualityComparer<AssemblyName>
|
||||
{
|
||||
bool IEqualityComparer<AssemblyName>.Equals(AssemblyName? x, AssemblyName? y) =>
|
||||
object.ReferenceEquals(x, y) ||
|
||||
@@ -112,7 +112,7 @@ namespace Semmle.Extraction.CIL.Driver
|
||||
(obj.Name, obj.Version).GetHashCode();
|
||||
}
|
||||
|
||||
readonly Dictionary<AssemblyName, AssemblyInfo> assembliesRead = new Dictionary<AssemblyName, AssemblyInfo>(new AssemblyNameComparer());
|
||||
private readonly Dictionary<AssemblyName, AssemblyInfo> assembliesRead = new Dictionary<AssemblyName, AssemblyInfo>(new AssemblyNameComparer());
|
||||
|
||||
public void AddFile(string assemblyPath, bool extractAll)
|
||||
{
|
||||
@@ -135,7 +135,7 @@ namespace Semmle.Extraction.CIL.Driver
|
||||
|
||||
public IEnumerable<AssemblyInfo> AssembliesToExtract => assembliesRead.Values.Where(info => info.extract);
|
||||
|
||||
IEnumerable<AssemblyName> AssembliesToReference => AssembliesToExtract.SelectMany(info => info.references);
|
||||
private IEnumerable<AssemblyName> AssembliesToReference => AssembliesToExtract.SelectMany(info => info.references);
|
||||
|
||||
public void ResolveReferences()
|
||||
{
|
||||
@@ -160,16 +160,16 @@ namespace Semmle.Extraction.CIL.Driver
|
||||
}
|
||||
}
|
||||
|
||||
readonly HashSet<string> filesAnalyzed = new HashSet<string>();
|
||||
private readonly HashSet<string> filesAnalyzed = new HashSet<string>();
|
||||
public readonly HashSet<AssemblyName> missingReferences = new HashSet<AssemblyName>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parses the command line and collates a list of DLLs/EXEs to extract.
|
||||
/// </summary>
|
||||
class ExtractorOptions
|
||||
internal class ExtractorOptions
|
||||
{
|
||||
readonly AssemblyList assemblyList = new AssemblyList();
|
||||
private readonly AssemblyList assemblyList = new AssemblyList();
|
||||
|
||||
public ExtractorOptions(string[] args)
|
||||
{
|
||||
@@ -196,7 +196,7 @@ namespace Semmle.Extraction.CIL.Driver
|
||||
}
|
||||
}
|
||||
|
||||
void AddFrameworkDirectories(bool extractAll)
|
||||
private void AddFrameworkDirectories(bool extractAll)
|
||||
{
|
||||
AddDirectory(RuntimeEnvironment.GetRuntimeDirectory(), extractAll);
|
||||
}
|
||||
@@ -207,7 +207,7 @@ namespace Semmle.Extraction.CIL.Driver
|
||||
public bool PDB { get; private set; }
|
||||
public TrapWriter.CompressionMode TrapCompression { get; private set; }
|
||||
|
||||
void AddFileOrDirectory(string path)
|
||||
private void AddFileOrDirectory(string path)
|
||||
{
|
||||
path = Path.GetFullPath(path);
|
||||
if (File.Exists(path))
|
||||
|
||||
@@ -2,6 +2,6 @@ using System;
|
||||
|
||||
namespace Semmle.Extraction.CIL.Driver
|
||||
{
|
||||
class InvalidAssemblyException : Exception
|
||||
internal class InvalidAssemblyException : Exception
|
||||
{ }
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ using System.Diagnostics;
|
||||
|
||||
namespace Semmle.Extraction.CIL.Driver
|
||||
{
|
||||
class Program
|
||||
public static class Program
|
||||
{
|
||||
static void DisplayHelp()
|
||||
private static void DisplayHelp()
|
||||
{
|
||||
Console.WriteLine("CIL command line extractor");
|
||||
Console.WriteLine();
|
||||
@@ -20,7 +20,7 @@ namespace Semmle.Extraction.CIL.Driver
|
||||
Console.WriteLine(" path A directory/dll/exe to analyze");
|
||||
}
|
||||
|
||||
static void ExtractAssembly(Layout layout, string assemblyPath, ILogger logger, bool nocache, bool extractPdbs, TrapWriter.CompressionMode trapCompression)
|
||||
private static void ExtractAssembly(Layout layout, string assemblyPath, ILogger logger, bool nocache, bool extractPdbs, TrapWriter.CompressionMode trapCompression)
|
||||
{
|
||||
var sw = new Stopwatch();
|
||||
sw.Start();
|
||||
@@ -29,7 +29,7 @@ namespace Semmle.Extraction.CIL.Driver
|
||||
logger.Log(Severity.Info, " {0} ({1})", assemblyPath, sw.Elapsed);
|
||||
}
|
||||
|
||||
static void Main(string[] args)
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
if (args.Length == 0)
|
||||
{
|
||||
|
||||
@@ -11,8 +11,8 @@ namespace Semmle.Extraction.CIL
|
||||
/// <typeparam name="TargetType">The type of the generated object.</typeparam>
|
||||
public class CachedFunction<SrcType, TargetType> where SrcType : notnull
|
||||
{
|
||||
readonly Func<SrcType, TargetType> generator;
|
||||
readonly Dictionary<SrcType, TargetType> cache;
|
||||
private readonly Func<SrcType, TargetType> generator;
|
||||
private readonly Dictionary<SrcType, TargetType> cache;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the factory with a given mapping.
|
||||
@@ -52,7 +52,7 @@ namespace Semmle.Extraction.CIL
|
||||
/// <typeparam name="Target">The target type.</typeparam>
|
||||
public class CachedFunction<Src1, Src2, Target>
|
||||
{
|
||||
readonly CachedFunction<(Src1, Src2), Target> factory;
|
||||
private readonly CachedFunction<(Src1, Src2), Target> factory;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the factory with a given mapping.
|
||||
|
||||
@@ -12,10 +12,10 @@ namespace Semmle.Extraction.CIL
|
||||
/// Adds additional context that is specific for CIL extraction.
|
||||
/// One context = one DLL/EXE.
|
||||
/// </summary>
|
||||
sealed partial class Context : IDisposable
|
||||
public sealed partial class Context : IDisposable
|
||||
{
|
||||
readonly FileStream stream;
|
||||
Entities.Assembly? assemblyNull;
|
||||
private readonly FileStream stream;
|
||||
private Entities.Assembly? assemblyNull;
|
||||
|
||||
public Extraction.Context cx { get; }
|
||||
public MetadataReader mdReader { get; }
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
}
|
||||
|
||||
interface IAssembly : ILocation
|
||||
internal interface IAssembly : ILocation
|
||||
{
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// </summary>
|
||||
public class Assembly : LabelledEntity, IAssembly
|
||||
{
|
||||
readonly File file;
|
||||
readonly AssemblyName assemblyName;
|
||||
private readonly File file;
|
||||
private readonly AssemblyName assemblyName;
|
||||
|
||||
public Assembly(Context cx) : base(cx)
|
||||
{
|
||||
@@ -59,7 +59,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
|
||||
public override string IdSuffix => ";assembly";
|
||||
|
||||
string FullName => assemblyName.GetPublicKey() is null ? assemblyName.FullName + ", PublicKeyToken=null" : assemblyName.FullName;
|
||||
private string FullName => assemblyName.GetPublicKey() is null ? assemblyName.FullName + ", PublicKeyToken=null" : assemblyName.FullName;
|
||||
|
||||
public override IEnumerable<IExtractionProduct> Contents
|
||||
{
|
||||
@@ -111,7 +111,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
}
|
||||
}
|
||||
|
||||
static void ExtractCIL(Extraction.Context cx, string assemblyPath, bool extractPdbs)
|
||||
private static void ExtractCIL(Extraction.Context cx, string assemblyPath, bool extractPdbs)
|
||||
{
|
||||
using var cilContext = new Context(cx, assemblyPath, extractPdbs);
|
||||
cilContext.Populate(new Assembly(cilContext));
|
||||
|
||||
@@ -7,18 +7,18 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// <summary>
|
||||
/// A CIL attribute.
|
||||
/// </summary>
|
||||
interface IAttribute : IExtractedEntity
|
||||
internal interface IAttribute : IExtractedEntity
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Entity representing a CIL attribute.
|
||||
/// </summary>
|
||||
sealed class Attribute : UnlabelledEntity, IAttribute
|
||||
internal sealed class Attribute : UnlabelledEntity, IAttribute
|
||||
{
|
||||
readonly CustomAttributeHandle handle;
|
||||
readonly CustomAttribute attrib;
|
||||
readonly IEntity @object;
|
||||
private readonly CustomAttributeHandle handle;
|
||||
private readonly CustomAttribute attrib;
|
||||
private readonly IEntity @object;
|
||||
|
||||
public Attribute(Context cx, IEntity @object, CustomAttributeHandle handle) : base(cx)
|
||||
{
|
||||
@@ -84,9 +84,9 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// Helper class to decode the attribute structure.
|
||||
/// Note that there are some unhandled cases that should be fixed in due course.
|
||||
/// </summary>
|
||||
class CustomAttributeDecoder : ICustomAttributeTypeProvider<Type>
|
||||
internal class CustomAttributeDecoder : ICustomAttributeTypeProvider<Type>
|
||||
{
|
||||
readonly Context cx;
|
||||
private readonly Context cx;
|
||||
public CustomAttributeDecoder(Context cx) { this.cx = cx; }
|
||||
|
||||
public Type GetPrimitiveType(PrimitiveTypeCode typeCode) => cx.Create(typeCode);
|
||||
|
||||
@@ -7,18 +7,18 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// <summary>
|
||||
/// An event.
|
||||
/// </summary>
|
||||
interface IEvent : IExtractedEntity
|
||||
internal interface IEvent : IExtractedEntity
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An event entity.
|
||||
/// </summary>
|
||||
sealed class Event : LabelledEntity, IEvent
|
||||
internal sealed class Event : LabelledEntity, IEvent
|
||||
{
|
||||
readonly EventDefinitionHandle handle;
|
||||
readonly Type parent;
|
||||
readonly EventDefinition ed;
|
||||
private readonly EventDefinitionHandle handle;
|
||||
private readonly Type parent;
|
||||
private readonly EventDefinition ed;
|
||||
|
||||
public Event(Context cx, Type parent, EventDefinitionHandle handle) : base(cx)
|
||||
{
|
||||
|
||||
@@ -2,20 +2,20 @@
|
||||
|
||||
namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
interface IExceptionRegion : IExtractedEntity
|
||||
internal interface IExceptionRegion : IExtractedEntity
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An exception region entity.
|
||||
/// </summary>
|
||||
class ExceptionRegion : UnlabelledEntity, IExceptionRegion
|
||||
internal class ExceptionRegion : UnlabelledEntity, IExceptionRegion
|
||||
{
|
||||
readonly GenericContext gc;
|
||||
readonly MethodImplementation method;
|
||||
readonly int index;
|
||||
readonly System.Reflection.Metadata.ExceptionRegion r;
|
||||
readonly Dictionary<int, IInstruction> jump_table;
|
||||
private readonly GenericContext gc;
|
||||
private readonly MethodImplementation method;
|
||||
private readonly int index;
|
||||
private readonly System.Reflection.Metadata.ExceptionRegion r;
|
||||
private readonly Dictionary<int, IInstruction> jump_table;
|
||||
|
||||
public ExceptionRegion(GenericContext gc, MethodImplementation method, int index, System.Reflection.Metadata.ExceptionRegion r, Dictionary<int, IInstruction> jump_table) : base(gc.cx)
|
||||
{
|
||||
|
||||
@@ -13,21 +13,21 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// An entity represting a member.
|
||||
/// Used to type tuples correctly.
|
||||
/// </summary>
|
||||
interface IMember : IExtractedEntity
|
||||
internal interface IMember : IExtractedEntity
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An entity representing a field.
|
||||
/// </summary>
|
||||
interface IField : IMember
|
||||
internal interface IField : IMember
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An entity representing a field.
|
||||
/// </summary>
|
||||
abstract class Field : GenericContext, IField
|
||||
internal abstract class Field : GenericContext, IField
|
||||
{
|
||||
protected Field(Context cx) : base(cx)
|
||||
{
|
||||
@@ -58,7 +58,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
|
||||
public Location ReportingLocation => throw new NotImplementedException();
|
||||
|
||||
abstract public Type Type { get; }
|
||||
public abstract Type Type { get; }
|
||||
|
||||
public virtual IEnumerable<IExtractionProduct> Contents
|
||||
{
|
||||
@@ -76,10 +76,10 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
TrapStackBehaviour IEntity.TrapStackBehaviour => TrapStackBehaviour.NoLabel;
|
||||
}
|
||||
|
||||
sealed class DefinitionField : Field
|
||||
internal sealed class DefinitionField : Field
|
||||
{
|
||||
readonly Handle handle;
|
||||
readonly FieldDefinition fd;
|
||||
private readonly Handle handle;
|
||||
private readonly FieldDefinition fd;
|
||||
|
||||
public DefinitionField(GenericContext gc, FieldDefinitionHandle handle) : base(gc.cx)
|
||||
{
|
||||
@@ -134,12 +134,12 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
public override IEnumerable<Type> MethodParameters => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
sealed class MemberReferenceField : Field
|
||||
internal sealed class MemberReferenceField : Field
|
||||
{
|
||||
readonly MemberReferenceHandle Handle;
|
||||
readonly MemberReference mr;
|
||||
readonly GenericContext gc;
|
||||
readonly Type declType;
|
||||
private readonly MemberReferenceHandle Handle;
|
||||
private readonly MemberReference mr;
|
||||
private readonly GenericContext gc;
|
||||
private readonly Type declType;
|
||||
|
||||
public MemberReferenceField(GenericContext gc, MemberReferenceHandle handle) : base(gc.cx)
|
||||
{
|
||||
|
||||
@@ -3,11 +3,11 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
interface IFileOrFolder : IEntity
|
||||
internal interface IFileOrFolder : IEntity
|
||||
{
|
||||
}
|
||||
|
||||
interface IFile : IFileOrFolder
|
||||
internal interface IFile : IFileOrFolder
|
||||
{
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
|
||||
public class PdbSourceFile : File
|
||||
{
|
||||
readonly PDB.ISourceFile file;
|
||||
private readonly PDB.ISourceFile file;
|
||||
|
||||
public PdbSourceFile(Context cx, PDB.ISourceFile file) : base(cx, file.Path)
|
||||
{
|
||||
|
||||
@@ -3,13 +3,13 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
interface IFolder : IFileOrFolder
|
||||
internal interface IFolder : IFileOrFolder
|
||||
{
|
||||
}
|
||||
|
||||
public sealed class Folder : LabelledEntity, IFolder
|
||||
{
|
||||
readonly PathTransformer.ITransformedPath TransformedPath;
|
||||
private readonly PathTransformer.ITransformedPath TransformedPath;
|
||||
|
||||
public Folder(Context cx, PathTransformer.ITransformedPath path) : base(cx)
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// <summary>
|
||||
/// A CIL instruction.
|
||||
/// </summary>
|
||||
interface IInstruction : IExtractedEntity
|
||||
internal interface IInstruction : IExtractedEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the extraction products for branches.
|
||||
@@ -21,7 +21,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// <summary>
|
||||
/// A CIL instruction.
|
||||
/// </summary>
|
||||
class Instruction : UnlabelledEntity, IInstruction
|
||||
internal class Instruction : UnlabelledEntity, IInstruction
|
||||
{
|
||||
/// <summary>
|
||||
/// The additional data following the opcode, if any.
|
||||
@@ -272,8 +272,8 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
public readonly ILOpCode OpCode;
|
||||
public readonly int Offset;
|
||||
public readonly int Index;
|
||||
readonly int PayloadValue;
|
||||
readonly uint UnsignedPayloadValue;
|
||||
private readonly int PayloadValue;
|
||||
private readonly uint UnsignedPayloadValue;
|
||||
|
||||
public Payload PayloadType
|
||||
{
|
||||
@@ -306,10 +306,9 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
get; set;
|
||||
}
|
||||
|
||||
private readonly byte[] data;
|
||||
|
||||
readonly byte[] data;
|
||||
|
||||
int PayloadSize => payloadSizes[(int)PayloadType];
|
||||
private int PayloadSize => payloadSizes[(int)PayloadType];
|
||||
|
||||
/// <summary>
|
||||
/// Reads the instruction from a byte stream.
|
||||
|
||||
@@ -3,15 +3,15 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
interface ILocal : IExtractedEntity
|
||||
internal interface ILocal : IExtractedEntity
|
||||
{
|
||||
}
|
||||
|
||||
class LocalVariable : LabelledEntity, ILocal
|
||||
internal class LocalVariable : LabelledEntity, ILocal
|
||||
{
|
||||
readonly MethodImplementation method;
|
||||
readonly int index;
|
||||
readonly Type type;
|
||||
private readonly MethodImplementation method;
|
||||
private readonly int index;
|
||||
private readonly Type type;
|
||||
|
||||
public LocalVariable(Context cx, MethodImplementation m, int i, Type t) : base(cx)
|
||||
{
|
||||
|
||||
@@ -13,14 +13,14 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// <summary>
|
||||
/// A method entity.
|
||||
/// </summary>
|
||||
interface IMethod : IMember
|
||||
internal interface IMethod : IMember
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A method entity.
|
||||
/// </summary>
|
||||
abstract class Method : TypeContainer, IMethod
|
||||
internal abstract class Method : TypeContainer, IMethod
|
||||
{
|
||||
protected MethodTypeParameter[]? genericParams;
|
||||
protected GenericContext gc;
|
||||
@@ -50,7 +50,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
|
||||
public abstract string NameLabel { get; }
|
||||
|
||||
internal protected void WriteMethodId(TextWriter trapFile, Type parent, string methodName)
|
||||
protected internal void WriteMethodId(TextWriter trapFile, Type parent, string methodName)
|
||||
{
|
||||
signature.ReturnType.WriteId(trapFile, this);
|
||||
trapFile.Write(' ');
|
||||
@@ -103,7 +103,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// <summary>
|
||||
/// A method implementation entity.
|
||||
/// </summary>
|
||||
interface IMethodImplementation : IExtractedEntity
|
||||
internal interface IMethodImplementation : IExtractedEntity
|
||||
{
|
||||
}
|
||||
|
||||
@@ -111,9 +111,9 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// A method implementation entity.
|
||||
/// In the database, the same method could in principle have multiple implementations.
|
||||
/// </summary>
|
||||
class MethodImplementation : UnlabelledEntity, IMethodImplementation
|
||||
internal class MethodImplementation : UnlabelledEntity, IMethodImplementation
|
||||
{
|
||||
readonly Method m;
|
||||
private readonly Method m;
|
||||
|
||||
public MethodImplementation(Method m) : base(m.cx)
|
||||
{
|
||||
@@ -133,15 +133,15 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// <summary>
|
||||
/// A definition method - a method defined in the current assembly.
|
||||
/// </summary>
|
||||
sealed class DefinitionMethod : Method, IMember
|
||||
internal sealed class DefinitionMethod : Method, IMember
|
||||
{
|
||||
readonly Handle handle;
|
||||
readonly MethodDefinition md;
|
||||
readonly PDB.IMethod? methodDebugInformation;
|
||||
readonly Type declaringType;
|
||||
private readonly Handle handle;
|
||||
private readonly MethodDefinition md;
|
||||
private readonly PDB.IMethod? methodDebugInformation;
|
||||
private readonly Type declaringType;
|
||||
|
||||
readonly string name;
|
||||
LocalVariable[]? locals;
|
||||
private readonly string name;
|
||||
private LocalVariable[]? locals;
|
||||
|
||||
public MethodImplementation? Implementation { get; private set; }
|
||||
|
||||
@@ -302,7 +302,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerable<IExtractionProduct> Decode(byte[] ilbytes, Dictionary<int, IInstruction> jump_table)
|
||||
private IEnumerable<IExtractionProduct> Decode(byte[] ilbytes, Dictionary<int, IInstruction> jump_table)
|
||||
{
|
||||
// Sequence points are stored in order of offset.
|
||||
// We use an enumerator to locate the correct sequence point for each instruction.
|
||||
@@ -391,13 +391,13 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// <summary>
|
||||
/// This is a late-bound reference to a method.
|
||||
/// </summary>
|
||||
sealed class MemberReferenceMethod : Method
|
||||
internal sealed class MemberReferenceMethod : Method
|
||||
{
|
||||
readonly MemberReferenceHandle handle;
|
||||
readonly MemberReference mr;
|
||||
readonly Type declaringType;
|
||||
readonly GenericContext parent;
|
||||
readonly Method? sourceDeclaration;
|
||||
private readonly MemberReferenceHandle handle;
|
||||
private readonly MemberReference mr;
|
||||
private readonly Type declaringType;
|
||||
private readonly GenericContext parent;
|
||||
private readonly Method? sourceDeclaration;
|
||||
|
||||
public MemberReferenceMethod(GenericContext gc, MemberReferenceHandle handle) : base(gc)
|
||||
{
|
||||
@@ -476,12 +476,12 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// <summary>
|
||||
/// A constructed method.
|
||||
/// </summary>
|
||||
sealed class MethodSpecificationMethod : Method
|
||||
internal sealed class MethodSpecificationMethod : Method
|
||||
{
|
||||
readonly MethodSpecificationHandle handle;
|
||||
readonly MethodSpecification ms;
|
||||
readonly Method unboundMethod;
|
||||
readonly ImmutableArray<Type> typeParams;
|
||||
private readonly MethodSpecificationHandle handle;
|
||||
private readonly MethodSpecification ms;
|
||||
private readonly Method unboundMethod;
|
||||
private readonly ImmutableArray<Type> typeParams;
|
||||
|
||||
public MethodSpecificationMethod(GenericContext gc, MethodSpecificationHandle handle) : base(gc)
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// <summary>
|
||||
/// A namespace.
|
||||
/// </summary>
|
||||
interface INamespace : ITypeContainer
|
||||
internal interface INamespace : ITypeContainer
|
||||
{
|
||||
}
|
||||
|
||||
@@ -56,13 +56,13 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
|
||||
public override IEnumerable<Type> MethodParameters => throw new NotImplementedException();
|
||||
|
||||
static string parseNamespaceName(string fqn)
|
||||
private static string parseNamespaceName(string fqn)
|
||||
{
|
||||
var i = fqn.LastIndexOf('.');
|
||||
return i == -1 ? fqn : fqn.Substring(i + 1);
|
||||
}
|
||||
|
||||
static Namespace? createParentNamespace(Context cx, string fqn)
|
||||
private static Namespace? createParentNamespace(Context cx, string fqn)
|
||||
{
|
||||
if (fqn.Length == 0) return null;
|
||||
var i = fqn.LastIndexOf('.');
|
||||
|
||||
@@ -6,18 +6,18 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// <summary>
|
||||
/// A parameter entity.
|
||||
/// </summary>
|
||||
interface IParameter : IExtractedEntity
|
||||
internal interface IParameter : IExtractedEntity
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A parameter entity.
|
||||
/// </summary>
|
||||
sealed class Parameter : LabelledEntity, IParameter
|
||||
internal sealed class Parameter : LabelledEntity, IParameter
|
||||
{
|
||||
readonly Method method;
|
||||
readonly int index;
|
||||
readonly Type type;
|
||||
private readonly Method method;
|
||||
private readonly int index;
|
||||
private readonly Type type;
|
||||
|
||||
public Parameter(Context cx, Method m, int i, Type t) : base(cx)
|
||||
{
|
||||
|
||||
@@ -8,20 +8,20 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// <summary>
|
||||
/// A property.
|
||||
/// </summary>
|
||||
interface IProperty : IExtractedEntity
|
||||
internal interface IProperty : IExtractedEntity
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A property.
|
||||
/// </summary>
|
||||
sealed class Property : LabelledEntity, IProperty
|
||||
internal sealed class Property : LabelledEntity, IProperty
|
||||
{
|
||||
readonly Handle handle;
|
||||
readonly Type type;
|
||||
readonly PropertyDefinition pd;
|
||||
private readonly Handle handle;
|
||||
private readonly Type type;
|
||||
private readonly PropertyDefinition pd;
|
||||
public override string IdSuffix => ";cil-property";
|
||||
readonly GenericContext gc;
|
||||
private readonly GenericContext gc;
|
||||
|
||||
public Property(GenericContext gc, Type type, PropertyDefinitionHandle handle) : base(gc.cx)
|
||||
{
|
||||
|
||||
@@ -10,8 +10,8 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
|
||||
public sealed class PdbSourceLocation : LabelledEntity, ISourceLocation
|
||||
{
|
||||
readonly Location location;
|
||||
readonly PdbSourceFile file;
|
||||
private readonly Location location;
|
||||
private readonly PdbSourceFile file;
|
||||
|
||||
public PdbSourceLocation(Context cx, PDB.Location location) : base(cx)
|
||||
{
|
||||
|
||||
@@ -14,14 +14,14 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// <summary>
|
||||
/// A type.
|
||||
/// </summary>
|
||||
interface IType : IEntity
|
||||
internal interface IType : IEntity
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An array type.
|
||||
/// </summary>
|
||||
interface IArrayType : IType
|
||||
internal interface IArrayType : IType
|
||||
{
|
||||
}
|
||||
|
||||
@@ -39,14 +39,14 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// <summary>
|
||||
/// A type container (namespace/types/method).
|
||||
/// </summary>
|
||||
interface ITypeContainer : IExtractedEntity
|
||||
internal interface ITypeContainer : IExtractedEntity
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Base class for all type containers (namespaces, types, methods).
|
||||
/// </summary>
|
||||
abstract public class TypeContainer : GenericContext, ITypeContainer
|
||||
public abstract class TypeContainer : GenericContext, ITypeContainer
|
||||
{
|
||||
protected TypeContainer(Context cx) : base(cx)
|
||||
{
|
||||
@@ -321,8 +321,8 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// </summary>
|
||||
public sealed class TypeDefinitionType : Type
|
||||
{
|
||||
readonly Handle handle;
|
||||
readonly TypeDefinition td;
|
||||
private readonly Handle handle;
|
||||
private readonly TypeDefinition td;
|
||||
|
||||
public TypeDefinitionType(Context cx, TypeDefinitionHandle handle) : base(cx)
|
||||
{
|
||||
@@ -386,7 +386,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
|
||||
public override Namespace Namespace => cx.Create(td.NamespaceDefinition);
|
||||
|
||||
readonly Type? declType;
|
||||
private readonly Type? declType;
|
||||
|
||||
public override Type? ContainingType => declType;
|
||||
|
||||
@@ -420,7 +420,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
ct.WriteAssemblyPrefix(trapFile);
|
||||
}
|
||||
|
||||
IEnumerable<TypeTypeParameter> MakeTypeParameters()
|
||||
private IEnumerable<TypeTypeParameter> MakeTypeParameters()
|
||||
{
|
||||
if (ThisTypeParameters == 0)
|
||||
return Enumerable.Empty<TypeTypeParameter>();
|
||||
@@ -437,7 +437,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
return newTypeParams;
|
||||
}
|
||||
|
||||
readonly Lazy<IEnumerable<TypeTypeParameter>> typeParams;
|
||||
private readonly Lazy<IEnumerable<TypeTypeParameter>> typeParams;
|
||||
|
||||
public override IEnumerable<Type> MethodParameters => Enumerable.Empty<Type>();
|
||||
|
||||
@@ -554,9 +554,9 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// </summary>
|
||||
public sealed class TypeReferenceType : Type
|
||||
{
|
||||
readonly TypeReferenceHandle handle;
|
||||
readonly TypeReference tr;
|
||||
readonly Lazy<TypeTypeParameter[]> typeParams;
|
||||
private readonly TypeReferenceHandle handle;
|
||||
private readonly TypeReference tr;
|
||||
private readonly Lazy<TypeTypeParameter[]> typeParams;
|
||||
|
||||
public TypeReferenceType(Context cx, TypeReferenceHandle handle) : base(cx)
|
||||
{
|
||||
@@ -575,7 +575,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
return handle.GetHashCode();
|
||||
}
|
||||
|
||||
TypeTypeParameter[] MakeTypeParameters()
|
||||
private TypeTypeParameter[] MakeTypeParameters()
|
||||
{
|
||||
var newTypeParams = new TypeTypeParameter[ThisTypeParameters];
|
||||
for (int i = 0; i < newTypeParams.Length; ++i)
|
||||
@@ -710,10 +710,10 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// </summary>
|
||||
public sealed class ConstructedType : Type
|
||||
{
|
||||
readonly Type unboundGenericType;
|
||||
private readonly Type unboundGenericType;
|
||||
|
||||
// Either null or notEmpty
|
||||
readonly Type[]? thisTypeArguments;
|
||||
private readonly Type[]? thisTypeArguments;
|
||||
|
||||
public override IEnumerable<Type> ThisTypeArguments => thisTypeArguments.EnumerateNull();
|
||||
|
||||
@@ -784,7 +784,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
return h;
|
||||
}
|
||||
|
||||
readonly Type? containingType;
|
||||
private readonly Type? containingType;
|
||||
public override Type? ContainingType => containingType;
|
||||
|
||||
public override string Name => unboundGenericType.Name;
|
||||
@@ -841,7 +841,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
|
||||
public sealed class PrimitiveType : Type
|
||||
{
|
||||
readonly PrimitiveTypeCode typeCode;
|
||||
private readonly PrimitiveTypeCode typeCode;
|
||||
public PrimitiveType(Context cx, PrimitiveTypeCode tc) : base(cx)
|
||||
{
|
||||
typeCode = tc;
|
||||
@@ -885,10 +885,10 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// <summary>
|
||||
/// An array type.
|
||||
/// </summary>
|
||||
sealed class ArrayType : Type, IArrayType
|
||||
internal sealed class ArrayType : Type, IArrayType
|
||||
{
|
||||
readonly Type elementType;
|
||||
readonly int rank;
|
||||
private readonly Type elementType;
|
||||
private readonly int rank;
|
||||
|
||||
public ArrayType(Context cx, Type elementType, int rank) : base(cx)
|
||||
{
|
||||
@@ -953,11 +953,11 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
public override IEnumerable<Type> MethodParameters => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
interface ITypeParameter : IType
|
||||
internal interface ITypeParameter : IType
|
||||
{
|
||||
}
|
||||
|
||||
abstract class TypeParameter : Type, ITypeParameter
|
||||
internal abstract class TypeParameter : Type, ITypeParameter
|
||||
{
|
||||
protected readonly GenericContext gc;
|
||||
|
||||
@@ -1005,10 +1005,10 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
}
|
||||
}
|
||||
|
||||
sealed class MethodTypeParameter : TypeParameter
|
||||
internal sealed class MethodTypeParameter : TypeParameter
|
||||
{
|
||||
readonly Method method;
|
||||
readonly int index;
|
||||
private readonly Method method;
|
||||
private readonly int index;
|
||||
|
||||
public override void WriteId(TextWriter trapFile, bool inContext)
|
||||
{
|
||||
@@ -1055,10 +1055,10 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
}
|
||||
|
||||
|
||||
sealed class TypeTypeParameter : TypeParameter
|
||||
internal sealed class TypeTypeParameter : TypeParameter
|
||||
{
|
||||
readonly Type type;
|
||||
readonly int index;
|
||||
private readonly Type type;
|
||||
private readonly int index;
|
||||
|
||||
public TypeTypeParameter(GenericContext cx, Type t, int i) : base(cx)
|
||||
{
|
||||
@@ -1100,13 +1100,13 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
}
|
||||
}
|
||||
|
||||
interface IPointerType : IType
|
||||
internal interface IPointerType : IType
|
||||
{
|
||||
}
|
||||
|
||||
sealed class PointerType : Type, IPointerType
|
||||
internal sealed class PointerType : Type, IPointerType
|
||||
{
|
||||
readonly Type pointee;
|
||||
private readonly Type pointee;
|
||||
|
||||
public PointerType(Context cx, Type pointee) : base(cx)
|
||||
{
|
||||
@@ -1160,7 +1160,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
}
|
||||
}
|
||||
|
||||
sealed class ErrorType : Type
|
||||
internal sealed class ErrorType : Type
|
||||
{
|
||||
public ErrorType(Context cx) : base(cx)
|
||||
{
|
||||
@@ -1187,14 +1187,14 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
public override Type Construct(IEnumerable<Type> typeArguments) => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
interface ITypeSignature
|
||||
internal interface ITypeSignature
|
||||
{
|
||||
void WriteId(TextWriter trapFile, GenericContext gc);
|
||||
}
|
||||
|
||||
public class SignatureDecoder : ISignatureTypeProvider<ITypeSignature, object>
|
||||
{
|
||||
struct Array : ITypeSignature
|
||||
private struct Array : ITypeSignature
|
||||
{
|
||||
private readonly ITypeSignature elementType;
|
||||
private readonly ArrayShape shape;
|
||||
@@ -1215,7 +1215,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
}
|
||||
}
|
||||
|
||||
struct ByRef : ITypeSignature
|
||||
private struct ByRef : ITypeSignature
|
||||
{
|
||||
private readonly ITypeSignature elementType;
|
||||
|
||||
@@ -1231,7 +1231,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
}
|
||||
}
|
||||
|
||||
struct FnPtr : ITypeSignature
|
||||
private struct FnPtr : ITypeSignature
|
||||
{
|
||||
|
||||
public void WriteId(TextWriter trapFile, GenericContext gc)
|
||||
@@ -1249,7 +1249,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
ITypeSignature ISignatureTypeProvider<ITypeSignature, object>.GetFunctionPointerType(MethodSignature<ITypeSignature> signature) =>
|
||||
new FnPtr();
|
||||
|
||||
class Instantiation : ITypeSignature
|
||||
private class Instantiation : ITypeSignature
|
||||
{
|
||||
private readonly ITypeSignature genericType;
|
||||
private readonly ImmutableArray<ITypeSignature> typeArguments;
|
||||
@@ -1260,6 +1260,21 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
this.typeArguments = typeArguments;
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
return base.Equals(obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
public override string? ToString()
|
||||
{
|
||||
return base.ToString();
|
||||
}
|
||||
|
||||
public void WriteId(TextWriter trapFile, GenericContext gc)
|
||||
{
|
||||
genericType.WriteId(trapFile, gc);
|
||||
@@ -1277,7 +1292,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
ITypeSignature IConstructedTypeProvider<ITypeSignature>.GetGenericInstantiation(ITypeSignature genericType, ImmutableArray<ITypeSignature> typeArguments) =>
|
||||
new Instantiation(genericType, typeArguments);
|
||||
|
||||
class GenericMethodParameter : ITypeSignature
|
||||
private class GenericMethodParameter : ITypeSignature
|
||||
{
|
||||
private readonly object innerGc;
|
||||
private readonly int index;
|
||||
@@ -1299,7 +1314,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
}
|
||||
}
|
||||
|
||||
class GenericTypeParameter : ITypeSignature
|
||||
private class GenericTypeParameter : ITypeSignature
|
||||
{
|
||||
private readonly int index;
|
||||
|
||||
@@ -1321,7 +1336,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
ITypeSignature ISignatureTypeProvider<ITypeSignature, object>.GetGenericTypeParameter(object genericContext, int index) =>
|
||||
new GenericTypeParameter(index);
|
||||
|
||||
class Modified : ITypeSignature
|
||||
private class Modified : ITypeSignature
|
||||
{
|
||||
private readonly ITypeSignature unmodifiedType;
|
||||
|
||||
@@ -1341,7 +1356,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
return new Modified(unmodifiedType);
|
||||
}
|
||||
|
||||
class Pinned : ITypeSignature
|
||||
private class Pinned : ITypeSignature
|
||||
{
|
||||
private readonly ITypeSignature elementType;
|
||||
|
||||
@@ -1362,7 +1377,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
return new Pinned(elementType);
|
||||
}
|
||||
|
||||
class PointerType : ITypeSignature
|
||||
private class PointerType : ITypeSignature
|
||||
{
|
||||
private readonly ITypeSignature elementType;
|
||||
|
||||
@@ -1383,7 +1398,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
return new PointerType(elementType);
|
||||
}
|
||||
|
||||
class Primitive : ITypeSignature
|
||||
private class Primitive : ITypeSignature
|
||||
{
|
||||
private readonly PrimitiveTypeCode typeCode;
|
||||
|
||||
@@ -1403,7 +1418,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
return new Primitive(typeCode);
|
||||
}
|
||||
|
||||
class SzArrayType : ITypeSignature
|
||||
private class SzArrayType : ITypeSignature
|
||||
{
|
||||
private readonly ITypeSignature elementType;
|
||||
|
||||
@@ -1424,7 +1439,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
return new SzArrayType(elementType);
|
||||
}
|
||||
|
||||
class TypeDefinition : ITypeSignature
|
||||
private class TypeDefinition : ITypeSignature
|
||||
{
|
||||
private readonly TypeDefinitionHandle handle;
|
||||
|
||||
@@ -1445,7 +1460,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
return new TypeDefinition(handle);
|
||||
}
|
||||
|
||||
class TypeReference : ITypeSignature
|
||||
private class TypeReference : ITypeSignature
|
||||
{
|
||||
private readonly TypeReferenceHandle handle;
|
||||
|
||||
@@ -1479,7 +1494,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// </summary>
|
||||
public class TypeSignatureDecoder : ISignatureTypeProvider<Type, GenericContext>
|
||||
{
|
||||
readonly Context cx;
|
||||
private readonly Context cx;
|
||||
|
||||
public TypeSignatureDecoder(Context cx)
|
||||
{
|
||||
|
||||
@@ -121,9 +121,9 @@ namespace Semmle.Extraction.CIL
|
||||
/// <summary>
|
||||
/// A tuple that is an extraction product.
|
||||
/// </summary>
|
||||
class Tuple : IExtractionProduct
|
||||
internal class Tuple : IExtractionProduct
|
||||
{
|
||||
readonly Extraction.Tuple tuple;
|
||||
private readonly Extraction.Tuple tuple;
|
||||
|
||||
public Tuple(string name, params object[] args)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Semmle.Extraction.CIL
|
||||
/// </summary>
|
||||
public sealed partial class Context
|
||||
{
|
||||
readonly Dictionary<object, Label> ids = new Dictionary<object, Label>();
|
||||
private readonly Dictionary<object, Label> ids = new Dictionary<object, Label>();
|
||||
|
||||
public T Populate<T>(T e) where T : IExtractedEntity
|
||||
{
|
||||
@@ -97,9 +97,9 @@ namespace Semmle.Extraction.CIL
|
||||
/// <returns></returns>
|
||||
public IExtractedEntity CreateGeneric(GenericContext genericContext, Handle h) => genericHandleFactory[genericContext, h];
|
||||
|
||||
readonly GenericContext defaultGenericContext;
|
||||
private readonly GenericContext defaultGenericContext;
|
||||
|
||||
IExtractedEntity CreateGenericHandle(GenericContext gc, Handle handle)
|
||||
private IExtractedEntity CreateGenericHandle(GenericContext gc, Handle handle)
|
||||
{
|
||||
IExtractedEntity entity;
|
||||
switch (handle.Kind)
|
||||
@@ -136,7 +136,7 @@ namespace Semmle.Extraction.CIL
|
||||
return entity;
|
||||
}
|
||||
|
||||
IExtractedEntity Create(GenericContext gc, MemberReferenceHandle handle)
|
||||
private IExtractedEntity Create(GenericContext gc, MemberReferenceHandle handle)
|
||||
{
|
||||
var mr = mdReader.GetMemberReference(handle);
|
||||
switch (mr.GetKind())
|
||||
@@ -159,11 +159,11 @@ namespace Semmle.Extraction.CIL
|
||||
|
||||
#region Namespaces
|
||||
|
||||
readonly CachedFunction<StringHandle, Namespace> namespaceFactory;
|
||||
private readonly CachedFunction<StringHandle, Namespace> namespaceFactory;
|
||||
|
||||
public Namespace CreateNamespace(StringHandle fqn) => namespaceFactory[fqn];
|
||||
|
||||
readonly Lazy<Namespace> globalNamespace, systemNamespace;
|
||||
private readonly Lazy<Namespace> globalNamespace, systemNamespace;
|
||||
|
||||
/// <summary>
|
||||
/// The entity representing the global namespace.
|
||||
@@ -180,9 +180,9 @@ namespace Semmle.Extraction.CIL
|
||||
/// </summary>
|
||||
/// <param name="fqn">The fully-qualified namespace name.</param>
|
||||
/// <returns>The namespace entity.</returns>
|
||||
Namespace CreateNamespace(string fqn) => Populate(new Namespace(this, fqn));
|
||||
private Namespace CreateNamespace(string fqn) => Populate(new Namespace(this, fqn));
|
||||
|
||||
readonly CachedFunction<NamespaceDefinitionHandle, Namespace> namespaceDefinitionFactory;
|
||||
private readonly CachedFunction<NamespaceDefinitionHandle, Namespace> namespaceDefinitionFactory;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a namespace from a namespace handle.
|
||||
@@ -191,7 +191,7 @@ namespace Semmle.Extraction.CIL
|
||||
/// <returns>The namespace entity.</returns>
|
||||
public Namespace Create(NamespaceDefinitionHandle handle) => namespaceDefinitionFactory[handle];
|
||||
|
||||
Namespace CreateNamespace(NamespaceDefinitionHandle handle)
|
||||
private Namespace CreateNamespace(NamespaceDefinitionHandle handle)
|
||||
{
|
||||
if (handle.IsNil) return GlobalNamespace;
|
||||
NamespaceDefinition nd = mdReader.GetNamespaceDefinition(handle);
|
||||
@@ -200,9 +200,9 @@ namespace Semmle.Extraction.CIL
|
||||
#endregion
|
||||
|
||||
#region Locations
|
||||
readonly CachedFunction<PDB.ISourceFile, PdbSourceFile> sourceFiles;
|
||||
readonly CachedFunction<PathTransformer.ITransformedPath, Folder> folders;
|
||||
readonly CachedFunction<PDB.Location, PdbSourceLocation> sourceLocations;
|
||||
private readonly CachedFunction<PDB.ISourceFile, PdbSourceFile> sourceFiles;
|
||||
private readonly CachedFunction<PathTransformer.ITransformedPath, Folder> folders;
|
||||
private readonly CachedFunction<PDB.Location, PdbSourceLocation> sourceLocations;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a source file entity from a PDB source file.
|
||||
@@ -227,7 +227,7 @@ namespace Semmle.Extraction.CIL
|
||||
|
||||
#endregion
|
||||
|
||||
readonly CachedFunction<GenericContext, Handle, IExtractedEntity> genericHandleFactory;
|
||||
private readonly CachedFunction<GenericContext, Handle, IExtractedEntity> genericHandleFactory;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the short name of a member, without the preceding interface qualifier.
|
||||
|
||||
@@ -13,9 +13,9 @@ namespace Semmle.Extraction.PDB
|
||||
///
|
||||
/// PDB information can be in a separate PDB file, or embedded in the DLL.
|
||||
/// </summary>
|
||||
sealed class MetadataPdbReader : IPdb
|
||||
internal sealed class MetadataPdbReader : IPdb
|
||||
{
|
||||
class SourceFile : ISourceFile
|
||||
private class SourceFile : ISourceFile
|
||||
{
|
||||
public SourceFile(MetadataReader reader, DocumentHandle handle)
|
||||
{
|
||||
@@ -30,8 +30,8 @@ namespace Semmle.Extraction.PDB
|
||||
|
||||
// Turns out to be very important to keep the MetadataReaderProvider live
|
||||
// or the reader will crash.
|
||||
readonly MetadataReaderProvider provider;
|
||||
readonly MetadataReader reader;
|
||||
private readonly MetadataReaderProvider provider;
|
||||
private readonly MetadataReader reader;
|
||||
|
||||
public MetadataPdbReader(MetadataReaderProvider provider)
|
||||
{
|
||||
|
||||
@@ -14,11 +14,11 @@ namespace Semmle.Extraction.PDB
|
||||
/// A PDB reader using Microsoft.DiaSymReader.Native.
|
||||
/// This is an unmanaged Windows DLL, which therefore only works on Windows.
|
||||
/// </summary>
|
||||
sealed class NativePdbReader : IPdb
|
||||
internal sealed class NativePdbReader : IPdb
|
||||
{
|
||||
sealed class Document : ISourceFile
|
||||
private sealed class Document : ISourceFile
|
||||
{
|
||||
readonly ISymUnmanagedDocument document;
|
||||
private readonly ISymUnmanagedDocument document;
|
||||
|
||||
public Document(ISymUnmanagedDocument doc)
|
||||
{
|
||||
@@ -49,7 +49,7 @@ namespace Semmle.Extraction.PDB
|
||||
|
||||
public override string ToString() => Path;
|
||||
|
||||
readonly Lazy<string?> contents;
|
||||
private readonly Lazy<string?> contents;
|
||||
|
||||
public string? Contents => contents.Value;
|
||||
}
|
||||
@@ -76,15 +76,15 @@ namespace Semmle.Extraction.PDB
|
||||
return null;
|
||||
}
|
||||
|
||||
NativePdbReader(string path)
|
||||
private NativePdbReader(string path)
|
||||
{
|
||||
pdbStream = new FileStream(path, FileMode.Open);
|
||||
var metadataProvider = new MdProvider();
|
||||
reader = SymUnmanagedReaderFactory.CreateReader<ISymUnmanagedReader5>(pdbStream, metadataProvider);
|
||||
}
|
||||
|
||||
readonly ISymUnmanagedReader5 reader;
|
||||
readonly FileStream pdbStream;
|
||||
private readonly ISymUnmanagedReader5 reader;
|
||||
private readonly FileStream pdbStream;
|
||||
|
||||
public static NativePdbReader? CreateFromAssembly(PEReader peReader)
|
||||
{
|
||||
@@ -118,7 +118,7 @@ namespace Semmle.Extraction.PDB
|
||||
/// <summary>
|
||||
/// This is not used but is seemingly needed in order to use DiaSymReader.
|
||||
/// </summary>
|
||||
class MdProvider : ISymReaderMetadataProvider
|
||||
internal class MdProvider : ISymReaderMetadataProvider
|
||||
{
|
||||
public MdProvider()
|
||||
{
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace Semmle.Extraction.PDB
|
||||
Location Location { get; }
|
||||
}
|
||||
|
||||
class Method : IMethod
|
||||
internal class Method : IMethod
|
||||
{
|
||||
public IEnumerable<SequencePoint> SequencePoints { get; }
|
||||
|
||||
@@ -136,7 +136,7 @@ namespace Semmle.Extraction.PDB
|
||||
IMethod? GetMethod(MethodDebugInformationHandle methodHandle);
|
||||
}
|
||||
|
||||
class PdbReader
|
||||
internal class PdbReader
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the PDB information associated with an assembly.
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Semmle.Extraction.CSharp
|
||||
/// </summary>
|
||||
public class Driver
|
||||
{
|
||||
static int Main(string[] args)
|
||||
public static int Main(string[] args)
|
||||
{
|
||||
return (int)Extractor.Run(args);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Semmle.BuildAnalyser
|
||||
/// Searches for assembly DLLs, indexes them and provides
|
||||
/// a lookup facility from assembly ID to filename.
|
||||
/// </summary>
|
||||
class AssemblyCache
|
||||
internal class AssemblyCache
|
||||
{
|
||||
/// <summary>
|
||||
/// Locate all reference files and index them.
|
||||
@@ -33,7 +33,7 @@ namespace Semmle.BuildAnalyser
|
||||
/// (Indexing is performed at a later stage by IndexReferences()).
|
||||
/// </summary>
|
||||
/// <param name="dir">The directory to index.</param>
|
||||
void AddReferenceDirectory(string dir)
|
||||
private void AddReferenceDirectory(string dir)
|
||||
{
|
||||
foreach (var dll in new DirectoryInfo(dir).EnumerateFiles("*.dll", SearchOption.AllDirectories))
|
||||
{
|
||||
@@ -45,7 +45,7 @@ namespace Semmle.BuildAnalyser
|
||||
/// Indexes all DLLs we have located.
|
||||
/// Because this is a potentially time-consuming operation, it is put into a separate stage.
|
||||
/// </summary>
|
||||
void IndexReferences()
|
||||
private void IndexReferences()
|
||||
{
|
||||
// Read all of the files
|
||||
foreach (var filename in pendingDllsToIndex)
|
||||
@@ -177,17 +177,17 @@ namespace Semmle.BuildAnalyser
|
||||
throw new AssemblyLoadException();
|
||||
}
|
||||
|
||||
readonly Queue<string> pendingDllsToIndex = new Queue<string>();
|
||||
private readonly Queue<string> pendingDllsToIndex = new Queue<string>();
|
||||
|
||||
readonly Dictionary<string, AssemblyInfo> assemblyInfoByFileName = new Dictionary<string, AssemblyInfo>();
|
||||
private readonly Dictionary<string, AssemblyInfo> assemblyInfoByFileName = new Dictionary<string, AssemblyInfo>();
|
||||
|
||||
// List of DLLs which are not assemblies.
|
||||
// We probably don't need to keep this
|
||||
readonly List<string> failedAssemblyInfoFileNames = new List<string>();
|
||||
private readonly List<string> failedAssemblyInfoFileNames = new List<string>();
|
||||
|
||||
// Map from assembly id (in various formats) to the full info.
|
||||
readonly Dictionary<string, AssemblyInfo> assemblyInfoById = new Dictionary<string, AssemblyInfo>();
|
||||
private readonly Dictionary<string, AssemblyInfo> assemblyInfoById = new Dictionary<string, AssemblyInfo>();
|
||||
|
||||
readonly HashSet<string> failedAssemblyInfoIds = new HashSet<string>();
|
||||
private readonly HashSet<string> failedAssemblyInfoIds = new HashSet<string>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Semmle.BuildAnalyser
|
||||
/// <summary>
|
||||
/// Stores information about an assembly file (DLL).
|
||||
/// </summary>
|
||||
sealed class AssemblyInfo
|
||||
internal sealed class AssemblyInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// The file containing the assembly.
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Semmle.BuildAnalyser
|
||||
/// <summary>
|
||||
/// The output of a build analysis.
|
||||
/// </summary>
|
||||
interface IBuildAnalysis
|
||||
internal interface IBuildAnalysis
|
||||
{
|
||||
/// <summary>
|
||||
/// Full filepaths of external references.
|
||||
@@ -46,7 +46,7 @@ namespace Semmle.BuildAnalyser
|
||||
/// <summary>
|
||||
/// Main implementation of the build analysis.
|
||||
/// </summary>
|
||||
sealed class BuildAnalysis : IBuildAnalysis, IDisposable
|
||||
internal sealed class BuildAnalysis : IBuildAnalysis, IDisposable
|
||||
{
|
||||
private readonly AssemblyCache assemblyCache;
|
||||
private readonly IProgressMonitor progressMonitor;
|
||||
@@ -172,7 +172,7 @@ namespace Semmle.BuildAnalyser
|
||||
/// If the same assembly name is duplicated with different versions,
|
||||
/// resolve to the higher version number.
|
||||
/// </summary>
|
||||
void ResolveConflicts()
|
||||
private void ResolveConflicts()
|
||||
{
|
||||
var sortedReferences = new List<AssemblyInfo>();
|
||||
foreach (var usedReference in usedReferences)
|
||||
@@ -217,7 +217,7 @@ namespace Semmle.BuildAnalyser
|
||||
/// Store that a particular reference file is used.
|
||||
/// </summary>
|
||||
/// <param name="reference">The filename of the reference.</param>
|
||||
void UseReference(string reference)
|
||||
private void UseReference(string reference)
|
||||
{
|
||||
usedReferences[reference] = true;
|
||||
}
|
||||
@@ -226,7 +226,7 @@ namespace Semmle.BuildAnalyser
|
||||
/// Store that a particular source file is used (by a project file).
|
||||
/// </summary>
|
||||
/// <param name="sourceFile">The source file.</param>
|
||||
void UseSource(FileInfo sourceFile)
|
||||
private void UseSource(FileInfo sourceFile)
|
||||
{
|
||||
sources[sourceFile.FullName] = sourceFile.Exists;
|
||||
}
|
||||
@@ -263,24 +263,24 @@ namespace Semmle.BuildAnalyser
|
||||
/// </summary>
|
||||
/// <param name="id">The assembly ID.</param>
|
||||
/// <param name="projectFile">The project file making the reference.</param>
|
||||
void UnresolvedReference(string id, string projectFile)
|
||||
private void UnresolvedReference(string id, string projectFile)
|
||||
{
|
||||
unresolvedReferences[id] = projectFile;
|
||||
}
|
||||
|
||||
readonly TemporaryDirectory PackageDirectory;
|
||||
private readonly TemporaryDirectory PackageDirectory;
|
||||
|
||||
/// <summary>
|
||||
/// Reads all the source files and references from the given list of projects.
|
||||
/// </summary>
|
||||
/// <param name="projectFiles">The list of projects to analyse.</param>
|
||||
void AnalyseProjectFiles(IEnumerable<FileInfo> projectFiles)
|
||||
private void AnalyseProjectFiles(IEnumerable<FileInfo> projectFiles)
|
||||
{
|
||||
foreach (var proj in projectFiles)
|
||||
AnalyseProject(proj);
|
||||
}
|
||||
|
||||
void AnalyseProject(FileInfo project)
|
||||
private void AnalyseProject(FileInfo project)
|
||||
{
|
||||
if (!project.Exists)
|
||||
{
|
||||
@@ -323,7 +323,7 @@ namespace Semmle.BuildAnalyser
|
||||
|
||||
}
|
||||
|
||||
void Restore(string projectOrSolution)
|
||||
private void Restore(string projectOrSolution)
|
||||
{
|
||||
int exit = DotNet.RestoreToDirectory(projectOrSolution, PackageDirectory.DirInfo.FullName);
|
||||
switch (exit)
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Semmle.BuildAnalyser
|
||||
/// <summary>
|
||||
/// Represents a .csproj file and reads information from it.
|
||||
/// </summary>
|
||||
class CsProjFile
|
||||
internal class CsProjFile
|
||||
{
|
||||
private string Filename { get; }
|
||||
|
||||
@@ -126,8 +126,8 @@ namespace Semmle.BuildAnalyser
|
||||
return (csFiles, references);
|
||||
}
|
||||
|
||||
readonly string[] references;
|
||||
readonly string[] csFiles;
|
||||
private readonly string[] references;
|
||||
private readonly string[] csFiles;
|
||||
|
||||
/// <summary>
|
||||
/// The list of references as a list of assembly IDs.
|
||||
@@ -140,7 +140,7 @@ namespace Semmle.BuildAnalyser
|
||||
public IEnumerable<string> Sources => csFiles;
|
||||
}
|
||||
|
||||
static class XmlNodeHelper
|
||||
internal static class XmlNodeHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper to convert an XmlNodeList into an IEnumerable.
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Semmle.BuildAnalyser
|
||||
/// <summary>
|
||||
/// Utilities to run the "dotnet" command.
|
||||
/// </summary>
|
||||
static class DotNet
|
||||
internal static class DotNet
|
||||
{
|
||||
public static int RestoreToDirectory(string projectOrSolutionFile, string packageDirectory)
|
||||
{
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Semmle.BuildAnalyser
|
||||
/// Locates packages in a source tree and downloads all of the
|
||||
/// referenced assemblies to a temp folder.
|
||||
/// </summary>
|
||||
class NugetPackages
|
||||
internal class NugetPackages
|
||||
{
|
||||
/// <summary>
|
||||
/// Create the package manager for a specified source tree.
|
||||
@@ -80,7 +80,7 @@ namespace Semmle.BuildAnalyser
|
||||
/// </summary>
|
||||
/// <param name="package">The package file.</param>
|
||||
/// <param name="pm">Where to log progress/errors.</param>
|
||||
void RestoreNugetPackage(string package, IProgressMonitor pm)
|
||||
private void RestoreNugetPackage(string package, IProgressMonitor pm)
|
||||
{
|
||||
pm.NugetInstall(package);
|
||||
|
||||
@@ -129,6 +129,6 @@ namespace Semmle.BuildAnalyser
|
||||
}
|
||||
}
|
||||
|
||||
readonly string nugetExe;
|
||||
private readonly string nugetExe;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Semmle.Extraction.CSharp.Standalone
|
||||
/// </summary>
|
||||
public sealed class Options : CommonOptions
|
||||
{
|
||||
public override bool handleFlag(string key, bool value)
|
||||
public override bool HandleFlag(string key, bool value)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
@@ -40,11 +40,11 @@ namespace Semmle.Extraction.CSharp.Standalone
|
||||
UseSelfContainedDotnet = value;
|
||||
return true;
|
||||
default:
|
||||
return base.handleFlag(key, value);
|
||||
return base.HandleFlag(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool handleOption(string key, string value)
|
||||
public override bool HandleOption(string key, string value)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
@@ -55,11 +55,11 @@ namespace Semmle.Extraction.CSharp.Standalone
|
||||
DllDirs.Add(value);
|
||||
return true;
|
||||
default:
|
||||
return base.handleOption(key, value);
|
||||
return base.HandleOption(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool handleArgument(string arg)
|
||||
public override bool HandleArgument(string arg)
|
||||
{
|
||||
SolutionFile = arg;
|
||||
var fi = new FileInfo(SolutionFile);
|
||||
@@ -71,7 +71,7 @@ namespace Semmle.Extraction.CSharp.Standalone
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void invalidArgument(string argument)
|
||||
public override void InvalidArgument(string argument)
|
||||
{
|
||||
System.Console.WriteLine($"Error: Invalid argument {argument}");
|
||||
Errors = true;
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Semmle.Extraction.CSharp.Standalone
|
||||
/// <summary>
|
||||
/// One independent run of the extractor.
|
||||
/// </summary>
|
||||
class Extraction
|
||||
internal class Extraction
|
||||
{
|
||||
public Extraction(string directory)
|
||||
{
|
||||
@@ -22,7 +22,7 @@ namespace Semmle.Extraction.CSharp.Standalone
|
||||
/// <summary>
|
||||
/// Searches for source/references and creates separate extractions.
|
||||
/// </summary>
|
||||
sealed class Analysis : IDisposable
|
||||
internal sealed class Analysis : IDisposable
|
||||
{
|
||||
public Analysis(ILogger logger, Options options)
|
||||
{
|
||||
@@ -40,7 +40,7 @@ namespace Semmle.Extraction.CSharp.Standalone
|
||||
/// </summary>
|
||||
public Extraction Extraction { get; }
|
||||
|
||||
readonly BuildAnalysis buildAnalysis;
|
||||
private readonly BuildAnalysis buildAnalysis;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
@@ -50,7 +50,7 @@ namespace Semmle.Extraction.CSharp.Standalone
|
||||
|
||||
public class Program
|
||||
{
|
||||
static int Main(string[] args)
|
||||
public static int Main(string[] args)
|
||||
{
|
||||
var options = Options.Create(args);
|
||||
// options.CIL = true; // To do: Enable this
|
||||
@@ -95,14 +95,14 @@ namespace Semmle.Extraction.CSharp.Standalone
|
||||
return 0;
|
||||
}
|
||||
|
||||
class ExtractionProgress : IProgressMonitor
|
||||
private class ExtractionProgress : IProgressMonitor
|
||||
{
|
||||
public ExtractionProgress(ILogger output)
|
||||
{
|
||||
logger = output;
|
||||
}
|
||||
|
||||
readonly ILogger logger;
|
||||
private readonly ILogger logger;
|
||||
|
||||
public void Analysed(int item, int total, string source, string output, TimeSpan time, AnalysisAction action)
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Semmle.BuildAnalyser
|
||||
/// <summary>
|
||||
/// Callback for various events that may happen during the build analysis.
|
||||
/// </summary>
|
||||
interface IProgressMonitor
|
||||
internal interface IProgressMonitor
|
||||
{
|
||||
void FindingFiles(string dir);
|
||||
void UnresolvedReference(string id, string project);
|
||||
@@ -23,9 +23,9 @@ namespace Semmle.BuildAnalyser
|
||||
void MissingNuGet();
|
||||
}
|
||||
|
||||
class ProgressMonitor : IProgressMonitor
|
||||
internal class ProgressMonitor : IProgressMonitor
|
||||
{
|
||||
readonly ILogger logger;
|
||||
private readonly ILogger logger;
|
||||
|
||||
public ProgressMonitor(ILogger logger)
|
||||
{
|
||||
|
||||
@@ -10,9 +10,9 @@ namespace Semmle.Extraction.CSharp.Standalone
|
||||
/// <summary>
|
||||
/// Locates .NET Runtimes.
|
||||
/// </summary>
|
||||
static class Runtime
|
||||
internal static class Runtime
|
||||
{
|
||||
static string ExecutingRuntime => RuntimeEnvironment.GetRuntimeDirectory();
|
||||
private static string ExecutingRuntime => RuntimeEnvironment.GetRuntimeDirectory();
|
||||
|
||||
/// <summary>
|
||||
/// Locates .NET Core Runtimes.
|
||||
|
||||
@@ -8,9 +8,9 @@ namespace Semmle.BuildAnalyser
|
||||
/// <summary>
|
||||
/// Access data in a .sln file.
|
||||
/// </summary>
|
||||
class SolutionFile
|
||||
internal class SolutionFile
|
||||
{
|
||||
readonly Microsoft.Build.Construction.SolutionFile solutionFile;
|
||||
private readonly Microsoft.Build.Construction.SolutionFile solutionFile;
|
||||
|
||||
private string FullPath { get; }
|
||||
|
||||
|
||||
@@ -17,11 +17,11 @@ namespace Semmle.Extraction.CSharp
|
||||
/// </summary>
|
||||
public sealed class Analyser : IDisposable
|
||||
{
|
||||
IExtractor extractor;
|
||||
private IExtractor extractor;
|
||||
|
||||
readonly Stopwatch stopWatch = new Stopwatch();
|
||||
private readonly Stopwatch stopWatch = new Stopwatch();
|
||||
|
||||
readonly IProgressMonitor progressMonitor;
|
||||
private readonly IProgressMonitor progressMonitor;
|
||||
|
||||
public readonly ILogger Logger;
|
||||
|
||||
@@ -39,8 +39,8 @@ namespace Semmle.Extraction.CSharp
|
||||
PathTransformer = pathTransformer;
|
||||
}
|
||||
|
||||
CSharpCompilation compilation;
|
||||
Layout layout;
|
||||
private CSharpCompilation compilation;
|
||||
private Layout layout;
|
||||
|
||||
private bool init;
|
||||
/// <summary>
|
||||
@@ -84,7 +84,7 @@ namespace Semmle.Extraction.CSharp
|
||||
/// Roslyn doesn't record the relationship between a filename and its assembly
|
||||
/// information, so we need to retrieve this information manually.
|
||||
/// </summary>
|
||||
void SetReferencePaths()
|
||||
private void SetReferencePaths()
|
||||
{
|
||||
foreach (var reference in compilation.References.OfType<PortableExecutableReference>())
|
||||
{
|
||||
@@ -126,14 +126,14 @@ namespace Semmle.Extraction.CSharp
|
||||
SetReferencePaths();
|
||||
}
|
||||
|
||||
readonly HashSet<string> errorsToIgnore = new HashSet<string>
|
||||
private readonly HashSet<string> errorsToIgnore = new HashSet<string>
|
||||
{
|
||||
"CS7027", // Code signing failure
|
||||
"CS1589", // XML referencing not supported
|
||||
"CS1569" // Error writing XML documentation
|
||||
};
|
||||
|
||||
IEnumerable<Diagnostic> FilteredDiagnostics
|
||||
private IEnumerable<Diagnostic> FilteredDiagnostics
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -154,7 +154,7 @@ namespace Semmle.Extraction.CSharp
|
||||
/// <param name="compilation">Information about the compilation.</param>
|
||||
/// <param name="cancel">Cancellation token required.</param>
|
||||
/// <returns>The filename.</returns>
|
||||
static string GetOutputName(CSharpCompilation compilation,
|
||||
private static string GetOutputName(CSharpCompilation compilation,
|
||||
CSharpCommandLineArguments commandLineArguments)
|
||||
{
|
||||
// There's no apparent way to access the output filename from the compilation,
|
||||
@@ -194,7 +194,7 @@ namespace Semmle.Extraction.CSharp
|
||||
/// Perform an analysis on an assembly.
|
||||
/// </summary>
|
||||
/// <param name="assembly">Assembly to analyse.</param>
|
||||
void AnalyseAssembly(PortableExecutableReference assembly)
|
||||
private void AnalyseAssembly(PortableExecutableReference assembly)
|
||||
{
|
||||
// CIL first - it takes longer.
|
||||
if (options.CIL)
|
||||
@@ -202,12 +202,12 @@ namespace Semmle.Extraction.CSharp
|
||||
extractionTasks.Add(() => DoAnalyseAssembly(assembly));
|
||||
}
|
||||
|
||||
readonly object progressMutex = new object();
|
||||
int taskCount = 0;
|
||||
private readonly object progressMutex = new object();
|
||||
private int taskCount = 0;
|
||||
|
||||
CommonOptions options;
|
||||
private CommonOptions options;
|
||||
|
||||
static bool FileIsUpToDate(string src, string dest)
|
||||
private static bool FileIsUpToDate(string src, string dest)
|
||||
{
|
||||
return File.Exists(dest) &&
|
||||
File.GetLastWriteTime(dest) >= File.GetLastWriteTime(src);
|
||||
@@ -221,10 +221,10 @@ namespace Semmle.Extraction.CSharp
|
||||
extractionTasks.Add(() => DoAnalyseCompilation(cwd, args));
|
||||
}
|
||||
|
||||
Entities.Compilation compilationEntity;
|
||||
IDisposable compilationTrapFile;
|
||||
private Entities.Compilation compilationEntity;
|
||||
private IDisposable compilationTrapFile;
|
||||
|
||||
void DoAnalyseCompilation(string cwd, string[] args)
|
||||
private void DoAnalyseCompilation(string cwd, string[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -252,7 +252,7 @@ namespace Semmle.Extraction.CSharp
|
||||
/// extraction within the snapshot.
|
||||
/// </summary>
|
||||
/// <param name="r">The assembly to extract.</param>
|
||||
void DoAnalyseAssembly(PortableExecutableReference r)
|
||||
private void DoAnalyseAssembly(PortableExecutableReference r)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -308,7 +308,7 @@ namespace Semmle.Extraction.CSharp
|
||||
}
|
||||
}
|
||||
|
||||
void DoExtractCIL(PortableExecutableReference r)
|
||||
private void DoExtractCIL(PortableExecutableReference r)
|
||||
{
|
||||
var stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
@@ -317,7 +317,7 @@ namespace Semmle.Extraction.CSharp
|
||||
ReportProgress(r.FilePath, trapFile, stopwatch.Elapsed, extracted ? AnalysisAction.Extracted : AnalysisAction.UpToDate);
|
||||
}
|
||||
|
||||
void AnalyseNamespace(Context cx, INamespaceSymbol ns)
|
||||
private void AnalyseNamespace(Context cx, INamespaceSymbol ns)
|
||||
{
|
||||
foreach (var memberNamespace in ns.GetNamespaceMembers())
|
||||
{
|
||||
@@ -342,15 +342,15 @@ namespace Semmle.Extraction.CSharp
|
||||
}
|
||||
|
||||
// The bulk of the extraction work, potentially executed in parallel.
|
||||
readonly List<Action> extractionTasks = new List<Action>();
|
||||
private readonly List<Action> extractionTasks = new List<Action>();
|
||||
|
||||
void ReportProgress(string src, string output, TimeSpan time, AnalysisAction action)
|
||||
private void ReportProgress(string src, string output, TimeSpan time, AnalysisAction action)
|
||||
{
|
||||
lock (progressMutex)
|
||||
progressMonitor.Analysed(++taskCount, extractionTasks.Count, src, output, time, action);
|
||||
}
|
||||
|
||||
void DoExtractTree(SyntaxTree tree)
|
||||
private void DoExtractTree(SyntaxTree tree)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -13,8 +13,8 @@ namespace Semmle.Extraction.CSharp
|
||||
/// </summary>
|
||||
public class CompilerVersion
|
||||
{
|
||||
const string csc_rsp = "csc.rsp";
|
||||
readonly string specifiedFramework = null;
|
||||
private const string csc_rsp = "csc.rsp";
|
||||
private readonly string specifiedFramework = null;
|
||||
|
||||
/// <summary>
|
||||
/// The value specified by --compiler, or null.
|
||||
@@ -85,7 +85,7 @@ namespace Semmle.Extraction.CSharp
|
||||
ArgsWithResponse = AddDefaultResponse(CscRsp, options.CompilerArguments).ToArray();
|
||||
}
|
||||
|
||||
void SkipExtractionBecause(string reason)
|
||||
private void SkipExtractionBecause(string reason)
|
||||
{
|
||||
SkipExtraction = true;
|
||||
SkipReason = reason;
|
||||
@@ -99,7 +99,7 @@ namespace Semmle.Extraction.CSharp
|
||||
/// <summary>
|
||||
/// The file csc.rsp.
|
||||
/// </summary>
|
||||
string CscRsp => Path.Combine(FrameworkPath, csc_rsp);
|
||||
private string CscRsp => Path.Combine(FrameworkPath, csc_rsp);
|
||||
|
||||
/// <summary>
|
||||
/// Should we skip extraction?
|
||||
@@ -122,14 +122,14 @@ namespace Semmle.Extraction.CSharp
|
||||
/// <param name="responseFile">The full pathname of csc.rsp.</param>
|
||||
/// <param name="args">The other command line arguments.</param>
|
||||
/// <returns>Modified list of arguments.</returns>
|
||||
static IEnumerable<string> AddDefaultResponse(string responseFile, IEnumerable<string> args)
|
||||
private static IEnumerable<string> AddDefaultResponse(string responseFile, IEnumerable<string> args)
|
||||
{
|
||||
return SuppressDefaultResponseFile(args) || !File.Exists(responseFile) ?
|
||||
args :
|
||||
new[] { "@" + responseFile }.Concat(args);
|
||||
}
|
||||
|
||||
static bool SuppressDefaultResponseFile(IEnumerable<string> args)
|
||||
private static bool SuppressDefaultResponseFile(IEnumerable<string> args)
|
||||
{
|
||||
return args.Any(arg => new[] { "/noconfig", "-noconfig" }.Contains(arg.ToLowerInvariant()));
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
class Accessor : Method
|
||||
internal class Accessor : Method
|
||||
{
|
||||
protected Accessor(Context cx, IMethodSymbol init)
|
||||
: base(cx, init) { }
|
||||
@@ -29,7 +29,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
/// <summary>
|
||||
/// Gets the property symbol associated with this accessor.
|
||||
/// </summary>
|
||||
IPropertySymbol PropertySymbol => GetPropertySymbol(symbol);
|
||||
private IPropertySymbol PropertySymbol => GetPropertySymbol(symbol);
|
||||
|
||||
public new Accessor OriginalDefinition => Create(Context, symbol.OriginalDefinition);
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
public new static Accessor Create(Context cx, IMethodSymbol symbol) =>
|
||||
AccessorFactory.Instance.CreateEntityFromSymbol(cx, symbol);
|
||||
|
||||
class AccessorFactory : ICachedEntityFactory<IMethodSymbol, Accessor>
|
||||
private class AccessorFactory : ICachedEntityFactory<IMethodSymbol, Accessor>
|
||||
{
|
||||
public static readonly AccessorFactory Instance = new AccessorFactory();
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
class Attribute : FreshEntity, IExpressionParentEntity
|
||||
internal class Attribute : FreshEntity, IExpressionParentEntity
|
||||
{
|
||||
bool IExpressionParentEntity.IsTopLevelParent => true;
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
ExtractAttribute(cx.TrapWriter.Writer, attribute, info.Symbol.ContainingType, entity);
|
||||
}
|
||||
|
||||
void ExtractAttribute(System.IO.TextWriter trapFile, AttributeSyntax syntax, ITypeSymbol attributeClass, IEntity entity)
|
||||
private void ExtractAttribute(System.IO.TextWriter trapFile, AttributeSyntax syntax, ITypeSymbol attributeClass, IEntity entity)
|
||||
{
|
||||
var type = Type.Create(cx, attributeClass);
|
||||
trapFile.attributes(this, type.TypeRef, entity);
|
||||
|
||||
@@ -4,9 +4,9 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
class CommentBlock : CachedEntity<ICommentBlock>
|
||||
internal class CommentBlock : CachedEntity<ICommentBlock>
|
||||
{
|
||||
CommentBlock(Context cx, ICommentBlock init)
|
||||
private CommentBlock(Context cx, ICommentBlock init)
|
||||
: base(cx, init) { }
|
||||
|
||||
public override void Populate(TextWriter trapFile)
|
||||
@@ -37,7 +37,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
public static CommentBlock Create(Context cx, ICommentBlock block) => CommentBlockFactory.Instance.CreateEntity(cx, block, block);
|
||||
|
||||
class CommentBlockFactory : ICachedEntityFactory<ICommentBlock, CommentBlock>
|
||||
private class CommentBlockFactory : ICachedEntityFactory<ICommentBlock, CommentBlock>
|
||||
{
|
||||
public static readonly CommentBlockFactory Instance = new CommentBlockFactory();
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
class CommentLine : CachedEntity<(Microsoft.CodeAnalysis.Location, string)>, ICommentLine
|
||||
internal class CommentLine : CachedEntity<(Microsoft.CodeAnalysis.Location, string)>, ICommentLine
|
||||
{
|
||||
CommentLine(Context cx, Microsoft.CodeAnalysis.Location loc, CommentLineType type, string text, string raw)
|
||||
private CommentLine(Context cx, Microsoft.CodeAnalysis.Location loc, CommentLineType type, string text, string raw)
|
||||
: base(cx, (loc, text))
|
||||
{
|
||||
Type = type;
|
||||
@@ -110,7 +110,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
}
|
||||
}
|
||||
|
||||
Extraction.Entities.Location location;
|
||||
private Extraction.Entities.Location location;
|
||||
|
||||
public override void Populate(TextWriter trapFile)
|
||||
{
|
||||
@@ -129,13 +129,13 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
trapFile.Write(";commentline");
|
||||
}
|
||||
|
||||
static CommentLine Create(Context cx, Microsoft.CodeAnalysis.Location loc, CommentLineType type, string text, string raw)
|
||||
private static CommentLine Create(Context cx, Microsoft.CodeAnalysis.Location loc, CommentLineType type, string text, string raw)
|
||||
{
|
||||
var init = (loc, type, text, raw);
|
||||
return CommentLineFactory.Instance.CreateEntity(cx, init, init);
|
||||
}
|
||||
|
||||
class CommentLineFactory : ICachedEntityFactory<(Microsoft.CodeAnalysis.Location, CommentLineType, string, string), CommentLine>
|
||||
private class CommentLineFactory : ICachedEntityFactory<(Microsoft.CodeAnalysis.Location, CommentLineType, string, string), CommentLine>
|
||||
{
|
||||
public static readonly CommentLineFactory Instance = new CommentLineFactory();
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ using Semmle.Util;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
class Compilation : FreshEntity
|
||||
internal class Compilation : FreshEntity
|
||||
{
|
||||
private readonly string cwd;
|
||||
private readonly string[] args;
|
||||
@@ -68,11 +68,11 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
public override TrapStackBehaviour TrapStackBehaviour => TrapStackBehaviour.NoLabel;
|
||||
}
|
||||
|
||||
class Diagnostic : FreshEntity
|
||||
internal class Diagnostic : FreshEntity
|
||||
{
|
||||
public override TrapStackBehaviour TrapStackBehaviour => TrapStackBehaviour.NoLabel;
|
||||
|
||||
readonly Microsoft.CodeAnalysis.Diagnostic diagnostic;
|
||||
private readonly Microsoft.CodeAnalysis.Diagnostic diagnostic;
|
||||
|
||||
public Diagnostic(Context cx, Microsoft.CodeAnalysis.Diagnostic diag) : base(cx)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
public class Constructor : Method
|
||||
{
|
||||
Constructor(Context cx, IMethodSymbol init)
|
||||
private Constructor(Context cx, IMethodSymbol init)
|
||||
: base(cx, init) { }
|
||||
|
||||
public override void Populate(TextWriter trapFile)
|
||||
@@ -84,7 +84,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
}
|
||||
}
|
||||
|
||||
ConstructorDeclarationSyntax Syntax
|
||||
private ConstructorDeclarationSyntax Syntax
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -117,7 +117,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
trapFile.Write(";constructor");
|
||||
}
|
||||
|
||||
ConstructorDeclarationSyntax GetSyntax() =>
|
||||
private ConstructorDeclarationSyntax GetSyntax() =>
|
||||
symbol.DeclaringSyntaxReferences.Select(r => r.GetSyntax()).OfType<ConstructorDeclarationSyntax>().FirstOrDefault();
|
||||
|
||||
public override Microsoft.CodeAnalysis.Location FullLocation => ReportingLocation;
|
||||
@@ -141,7 +141,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
}
|
||||
}
|
||||
|
||||
class ConstructorFactory : ICachedEntityFactory<IMethodSymbol, Constructor>
|
||||
private class ConstructorFactory : ICachedEntityFactory<IMethodSymbol, Constructor>
|
||||
{
|
||||
public static readonly ConstructorFactory Instance = new ConstructorFactory();
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@ using System.Linq;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
class Conversion : UserOperator
|
||||
internal class Conversion : UserOperator
|
||||
{
|
||||
Conversion(Context cx, IMethodSymbol init)
|
||||
private Conversion(Context cx, IMethodSymbol init)
|
||||
: base(cx, init) { }
|
||||
|
||||
public new static Conversion Create(Context cx, IMethodSymbol symbol) =>
|
||||
@@ -26,7 +26,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
}
|
||||
}
|
||||
|
||||
class ConversionFactory : ICachedEntityFactory<IMethodSymbol, Conversion>
|
||||
private class ConversionFactory : ICachedEntityFactory<IMethodSymbol, Conversion>
|
||||
{
|
||||
public static readonly ConversionFactory Instance = new ConversionFactory();
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
class Destructor : Method
|
||||
internal class Destructor : Method
|
||||
{
|
||||
Destructor(Context cx, IMethodSymbol init)
|
||||
private Destructor(Context cx, IMethodSymbol init)
|
||||
: base(cx, init) { }
|
||||
|
||||
public override void Populate(TextWriter trapFile)
|
||||
@@ -18,7 +18,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
trapFile.destructor_location(this, Location);
|
||||
}
|
||||
|
||||
static new Destructor OriginalDefinition(Context cx, Destructor original, IMethodSymbol symbol)
|
||||
private static new Destructor OriginalDefinition(Context cx, Destructor original, IMethodSymbol symbol)
|
||||
{
|
||||
return symbol.OriginalDefinition == null || SymbolEqualityComparer.Default.Equals(symbol.OriginalDefinition, symbol) ? original : Create(cx, symbol.OriginalDefinition);
|
||||
}
|
||||
@@ -26,7 +26,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
public new static Destructor Create(Context cx, IMethodSymbol symbol) =>
|
||||
DestructorFactory.Instance.CreateEntityFromSymbol(cx, symbol);
|
||||
|
||||
class DestructorFactory : ICachedEntityFactory<IMethodSymbol, Destructor>
|
||||
private class DestructorFactory : ICachedEntityFactory<IMethodSymbol, Destructor>
|
||||
{
|
||||
public static readonly DestructorFactory Instance = new DestructorFactory();
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@ using System.Linq;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
class Event : CachedSymbol<IEventSymbol>
|
||||
internal class Event : CachedSymbol<IEventSymbol>
|
||||
{
|
||||
Event(Context cx, IEventSymbol init)
|
||||
private Event(Context cx, IEventSymbol init)
|
||||
: base(cx, init) { }
|
||||
|
||||
public override void WriteId(TextWriter trapFile)
|
||||
@@ -65,7 +65,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
public static Event Create(Context cx, IEventSymbol symbol) => EventFactory.Instance.CreateEntityFromSymbol(cx, symbol);
|
||||
|
||||
class EventFactory : ICachedEntityFactory<IEventSymbol, Event>
|
||||
private class EventFactory : ICachedEntityFactory<IEventSymbol, Event>
|
||||
{
|
||||
public static readonly EventFactory Instance = new EventFactory();
|
||||
|
||||
|
||||
@@ -3,15 +3,15 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
class EventAccessor : Accessor
|
||||
internal class EventAccessor : Accessor
|
||||
{
|
||||
EventAccessor(Context cx, IMethodSymbol init)
|
||||
private EventAccessor(Context cx, IMethodSymbol init)
|
||||
: base(cx, init) { }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the event symbol associated with this accessor.
|
||||
/// </summary>
|
||||
IEventSymbol EventSymbol => symbol.AssociatedSymbol as IEventSymbol;
|
||||
private IEventSymbol EventSymbol => symbol.AssociatedSymbol as IEventSymbol;
|
||||
|
||||
public override void Populate(TextWriter trapFile)
|
||||
{
|
||||
@@ -55,7 +55,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
public new static EventAccessor Create(Context cx, IMethodSymbol symbol) =>
|
||||
EventAccessorFactory.Instance.CreateEntityFromSymbol(cx, symbol);
|
||||
|
||||
class EventAccessorFactory : ICachedEntityFactory<IMethodSymbol, EventAccessor>
|
||||
private class EventAccessorFactory : ICachedEntityFactory<IMethodSymbol, EventAccessor>
|
||||
{
|
||||
public static readonly EventAccessorFactory Instance = new EventAccessorFactory();
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
bool IsTopLevelParent { get; }
|
||||
}
|
||||
|
||||
class Expression : FreshEntity, IExpressionParentEntity
|
||||
internal class Expression : FreshEntity, IExpressionParentEntity
|
||||
{
|
||||
private readonly IExpressionInfo Info;
|
||||
public readonly AnnotatedType Type;
|
||||
@@ -122,7 +122,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
cx.PopulateLater(() => Create(cx, node, parent, child));
|
||||
}
|
||||
|
||||
static bool ContainsPattern(SyntaxNode node) =>
|
||||
private static bool ContainsPattern(SyntaxNode node) =>
|
||||
node is PatternSyntax || node is VariableDesignationSyntax || node.ChildNodes().Any(ContainsPattern);
|
||||
|
||||
/// <summary>
|
||||
@@ -273,7 +273,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
public override TrapStackBehaviour TrapStackBehaviour => TrapStackBehaviour.OptionalLabel;
|
||||
}
|
||||
|
||||
static class CallTypeExtensions
|
||||
internal static class CallTypeExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Adjust the expression kind <paramref name="k"/> to match this call type.
|
||||
@@ -291,7 +291,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
}
|
||||
}
|
||||
|
||||
abstract class Expression<SyntaxNode> : Expression
|
||||
internal abstract class Expression<SyntaxNode> : Expression
|
||||
where SyntaxNode : ExpressionSyntax
|
||||
{
|
||||
public readonly SyntaxNode Syntax;
|
||||
@@ -322,7 +322,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
/// <summary>
|
||||
/// Holds all information required to create an Expression entity.
|
||||
/// </summary>
|
||||
interface IExpressionInfo
|
||||
internal interface IExpressionInfo
|
||||
{
|
||||
Context Context { get; }
|
||||
|
||||
@@ -370,7 +370,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
/// <summary>
|
||||
/// Explicitly constructed expression information.
|
||||
/// </summary>
|
||||
class ExpressionInfo : IExpressionInfo
|
||||
internal class ExpressionInfo : IExpressionInfo
|
||||
{
|
||||
public Context Context { get; }
|
||||
public AnnotatedType Type { get; }
|
||||
@@ -401,7 +401,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
/// <summary>
|
||||
/// Expression information constructed from a syntax node.
|
||||
/// </summary>
|
||||
class ExpressionNodeInfo : IExpressionInfo
|
||||
internal class ExpressionNodeInfo : IExpressionInfo
|
||||
{
|
||||
public ExpressionNodeInfo(Context cx, ExpressionSyntax node, IExpressionParentEntity parent, int child) :
|
||||
this(cx, node, parent, child, cx.GetTypeInfo(node))
|
||||
@@ -457,7 +457,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
}
|
||||
}
|
||||
|
||||
Microsoft.CodeAnalysis.Location location;
|
||||
private Microsoft.CodeAnalysis.Location location;
|
||||
|
||||
public Microsoft.CodeAnalysis.Location CodeAnalysisLocation
|
||||
{
|
||||
@@ -484,7 +484,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
}
|
||||
}
|
||||
|
||||
AnnotatedType cachedType;
|
||||
private AnnotatedType cachedType;
|
||||
|
||||
public AnnotatedType Type
|
||||
{
|
||||
@@ -500,7 +500,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
}
|
||||
}
|
||||
|
||||
Extraction.Entities.Location cachedLocation;
|
||||
private Extraction.Entities.Location cachedLocation;
|
||||
|
||||
public Extraction.Entities.Location Location
|
||||
{
|
||||
@@ -546,7 +546,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
return this;
|
||||
}
|
||||
|
||||
SymbolInfo cachedSymbolInfo;
|
||||
private SymbolInfo cachedSymbolInfo;
|
||||
|
||||
public SymbolInfo SymbolInfo
|
||||
{
|
||||
|
||||
@@ -3,9 +3,9 @@ using Semmle.Extraction.Kinds;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
class Access : Expression
|
||||
internal class Access : Expression
|
||||
{
|
||||
static ExprKind AccessKind(Context cx, ISymbol symbol)
|
||||
private static ExprKind AccessKind(Context cx, ISymbol symbol)
|
||||
{
|
||||
switch (symbol.Kind)
|
||||
{
|
||||
@@ -42,7 +42,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
}
|
||||
}
|
||||
|
||||
Access(ExpressionNodeInfo info, ISymbol symbol, bool implicitThis, IEntity target)
|
||||
private Access(ExpressionNodeInfo info, ISymbol symbol, bool implicitThis, IEntity target)
|
||||
: base(info.SetKind(AccessKind(info.Context, symbol)))
|
||||
{
|
||||
if (!(target is null))
|
||||
|
||||
@@ -5,9 +5,9 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
class ArgList : Expression<ExpressionSyntax>
|
||||
internal class ArgList : Expression<ExpressionSyntax>
|
||||
{
|
||||
ArgList(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.UNKNOWN)) { }
|
||||
private ArgList(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.UNKNOWN)) { }
|
||||
|
||||
protected override void PopulateExpression(TextWriter trapFile)
|
||||
{
|
||||
|
||||
@@ -7,12 +7,12 @@ using System.Linq;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
abstract class ArrayCreation<SyntaxNode> : Expression<SyntaxNode> where SyntaxNode : ExpressionSyntax
|
||||
internal abstract class ArrayCreation<SyntaxNode> : Expression<SyntaxNode> where SyntaxNode : ExpressionSyntax
|
||||
{
|
||||
protected ArrayCreation(ExpressionNodeInfo info) : base(info) { }
|
||||
}
|
||||
|
||||
abstract class ExplicitArrayCreation<SyntaxNode> : ArrayCreation<SyntaxNode> where SyntaxNode : ExpressionSyntax
|
||||
internal abstract class ExplicitArrayCreation<SyntaxNode> : ArrayCreation<SyntaxNode> where SyntaxNode : ExpressionSyntax
|
||||
{
|
||||
protected ExplicitArrayCreation(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.ARRAY_CREATION)) { }
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
}
|
||||
}
|
||||
|
||||
class NormalArrayCreation : ExplicitArrayCreation<ArrayCreationExpressionSyntax>
|
||||
internal class NormalArrayCreation : ExplicitArrayCreation<ArrayCreationExpressionSyntax>
|
||||
{
|
||||
private NormalArrayCreation(ExpressionNodeInfo info) : base(info) { }
|
||||
|
||||
@@ -91,9 +91,9 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
public static Expression Create(ExpressionNodeInfo info) => new NormalArrayCreation(info).TryPopulate();
|
||||
}
|
||||
|
||||
class StackAllocArrayCreation : ExplicitArrayCreation<StackAllocArrayCreationExpressionSyntax>
|
||||
internal class StackAllocArrayCreation : ExplicitArrayCreation<StackAllocArrayCreationExpressionSyntax>
|
||||
{
|
||||
StackAllocArrayCreation(ExpressionNodeInfo info) : base(info) { }
|
||||
private StackAllocArrayCreation(ExpressionNodeInfo info) : base(info) { }
|
||||
|
||||
protected override ArrayTypeSyntax TypeSyntax => Syntax.Type as ArrayTypeSyntax;
|
||||
|
||||
@@ -108,9 +108,9 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
public static Expression Create(ExpressionNodeInfo info) => new StackAllocArrayCreation(info).TryPopulate();
|
||||
}
|
||||
|
||||
class ImplicitStackAllocArrayCreation : ArrayCreation<ImplicitStackAllocArrayCreationExpressionSyntax>
|
||||
internal class ImplicitStackAllocArrayCreation : ArrayCreation<ImplicitStackAllocArrayCreationExpressionSyntax>
|
||||
{
|
||||
ImplicitStackAllocArrayCreation(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.ARRAY_CREATION)) { }
|
||||
private ImplicitStackAllocArrayCreation(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.ARRAY_CREATION)) { }
|
||||
|
||||
public static Expression Create(ExpressionNodeInfo info) => new ImplicitStackAllocArrayCreation(info).TryPopulate();
|
||||
|
||||
@@ -122,9 +122,9 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
}
|
||||
}
|
||||
|
||||
class ImplicitArrayCreation : ArrayCreation<ImplicitArrayCreationExpressionSyntax>
|
||||
internal class ImplicitArrayCreation : ArrayCreation<ImplicitArrayCreationExpressionSyntax>
|
||||
{
|
||||
ImplicitArrayCreation(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.ARRAY_CREATION)) { }
|
||||
private ImplicitArrayCreation(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.ARRAY_CREATION)) { }
|
||||
|
||||
public static Expression Create(ExpressionNodeInfo info) => new ImplicitArrayCreation(info).TryPopulate();
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
class Assignment : Expression<AssignmentExpressionSyntax>
|
||||
internal class Assignment : Expression<AssignmentExpressionSyntax>
|
||||
{
|
||||
Assignment(ExpressionNodeInfo info)
|
||||
private Assignment(ExpressionNodeInfo info)
|
||||
: base(info.SetKind(GetKind(info.Context, (AssignmentExpressionSyntax)info.Node)))
|
||||
{
|
||||
}
|
||||
@@ -45,7 +45,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
}
|
||||
}
|
||||
|
||||
static ExprKind GetAssignmentOperation(Context cx, AssignmentExpressionSyntax syntax)
|
||||
private static ExprKind GetAssignmentOperation(Context cx, AssignmentExpressionSyntax syntax)
|
||||
{
|
||||
switch (syntax.OperatorToken.Kind())
|
||||
{
|
||||
@@ -79,7 +79,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
}
|
||||
}
|
||||
|
||||
static ExprKind GetKind(Context cx, AssignmentExpressionSyntax syntax)
|
||||
private static ExprKind GetKind(Context cx, AssignmentExpressionSyntax syntax)
|
||||
{
|
||||
var leftSymbol = cx.GetSymbolInfo(syntax.Left);
|
||||
bool assignEvent = leftSymbol.Symbol != null && leftSymbol.Symbol is IEventSymbol;
|
||||
@@ -111,7 +111,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
/// assignment is not an assignment operator). For example, the operator
|
||||
/// kind of `*=` is `*`.
|
||||
/// </summary>
|
||||
ExprKind? OperatorKind
|
||||
private ExprKind? OperatorKind
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
@@ -4,9 +4,9 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
class Await : Expression<AwaitExpressionSyntax>
|
||||
internal class Await : Expression<AwaitExpressionSyntax>
|
||||
{
|
||||
Await(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.AWAIT)) { }
|
||||
private Await(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.AWAIT)) { }
|
||||
|
||||
public static Expression Create(ExpressionNodeInfo info) => new Await(info).TryPopulate();
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@ using Semmle.Extraction.Kinds;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
class Base : Expression
|
||||
internal class Base : Expression
|
||||
{
|
||||
Base(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.BASE_ACCESS)) { }
|
||||
private Base(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.BASE_ACCESS)) { }
|
||||
|
||||
public static Base Create(ExpressionNodeInfo info) => new Base(info);
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
class Binary : Expression<BinaryExpressionSyntax>
|
||||
internal class Binary : Expression<BinaryExpressionSyntax>
|
||||
{
|
||||
Binary(ExpressionNodeInfo info)
|
||||
private Binary(ExpressionNodeInfo info)
|
||||
: base(info.SetKind(GetKind(info.Context, (BinaryExpressionSyntax)info.Node)))
|
||||
{
|
||||
}
|
||||
@@ -21,13 +21,13 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
CreateDeferred(cx, Syntax.Right, this, 1);
|
||||
}
|
||||
|
||||
static ExprKind GetKind(Context cx, BinaryExpressionSyntax node)
|
||||
private static ExprKind GetKind(Context cx, BinaryExpressionSyntax node)
|
||||
{
|
||||
var k = GetBinaryTokenKind(cx, node.OperatorToken.Kind());
|
||||
return GetCallType(cx, node).AdjustKind(k);
|
||||
}
|
||||
|
||||
static ExprKind GetBinaryTokenKind(Context cx, SyntaxKind kind)
|
||||
private static ExprKind GetBinaryTokenKind(Context cx, SyntaxKind kind)
|
||||
{
|
||||
switch (kind)
|
||||
{
|
||||
|
||||
@@ -4,9 +4,9 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
class Cast : Expression<CastExpressionSyntax>
|
||||
internal class Cast : Expression<CastExpressionSyntax>
|
||||
{
|
||||
Cast(ExpressionNodeInfo info) : base(info.SetKind(UnaryOperatorKind(info.Context, ExprKind.CAST, info.Node))) { }
|
||||
private Cast(ExpressionNodeInfo info) : base(info.SetKind(UnaryOperatorKind(info.Context, ExprKind.CAST, info.Node))) { }
|
||||
|
||||
public static Expression Create(ExpressionNodeInfo info) => new Cast(info).TryPopulate();
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
class Checked : Expression<CheckedExpressionSyntax>
|
||||
internal class Checked : Expression<CheckedExpressionSyntax>
|
||||
{
|
||||
Checked(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.CHECKED)) { }
|
||||
private Checked(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.CHECKED)) { }
|
||||
|
||||
public static Expression Create(ExpressionNodeInfo info) => new Checked(info).TryPopulate();
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
class Conditional : Expression<ConditionalExpressionSyntax>
|
||||
internal class Conditional : Expression<ConditionalExpressionSyntax>
|
||||
{
|
||||
Conditional(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.CONDITIONAL)) { }
|
||||
private Conditional(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.CONDITIONAL)) { }
|
||||
|
||||
public static Expression Create(ExpressionNodeInfo info) => new Conditional(info).TryPopulate();
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
class Default : Expression<DefaultExpressionSyntax>
|
||||
internal class Default : Expression<DefaultExpressionSyntax>
|
||||
{
|
||||
Default(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.DEFAULT)) { }
|
||||
private Default(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.DEFAULT)) { }
|
||||
|
||||
public static Expression Create(ExpressionNodeInfo info) => new Default(info).TryPopulate();
|
||||
|
||||
|
||||
@@ -5,13 +5,13 @@ using Semmle.Extraction.Kinds;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
class Discard : Expression
|
||||
internal class Discard : Expression
|
||||
{
|
||||
public Discard(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.DISCARD))
|
||||
{
|
||||
}
|
||||
|
||||
Discard(Context cx, CSharpSyntaxNode syntax, IExpressionParentEntity parent, int child) :
|
||||
private Discard(Context cx, CSharpSyntaxNode syntax, IExpressionParentEntity parent, int child) :
|
||||
base(new ExpressionInfo(cx, Entities.Type.Create(cx, cx.GetType(syntax)), cx.Create(syntax.GetLocation()), ExprKind.DISCARD, parent, child, false, null))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
abstract class ElementAccess : Expression<ExpressionSyntax>
|
||||
internal abstract class ElementAccess : Expression<ExpressionSyntax>
|
||||
{
|
||||
protected ElementAccess(ExpressionNodeInfo info, ExpressionSyntax qualifier, BracketedArgumentListSyntax argumentList)
|
||||
: base(info.SetKind(GetKind(info.Context, qualifier)))
|
||||
@@ -15,8 +15,8 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
ArgumentList = argumentList;
|
||||
}
|
||||
|
||||
readonly ExpressionSyntax Qualifier;
|
||||
readonly BracketedArgumentListSyntax ArgumentList;
|
||||
private readonly ExpressionSyntax Qualifier;
|
||||
private readonly BracketedArgumentListSyntax ArgumentList;
|
||||
|
||||
protected override void PopulateExpression(TextWriter trapFile)
|
||||
{
|
||||
@@ -48,7 +48,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
|
||||
public sealed override Microsoft.CodeAnalysis.Location ReportingLocation => base.ReportingLocation;
|
||||
|
||||
static ExprKind GetKind(Context cx, ExpressionSyntax qualifier)
|
||||
private static ExprKind GetKind(Context cx, ExpressionSyntax qualifier)
|
||||
{
|
||||
var qualifierType = cx.GetType(qualifier);
|
||||
|
||||
@@ -69,17 +69,17 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
}
|
||||
}
|
||||
|
||||
class NormalElementAccess : ElementAccess
|
||||
internal class NormalElementAccess : ElementAccess
|
||||
{
|
||||
NormalElementAccess(ExpressionNodeInfo info)
|
||||
private NormalElementAccess(ExpressionNodeInfo info)
|
||||
: base(info, ((ElementAccessExpressionSyntax)info.Node).Expression, ((ElementAccessExpressionSyntax)info.Node).ArgumentList) { }
|
||||
|
||||
public static Expression Create(ExpressionNodeInfo info) => new NormalElementAccess(info).TryPopulate();
|
||||
}
|
||||
|
||||
class BindingElementAccess : ElementAccess
|
||||
internal class BindingElementAccess : ElementAccess
|
||||
{
|
||||
BindingElementAccess(ExpressionNodeInfo info)
|
||||
private BindingElementAccess(ExpressionNodeInfo info)
|
||||
: base(info, FindConditionalQualifier(info.Node), ((ElementBindingExpressionSyntax)info.Node).ArgumentList) { }
|
||||
|
||||
public static Expression Create(ExpressionNodeInfo info) => new BindingElementAccess(info).TryPopulate();
|
||||
|
||||
@@ -3,7 +3,7 @@ using Semmle.Extraction.Kinds;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
class ImplicitCast : Expression
|
||||
internal class ImplicitCast : Expression
|
||||
{
|
||||
public Expression Expr
|
||||
{
|
||||
|
||||
@@ -7,14 +7,14 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
abstract class Initializer : Expression<InitializerExpressionSyntax>
|
||||
internal abstract class Initializer : Expression<InitializerExpressionSyntax>
|
||||
{
|
||||
protected Initializer(ExpressionNodeInfo info) : base(info) { }
|
||||
}
|
||||
|
||||
class ArrayInitializer : Expression<InitializerExpressionSyntax>
|
||||
internal class ArrayInitializer : Expression<InitializerExpressionSyntax>
|
||||
{
|
||||
ArrayInitializer(ExpressionNodeInfo info) : base(info.SetType(NullType.Create(info.Context)).SetKind(ExprKind.ARRAY_INIT)) { }
|
||||
private ArrayInitializer(ExpressionNodeInfo info) : base(info.SetType(NullType.Create(info.Context)).SetKind(ExprKind.ARRAY_INIT)) { }
|
||||
|
||||
public static Expression Create(ExpressionNodeInfo info) => new ArrayInitializer(info).TryPopulate();
|
||||
|
||||
@@ -38,9 +38,9 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
}
|
||||
|
||||
// Array initializer { ..., ... }.
|
||||
class ImplicitArrayInitializer : Initializer
|
||||
internal class ImplicitArrayInitializer : Initializer
|
||||
{
|
||||
ImplicitArrayInitializer(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.ARRAY_CREATION)) { }
|
||||
private ImplicitArrayInitializer(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.ARRAY_CREATION)) { }
|
||||
|
||||
public static Expression Create(ExpressionNodeInfo info) => new ImplicitArrayInitializer(info).TryPopulate();
|
||||
|
||||
@@ -51,9 +51,9 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
}
|
||||
}
|
||||
|
||||
class ObjectInitializer : Initializer
|
||||
internal class ObjectInitializer : Initializer
|
||||
{
|
||||
ObjectInitializer(ExpressionNodeInfo info)
|
||||
private ObjectInitializer(ExpressionNodeInfo info)
|
||||
: base(info.SetKind(ExprKind.OBJECT_INIT)) { }
|
||||
|
||||
public static Expression Create(ExpressionNodeInfo info) => new ObjectInitializer(info).TryPopulate();
|
||||
@@ -107,9 +107,9 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
}
|
||||
}
|
||||
|
||||
class CollectionInitializer : Initializer
|
||||
internal class CollectionInitializer : Initializer
|
||||
{
|
||||
CollectionInitializer(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.COLLECTION_INIT)) { }
|
||||
private CollectionInitializer(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.COLLECTION_INIT)) { }
|
||||
|
||||
public static Expression Create(ExpressionNodeInfo info) => new CollectionInitializer(info).TryPopulate();
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
class InterpolatedString : Expression<InterpolatedStringExpressionSyntax>
|
||||
internal class InterpolatedString : Expression<InterpolatedStringExpressionSyntax>
|
||||
{
|
||||
InterpolatedString(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.INTERPOLATED_STRING)) { }
|
||||
private InterpolatedString(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.INTERPOLATED_STRING)) { }
|
||||
|
||||
public static Expression Create(ExpressionNodeInfo info) => new InterpolatedString(info).TryPopulate();
|
||||
|
||||
|
||||
@@ -7,15 +7,15 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
class Invocation : Expression<InvocationExpressionSyntax>
|
||||
internal class Invocation : Expression<InvocationExpressionSyntax>
|
||||
{
|
||||
Invocation(ExpressionNodeInfo info)
|
||||
private Invocation(ExpressionNodeInfo info)
|
||||
: base(info.SetKind(GetKind(info)))
|
||||
{
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
readonly ExpressionNodeInfo info;
|
||||
private readonly ExpressionNodeInfo info;
|
||||
|
||||
public static Expression Create(ExpressionNodeInfo info) => new Invocation(info).TryPopulate();
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
trapFile.expr_call(this, targetKey);
|
||||
}
|
||||
|
||||
static bool IsDynamicCall(ExpressionNodeInfo info)
|
||||
private static bool IsDynamicCall(ExpressionNodeInfo info)
|
||||
{
|
||||
// Either the qualifier (Expression) is dynamic,
|
||||
// or one of the arguments is dynamic.
|
||||
@@ -132,7 +132,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
}
|
||||
}
|
||||
|
||||
static bool IsDelegateCall(ExpressionNodeInfo info)
|
||||
private static bool IsDelegateCall(ExpressionNodeInfo info)
|
||||
{
|
||||
var si = info.SymbolInfo;
|
||||
|
||||
@@ -153,13 +153,13 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
((IMethodSymbol)si.Symbol).MethodKind == MethodKind.DelegateInvoke;
|
||||
}
|
||||
|
||||
static bool IsLocalFunctionInvocation(ExpressionNodeInfo info)
|
||||
private static bool IsLocalFunctionInvocation(ExpressionNodeInfo info)
|
||||
{
|
||||
return info.SymbolInfo.Symbol is IMethodSymbol target &&
|
||||
target.MethodKind == MethodKind.LocalFunction;
|
||||
}
|
||||
|
||||
static ExprKind GetKind(ExpressionNodeInfo info)
|
||||
private static ExprKind GetKind(ExpressionNodeInfo info)
|
||||
{
|
||||
return IsNameof((InvocationExpressionSyntax)info.Node)
|
||||
? ExprKind.NAMEOF
|
||||
@@ -170,7 +170,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
: ExprKind.METHOD_INVOCATION;
|
||||
}
|
||||
|
||||
static bool IsNameof(InvocationExpressionSyntax syntax)
|
||||
private static bool IsNameof(InvocationExpressionSyntax syntax)
|
||||
{
|
||||
// Odd that this is not a separate expression type.
|
||||
// Maybe it will be in the future.
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
static class PatternExtensions
|
||||
internal static class PatternExtensions
|
||||
{
|
||||
public static Expression CreatePattern(this Context cx, PatternSyntax syntax, IExpressionParentEntity parent, int child)
|
||||
{
|
||||
@@ -65,7 +65,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
}
|
||||
}
|
||||
|
||||
class PropertyPattern : Expression
|
||||
internal class PropertyPattern : Expression
|
||||
{
|
||||
internal PropertyPattern(Context cx, PropertyPatternClauseSyntax pp, IExpressionParentEntity parent, int child) :
|
||||
base(new ExpressionInfo(cx, Entities.NullType.Create(cx), cx.Create(pp.GetLocation()), ExprKind.PROPERTY_PATTERN, parent, child, false, null))
|
||||
@@ -80,7 +80,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
}
|
||||
}
|
||||
|
||||
class PositionalPattern : Expression
|
||||
internal class PositionalPattern : Expression
|
||||
{
|
||||
internal PositionalPattern(Context cx, PositionalPatternClauseSyntax posPc, IExpressionParentEntity parent, int child) :
|
||||
base(new ExpressionInfo(cx, Entities.NullType.Create(cx), cx.Create(posPc.GetLocation()), ExprKind.POSITIONAL_PATTERN, parent, child, false, null))
|
||||
@@ -93,7 +93,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
}
|
||||
}
|
||||
|
||||
class RecursivePattern : Expression
|
||||
internal class RecursivePattern : Expression
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates and populates a recursive pattern.
|
||||
@@ -130,7 +130,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
}
|
||||
}
|
||||
|
||||
class IsPattern : Expression<IsPatternExpressionSyntax>
|
||||
internal class IsPattern : Expression<IsPatternExpressionSyntax>
|
||||
{
|
||||
private IsPattern(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.IS))
|
||||
{
|
||||
|
||||
@@ -9,19 +9,19 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
class Lambda : Expression<AnonymousFunctionExpressionSyntax>, IStatementParentEntity
|
||||
internal class Lambda : Expression<AnonymousFunctionExpressionSyntax>, IStatementParentEntity
|
||||
{
|
||||
bool IStatementParentEntity.IsTopLevelParent => false;
|
||||
|
||||
protected override void PopulateExpression(TextWriter trapFile) { }
|
||||
|
||||
void VisitParameter(ParameterSyntax p)
|
||||
private void VisitParameter(ParameterSyntax p)
|
||||
{
|
||||
var symbol = cx.GetModel(p).GetDeclaredSymbol(p);
|
||||
Parameter.Create(cx, symbol, this);
|
||||
}
|
||||
|
||||
Lambda(ExpressionNodeInfo info, CSharpSyntaxNode body, IEnumerable<ParameterSyntax> @params)
|
||||
private Lambda(ExpressionNodeInfo info, CSharpSyntaxNode body, IEnumerable<ParameterSyntax> @params)
|
||||
: base(info)
|
||||
{
|
||||
// No need to use `Populate` as the population happens later
|
||||
@@ -39,17 +39,17 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
});
|
||||
}
|
||||
|
||||
Lambda(ExpressionNodeInfo info, ParenthesizedLambdaExpressionSyntax node)
|
||||
private Lambda(ExpressionNodeInfo info, ParenthesizedLambdaExpressionSyntax node)
|
||||
: this(info.SetKind(ExprKind.LAMBDA), node.Body, node.ParameterList.Parameters) { }
|
||||
|
||||
public static Lambda Create(ExpressionNodeInfo info, ParenthesizedLambdaExpressionSyntax node) => new Lambda(info, node);
|
||||
|
||||
Lambda(ExpressionNodeInfo info, SimpleLambdaExpressionSyntax node)
|
||||
private Lambda(ExpressionNodeInfo info, SimpleLambdaExpressionSyntax node)
|
||||
: this(info.SetKind(ExprKind.LAMBDA), node.Body, Enumerators.Singleton(node.Parameter)) { }
|
||||
|
||||
public static Lambda Create(ExpressionNodeInfo info, SimpleLambdaExpressionSyntax node) => new Lambda(info, node);
|
||||
|
||||
Lambda(ExpressionNodeInfo info, AnonymousMethodExpressionSyntax node) :
|
||||
private Lambda(ExpressionNodeInfo info, AnonymousMethodExpressionSyntax node) :
|
||||
this(info.SetKind(ExprKind.ANONYMOUS_METHOD), node.Body, node.ParameterList == null ? Enumerable.Empty<ParameterSyntax>() : node.ParameterList.Parameters)
|
||||
{ }
|
||||
|
||||
|
||||
@@ -6,15 +6,15 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
class Literal : Expression<LiteralExpressionSyntax>
|
||||
internal class Literal : Expression<LiteralExpressionSyntax>
|
||||
{
|
||||
Literal(ExpressionNodeInfo info) : base(info.SetKind(GetKind(info))) { }
|
||||
private Literal(ExpressionNodeInfo info) : base(info.SetKind(GetKind(info))) { }
|
||||
|
||||
public static Expression Create(ExpressionNodeInfo info) => new Literal(info).TryPopulate();
|
||||
|
||||
protected override void PopulateExpression(TextWriter trapFile) { }
|
||||
|
||||
static ExprKind GetKind(ExpressionNodeInfo info)
|
||||
private static ExprKind GetKind(ExpressionNodeInfo info)
|
||||
{
|
||||
switch (info.Node.Kind())
|
||||
{
|
||||
|
||||
@@ -4,9 +4,9 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
class MakeRef : Expression<MakeRefExpressionSyntax>
|
||||
internal class MakeRef : Expression<MakeRefExpressionSyntax>
|
||||
{
|
||||
MakeRef(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.REF)) { }
|
||||
private MakeRef(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.REF)) { }
|
||||
|
||||
public static Expression Create(ExpressionNodeInfo info) => new MakeRef(info).TryPopulate();
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@ using Semmle.Extraction.Kinds;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
class MemberAccess : Expression
|
||||
internal class MemberAccess : Expression
|
||||
{
|
||||
readonly IEntity Target;
|
||||
private readonly IEntity Target;
|
||||
|
||||
private MemberAccess(ExpressionNodeInfo info, ExpressionSyntax qualifier, ISymbol target) : base(info)
|
||||
{
|
||||
@@ -42,7 +42,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
public static Expression Create(ExpressionNodeInfo info, MemberAccessExpressionSyntax node) =>
|
||||
Create(info, node.Expression, node.Name);
|
||||
|
||||
static Expression Create(ExpressionNodeInfo info, ExpressionSyntax expression, SimpleNameSyntax name)
|
||||
private static Expression Create(ExpressionNodeInfo info, ExpressionSyntax expression, SimpleNameSyntax name)
|
||||
{
|
||||
if (IsDynamic(info.Context, expression))
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
static class Name
|
||||
internal static class Name
|
||||
{
|
||||
public static Expression Create(ExpressionNodeInfo info)
|
||||
{
|
||||
|
||||
@@ -8,27 +8,27 @@ using System.Linq;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
abstract class ObjectCreation<SyntaxNode> : Expression<SyntaxNode> where SyntaxNode : ExpressionSyntax
|
||||
internal abstract class ObjectCreation<SyntaxNode> : Expression<SyntaxNode> where SyntaxNode : ExpressionSyntax
|
||||
{
|
||||
protected ObjectCreation(ExpressionNodeInfo info)
|
||||
: base(info) { }
|
||||
}
|
||||
|
||||
// new Foo(...) { ... }.
|
||||
class ExplicitObjectCreation : ObjectCreation<ObjectCreationExpressionSyntax>
|
||||
internal class ExplicitObjectCreation : ObjectCreation<ObjectCreationExpressionSyntax>
|
||||
{
|
||||
static bool IsDynamicObjectCreation(Context cx, ObjectCreationExpressionSyntax node)
|
||||
private static bool IsDynamicObjectCreation(Context cx, ObjectCreationExpressionSyntax node)
|
||||
{
|
||||
return node.ArgumentList != null && node.ArgumentList.Arguments.Any(arg => IsDynamic(cx, arg.Expression));
|
||||
}
|
||||
|
||||
static ExprKind GetKind(Context cx, ObjectCreationExpressionSyntax node)
|
||||
private static ExprKind GetKind(Context cx, ObjectCreationExpressionSyntax node)
|
||||
{
|
||||
var si = cx.GetModel(node).GetSymbolInfo(node.Type);
|
||||
return Entities.Type.IsDelegate(si.Symbol as INamedTypeSymbol) ? ExprKind.EXPLICIT_DELEGATE_CREATION : ExprKind.OBJECT_CREATION;
|
||||
}
|
||||
|
||||
ExplicitObjectCreation(ExpressionNodeInfo info)
|
||||
private ExplicitObjectCreation(ExpressionNodeInfo info)
|
||||
: base(info.SetKind(GetKind(info.Context, (ObjectCreationExpressionSyntax)info.Node))) { }
|
||||
|
||||
public static Expression Create(ExpressionNodeInfo info) => new ExplicitObjectCreation(info).TryPopulate();
|
||||
@@ -76,7 +76,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
TypeMention.Create(cx, Syntax.Type, this, Type);
|
||||
}
|
||||
|
||||
static SyntaxToken? GetDynamicName(CSharpSyntaxNode name)
|
||||
private static SyntaxToken? GetDynamicName(CSharpSyntaxNode name)
|
||||
{
|
||||
switch (name.Kind())
|
||||
{
|
||||
@@ -93,7 +93,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
}
|
||||
}
|
||||
|
||||
class ImplicitObjectCreation : ObjectCreation<AnonymousObjectCreationExpressionSyntax>
|
||||
internal class ImplicitObjectCreation : ObjectCreation<AnonymousObjectCreationExpressionSyntax>
|
||||
{
|
||||
public ImplicitObjectCreation(ExpressionNodeInfo info)
|
||||
: base(info.SetKind(ExprKind.OBJECT_CREATION)) { }
|
||||
|
||||
@@ -4,9 +4,9 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
class PointerMemberAccess : Expression<MemberAccessExpressionSyntax>
|
||||
internal class PointerMemberAccess : Expression<MemberAccessExpressionSyntax>
|
||||
{
|
||||
PointerMemberAccess(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.POINTER_INDIRECTION)) { }
|
||||
private PointerMemberAccess(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.POINTER_INDIRECTION)) { }
|
||||
|
||||
public static Expression Create(ExpressionNodeInfo info) => new PointerMemberAccess(info).TryPopulate();
|
||||
|
||||
|
||||
@@ -4,17 +4,17 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
class PostfixUnary : Expression<ExpressionSyntax>
|
||||
internal class PostfixUnary : Expression<ExpressionSyntax>
|
||||
{
|
||||
PostfixUnary(ExpressionNodeInfo info, ExprKind kind, ExpressionSyntax operand)
|
||||
private PostfixUnary(ExpressionNodeInfo info, ExprKind kind, ExpressionSyntax operand)
|
||||
: base(info.SetKind(UnaryOperatorKind(info.Context, kind, info.Node)))
|
||||
{
|
||||
Operand = operand;
|
||||
OperatorKind = kind;
|
||||
}
|
||||
|
||||
readonly ExpressionSyntax Operand;
|
||||
readonly ExprKind OperatorKind;
|
||||
private readonly ExpressionSyntax Operand;
|
||||
private readonly ExprKind OperatorKind;
|
||||
|
||||
public static Expression Create(ExpressionNodeInfo info, ExpressionSyntax operand) => new PostfixUnary(info, info.Kind, operand).TryPopulate();
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ using Semmle.Extraction.Entities;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
static class Query
|
||||
internal static class Query
|
||||
{
|
||||
/// <summary>
|
||||
/// An expression representing a call in a LINQ query.
|
||||
@@ -34,7 +34,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
/// <summary>
|
||||
/// Represents a chain of method calls (the operand being recursive).
|
||||
/// </summary>
|
||||
abstract class Clause
|
||||
private abstract class Clause
|
||||
{
|
||||
protected readonly IMethodSymbol method;
|
||||
protected readonly List<ExpressionSyntax> arguments = new List<ExpressionSyntax>();
|
||||
@@ -113,10 +113,10 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
public abstract Expression Populate(Context cx, IExpressionParentEntity parent, int child);
|
||||
}
|
||||
|
||||
class RangeClause : Clause
|
||||
private class RangeClause : Clause
|
||||
{
|
||||
readonly ISymbol declaration;
|
||||
readonly SyntaxToken name;
|
||||
private readonly ISymbol declaration;
|
||||
private readonly SyntaxToken name;
|
||||
|
||||
public RangeClause(IMethodSymbol method, SyntaxNode node, ISymbol declaration, SyntaxToken name) : base(method, node)
|
||||
{
|
||||
@@ -128,12 +128,12 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
DeclareRangeVariable(cx, parent, child, true, declaration, name);
|
||||
}
|
||||
|
||||
class LetClause : Clause
|
||||
private class LetClause : Clause
|
||||
{
|
||||
readonly Clause operand;
|
||||
readonly ISymbol declaration;
|
||||
readonly SyntaxToken name;
|
||||
ISymbol intoDeclaration;
|
||||
private readonly Clause operand;
|
||||
private readonly ISymbol declaration;
|
||||
private readonly SyntaxToken name;
|
||||
private ISymbol intoDeclaration;
|
||||
|
||||
public LetClause(Clause operand, IMethodSymbol method, SyntaxNode node, ISymbol declaration, SyntaxToken name) : base(method, node)
|
||||
{
|
||||
@@ -148,7 +148,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
return this;
|
||||
}
|
||||
|
||||
void DeclareIntoVariable(Context cx, IExpressionParentEntity parent, int intoChild, bool getElement)
|
||||
private void DeclareIntoVariable(Context cx, IExpressionParentEntity parent, int intoChild, bool getElement)
|
||||
{
|
||||
if (intoDeclaration != null)
|
||||
DeclareRangeVariable(cx, parent, intoChild, getElement, intoDeclaration, name);
|
||||
@@ -168,9 +168,9 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
}
|
||||
}
|
||||
|
||||
class CallClause : Clause
|
||||
private class CallClause : Clause
|
||||
{
|
||||
readonly Clause operand;
|
||||
private readonly Clause operand;
|
||||
|
||||
public CallClause(Clause operand, IMethodSymbol method, SyntaxNode node) : base(method, node)
|
||||
{
|
||||
@@ -193,7 +193,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
/// <param name="cx">The extraction context.</param>
|
||||
/// <param name="node">The query expression.</param>
|
||||
/// <returns>A "syntax tree" of the query.</returns>
|
||||
static Clause ConstructQueryExpression(Context cx, QueryExpressionSyntax node)
|
||||
private static Clause ConstructQueryExpression(Context cx, QueryExpressionSyntax node)
|
||||
{
|
||||
var info = cx.GetModel(node).GetQueryClauseInfo(node.FromClause);
|
||||
var method = info.OperationInfo.Symbol as IMethodSymbol;
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
class RangeExpression : Expression<RangeExpressionSyntax>
|
||||
internal class RangeExpression : Expression<RangeExpressionSyntax>
|
||||
{
|
||||
private RangeExpression(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.RANGE))
|
||||
{
|
||||
|
||||
@@ -4,9 +4,9 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
class Ref : Expression<RefExpressionSyntax>
|
||||
internal class Ref : Expression<RefExpressionSyntax>
|
||||
{
|
||||
Ref(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.REF)) { }
|
||||
private Ref(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.REF)) { }
|
||||
|
||||
public static Expression Create(ExpressionNodeInfo info) => new Ref(info).TryPopulate();
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
class RefType : Expression<RefTypeExpressionSyntax>
|
||||
internal class RefType : Expression<RefTypeExpressionSyntax>
|
||||
{
|
||||
RefType(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.UNKNOWN)) { }
|
||||
private RefType(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.UNKNOWN)) { }
|
||||
|
||||
public static Expression Create(ExpressionNodeInfo info) => new RefType(info).TryPopulate();
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
class RefValue : Expression<RefValueExpressionSyntax>
|
||||
internal class RefValue : Expression<RefValueExpressionSyntax>
|
||||
{
|
||||
RefValue(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.REF)) { }
|
||||
private RefValue(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.REF)) { }
|
||||
|
||||
public static Expression Create(ExpressionNodeInfo info) => new RefValue(info).TryPopulate();
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
class SizeOf : Expression<SizeOfExpressionSyntax>
|
||||
internal class SizeOf : Expression<SizeOfExpressionSyntax>
|
||||
{
|
||||
SizeOf(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.SIZEOF)) { }
|
||||
private SizeOf(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.SIZEOF)) { }
|
||||
|
||||
public static Expression Create(ExpressionNodeInfo info) => new SizeOf(info).TryPopulate();
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
class Switch : Expression<SwitchExpressionSyntax>
|
||||
internal class Switch : Expression<SwitchExpressionSyntax>
|
||||
{
|
||||
private Switch(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.SWITCH))
|
||||
{
|
||||
@@ -25,7 +25,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
}
|
||||
}
|
||||
|
||||
class SwitchCase : Expression
|
||||
internal class SwitchCase : Expression
|
||||
{
|
||||
internal SwitchCase(Context cx, SwitchExpressionArmSyntax arm, Switch parent, int child) :
|
||||
base(new ExpressionInfo(
|
||||
|
||||
@@ -3,9 +3,9 @@ using Semmle.Extraction.Kinds;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
class This : Expression
|
||||
internal class This : Expression
|
||||
{
|
||||
This(IExpressionInfo info) : base(info) { }
|
||||
private This(IExpressionInfo info) : base(info) { }
|
||||
|
||||
public static This CreateImplicit(Context cx, Type @class, Extraction.Entities.Location loc, IExpressionParentEntity parent, int child) =>
|
||||
new This(new ExpressionInfo(cx, new AnnotatedType(@class, NullableAnnotation.None), loc, Kinds.ExprKind.THIS_ACCESS, parent, child, true, null));
|
||||
|
||||
@@ -4,9 +4,9 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
class Throw : Expression<ThrowExpressionSyntax>
|
||||
internal class Throw : Expression<ThrowExpressionSyntax>
|
||||
{
|
||||
Throw(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.THROW)) { }
|
||||
private Throw(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.THROW)) { }
|
||||
|
||||
public static Expression Create(ExpressionNodeInfo info) => new Throw(info).TryPopulate();
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@ using System.Linq;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
class Tuple : Expression<TupleExpressionSyntax>
|
||||
internal class Tuple : Expression<TupleExpressionSyntax>
|
||||
{
|
||||
public static Expression Create(ExpressionNodeInfo info) => new Tuple(info).TryPopulate();
|
||||
|
||||
Tuple(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.TUPLE))
|
||||
private Tuple(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.TUPLE))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user