C#: Mark members static (remove unused members)

This commit is contained in:
Tamas Vajk
2020-10-02 10:24:18 +02:00
parent 68a45e7e9d
commit 921d3eeaec
11 changed files with 13 additions and 20 deletions

View File

@@ -268,7 +268,7 @@ Invoke-Command -ScriptBlock $ScriptBlock";
static string DotNetCommand(IBuildActions actions, string? dotNetPath) =>
dotNetPath != null ? actions.PathCombine(dotNetPath, "dotnet") : "dotnet";
BuildScript GetInfoCommand(IBuildActions actions, string? dotNetPath, IDictionary<string, string>? environment)
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;
}
CommandBuilder GetCleanCommand(IBuildActions actions, string? dotNetPath, IDictionary<string, string>? environment)
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;
}
CommandBuilder GetRestoreCommand(IBuildActions actions, string? dotNetPath, IDictionary<string, string>? environment)
static CommandBuilder GetRestoreCommand(IBuildActions actions, string? dotNetPath, IDictionary<string, string>? environment)
{
var restore = new CommandBuilder(actions, null, environment).
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>
BuildScript GetBuildScript(Autobuilder builder, string? dotNetPath, IDictionary<string, string>? environment, bool compatibleClr, string projOrSln)
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)).

View File

@@ -150,7 +150,7 @@ namespace Semmle.Autobuild.Shared
bool IBuildActions.FileExists(string file) => File.Exists(file);
ProcessStartInfo GetProcessStartInfo(string exe, string arguments, string? workingDirectory, IDictionary<string, string>? environment, bool redirectStandardOutput)
static ProcessStartInfo GetProcessStartInfo(string exe, string arguments, string? workingDirectory, IDictionary<string, string>? environment, bool redirectStandardOutput)
{
var pi = new ProcessStartInfo(exe, arguments)
{

View File

@@ -33,8 +33,6 @@ namespace Semmle.Extraction.CIL.Entities
{
}
public bool NeedsPopulation { get { return true; } }
public Label Label { get; set; }
public void WriteId(TextWriter trapFile)
@@ -52,7 +50,7 @@ namespace Semmle.Extraction.CIL.Entities
trapFile.Write('\"');
}
public string IdSuffix => ";cil-field";
private const string IdSuffix = ";cil-field";
public abstract string Name { get; }

View File

@@ -155,7 +155,7 @@ namespace Semmle.Extraction.CSharp.Standalone
/// <summary>
/// Outputs the command line options to the console.
/// </summary>
public void ShowHelp(System.IO.TextWriter output)
public static void ShowHelp(System.IO.TextWriter output)
{
output.WriteLine("C# standalone extractor\n\nExtracts a C# project in the current directory without performing a build.\n");
output.WriteLine("Additional options:\n");

View File

@@ -59,7 +59,7 @@ namespace Semmle.Extraction.CSharp.Standalone
if (options.Help)
{
options.ShowHelp(System.Console.Out);
Options.ShowHelp(System.Console.Out);
return 0;
}

View File

@@ -59,11 +59,6 @@ namespace Semmle.Extraction.CSharp.Entities
public sealed override Microsoft.CodeAnalysis.Location ReportingLocation => Node.GetLocation();
public IEnumerable<Tuple> GetTuples()
{
yield break;
}
public override TrapStackBehaviour TrapStackBehaviour => TrapStackBehaviour.NoLabel;
}
}

View File

@@ -21,7 +21,7 @@ namespace Semmle.Extraction.CSharp.Populators
return Visit(method.Identifier, method.Body ?? (SyntaxNode)method.ExpressionBody);
}
public LineCounts Visit(SyntaxToken identifier, SyntaxNode body)
public static LineCounts Visit(SyntaxToken identifier, SyntaxNode body)
{
int start = identifier.GetLocation().SourceSpan.Start;
int end = body.GetLocation().SourceSpan.End - 1;

View File

@@ -73,7 +73,7 @@ namespace Semmle.Extraction.CommentProcessing
// Ensure that commentBlock and element refer to the same file
// which can happen when processing multiple files.
void EnsureSameFile(ICommentBlock commentBlock, ref KeyValuePair<Location, Label>? element)
static void EnsureSameFile(ICommentBlock commentBlock, ref KeyValuePair<Location, Label>? element)
{
if (element != null && element.Value.Key.SourceTree != commentBlock.Location.SourceTree)
element = null;

View File

@@ -172,7 +172,7 @@ namespace Semmle.Extraction
public readonly Layout.SubProject Directories;
string? ReadVariable(string name, string line)
static string? ReadVariable(string name, string line)
{
string prefix = name + "=";
if (!line.StartsWith(prefix))

View File

@@ -28,7 +28,7 @@ namespace SemmleTests.Semmle.Util
CleanUp();
}
void CleanUp()
static void CleanUp()
{
try
{

View File

@@ -163,7 +163,7 @@ namespace Semmle.Util
GetRealPath("."); // Test that it works
}
string GetRealPath(string path)
static string GetRealPath(string path)
{
path = UnixPath.GetFullPath(path);
return UnixPath.GetCompleteRealPath(path);