mirror of
https://github.com/github/codeql.git
synced 2026-05-02 20:25:13 +02:00
C#: Fix private field and local variable naming
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -228,19 +228,19 @@ namespace Semmle.Autobuild.Shared
|
||||
public static BuildScript Bind(BuildScript s1, Func<IList<string>, int, BuildScript> s2) =>
|
||||
new BindBuildScript(s1, s2);
|
||||
|
||||
private 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);
|
||||
public static readonly BuildScript Success = Create(actions => successCode);
|
||||
|
||||
private 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);
|
||||
public static readonly BuildScript Failure = Create(actions => failureCode);
|
||||
|
||||
private 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));
|
||||
@@ -267,7 +267,7 @@ namespace Semmle.Autobuild.Shared
|
||||
Create(actions =>
|
||||
{
|
||||
if (string.IsNullOrEmpty(dir) || !actions.DirectoryExists(dir))
|
||||
return FailureCode;
|
||||
return failureCode;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -275,9 +275,9 @@ namespace Semmle.Autobuild.Shared
|
||||
}
|
||||
catch // lgtm[cs/catch-of-all-exceptions]
|
||||
{
|
||||
return FailureCode;
|
||||
return failureCode;
|
||||
}
|
||||
return SuccessCode;
|
||||
return successCode;
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
@@ -287,7 +287,7 @@ namespace Semmle.Autobuild.Shared
|
||||
Create(actions =>
|
||||
{
|
||||
if (string.IsNullOrEmpty(file) || !actions.FileExists(file))
|
||||
return FailureCode;
|
||||
return failureCode;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -295,9 +295,9 @@ namespace Semmle.Autobuild.Shared
|
||||
}
|
||||
catch // lgtm[cs/catch-of-all-exceptions]
|
||||
{
|
||||
return FailureCode;
|
||||
return failureCode;
|
||||
}
|
||||
return SuccessCode;
|
||||
return successCode;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Semmle.Autobuild.Shared
|
||||
/// <summary>
|
||||
/// The name of the msbuild command.
|
||||
/// </summary>
|
||||
private const string MsBuild = "msbuild";
|
||||
private const string msBuild = "msbuild";
|
||||
|
||||
public BuildScript Analyse(Autobuilder builder, bool auto)
|
||||
{
|
||||
@@ -57,7 +57,7 @@ namespace Semmle.Autobuild.Shared
|
||||
Script;
|
||||
var nugetRestore = GetNugetRestoreScript();
|
||||
var msbuildRestoreCommand = new CommandBuilder(builder.Actions).
|
||||
RunCommand(MsBuild).
|
||||
RunCommand(msBuild).
|
||||
Argument("/t:restore").
|
||||
QuoteArgument(projectOrSolution.FullPath);
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace Semmle.Autobuild.Shared
|
||||
command.RunCommand("set Platform=&& type NUL", quoteExe: false);
|
||||
}
|
||||
|
||||
builder.MaybeIndex(command, MsBuild);
|
||||
builder.MaybeIndex(command, msBuild);
|
||||
command.QuoteArgument(projectOrSolution.FullPath);
|
||||
|
||||
command.Argument("/p:UseSharedCompilation=false");
|
||||
|
||||
@@ -46,11 +46,11 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
trapFile.Write("@\"");
|
||||
WriteId(trapFile);
|
||||
trapFile.Write(IdSuffix);
|
||||
trapFile.Write(idSuffix);
|
||||
trapFile.Write('\"');
|
||||
}
|
||||
|
||||
private const string IdSuffix = ";cil-field";
|
||||
private const string idSuffix = ";cil-field";
|
||||
|
||||
public abstract string Name { get; }
|
||||
|
||||
@@ -136,14 +136,14 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
|
||||
internal sealed class MemberReferenceField : Field
|
||||
{
|
||||
private readonly MemberReferenceHandle Handle;
|
||||
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)
|
||||
{
|
||||
Handle = handle;
|
||||
this.handle = handle;
|
||||
this.gc = gc;
|
||||
mr = cx.mdReader.GetMemberReference(handle);
|
||||
declType = (Type)cx.CreateGeneric(gc, mr.Parent);
|
||||
@@ -151,12 +151,12 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
return obj is MemberReferenceField field && Handle.Equals(field.Handle);
|
||||
return obj is MemberReferenceField field && handle.Equals(field.handle);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Handle.GetHashCode();
|
||||
return handle.GetHashCode();
|
||||
}
|
||||
|
||||
public override string Name => cx.GetString(mr.Name);
|
||||
|
||||
@@ -9,16 +9,16 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
|
||||
public sealed class Folder : LabelledEntity, IFolder
|
||||
{
|
||||
private readonly PathTransformer.ITransformedPath TransformedPath;
|
||||
private readonly PathTransformer.ITransformedPath transformedPath;
|
||||
|
||||
public Folder(Context cx, PathTransformer.ITransformedPath path) : base(cx)
|
||||
{
|
||||
this.TransformedPath = path;
|
||||
this.transformedPath = path;
|
||||
}
|
||||
|
||||
public override void WriteId(TextWriter trapFile)
|
||||
{
|
||||
trapFile.Write(TransformedPath.DatabaseId);
|
||||
trapFile.Write(transformedPath.DatabaseId);
|
||||
}
|
||||
|
||||
public override string IdSuffix => ";folder";
|
||||
@@ -27,21 +27,21 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
get
|
||||
{
|
||||
if (TransformedPath.ParentDirectory is PathTransformer.ITransformedPath parent)
|
||||
if (transformedPath.ParentDirectory is PathTransformer.ITransformedPath parent)
|
||||
{
|
||||
var parentFolder = cx.CreateFolder(parent);
|
||||
yield return parentFolder;
|
||||
yield return Tuples.containerparent(parentFolder, this);
|
||||
}
|
||||
yield return Tuples.folders(this, TransformedPath.Value, TransformedPath.NameWithoutExtension);
|
||||
yield return Tuples.folders(this, transformedPath.Value, transformedPath.NameWithoutExtension);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
return obj is Folder folder && TransformedPath == folder.TransformedPath;
|
||||
return obj is Folder folder && transformedPath == folder.transformedPath;
|
||||
}
|
||||
|
||||
public override int GetHashCode() => TransformedPath.GetHashCode();
|
||||
public override int GetHashCode() => transformedPath.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,8 +272,8 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
public readonly ILOpCode OpCode;
|
||||
public readonly int Offset;
|
||||
public readonly int Index;
|
||||
private readonly int PayloadValue;
|
||||
private readonly uint UnsignedPayloadValue;
|
||||
private readonly int payloadValue;
|
||||
private readonly uint unsignedPayloadValue;
|
||||
|
||||
public Payload PayloadType
|
||||
{
|
||||
@@ -296,7 +296,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
get
|
||||
{
|
||||
if (OpCode == ILOpCode.Switch)
|
||||
return 5 + 4 * PayloadValue;
|
||||
return 5 + 4 * payloadValue;
|
||||
|
||||
return ((int)OpCode > 255 ? 2 : 1) + PayloadSize;
|
||||
}
|
||||
@@ -337,19 +337,19 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
switch (PayloadSize)
|
||||
{
|
||||
case 0:
|
||||
PayloadValue = 0;
|
||||
payloadValue = 0;
|
||||
break;
|
||||
case 1:
|
||||
PayloadValue = (sbyte)data[offset];
|
||||
UnsignedPayloadValue = data[offset];
|
||||
payloadValue = (sbyte)data[offset];
|
||||
unsignedPayloadValue = data[offset];
|
||||
break;
|
||||
case 2:
|
||||
PayloadValue = BitConverter.ToInt16(data, offset);
|
||||
UnsignedPayloadValue = BitConverter.ToUInt16(data, offset);
|
||||
payloadValue = BitConverter.ToInt16(data, offset);
|
||||
unsignedPayloadValue = BitConverter.ToUInt16(data, offset);
|
||||
break;
|
||||
case -1: // Switch
|
||||
case 4:
|
||||
PayloadValue = BitConverter.ToInt32(data, offset);
|
||||
payloadValue = BitConverter.ToInt32(data, offset);
|
||||
break;
|
||||
case 8: // Not handled here.
|
||||
break;
|
||||
@@ -374,7 +374,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
switch (PayloadType)
|
||||
{
|
||||
case Payload.String:
|
||||
yield return Tuples.cil_value(this, cx.mdReader.GetUserString(MetadataTokens.UserStringHandle(PayloadValue)));
|
||||
yield return Tuples.cil_value(this, cx.mdReader.GetUserString(MetadataTokens.UserStringHandle(payloadValue)));
|
||||
break;
|
||||
case Payload.Float32:
|
||||
yield return Tuples.cil_value(this, BitConverter.ToSingle(data, offset).ToString());
|
||||
@@ -404,7 +404,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
case Payload.Field:
|
||||
case Payload.ValueType:
|
||||
// A generic EntityHandle.
|
||||
var handle = MetadataTokens.EntityHandle(PayloadValue);
|
||||
var handle = MetadataTokens.EntityHandle(payloadValue);
|
||||
var target = cx.CreateGeneric(Method, handle);
|
||||
yield return target;
|
||||
if (target != null)
|
||||
@@ -420,14 +420,14 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
case Payload.Arg16:
|
||||
if (Method.Parameters is object)
|
||||
{
|
||||
yield return Tuples.cil_access(this, Method.Parameters[(int)UnsignedPayloadValue]);
|
||||
yield return Tuples.cil_access(this, Method.Parameters[(int)unsignedPayloadValue]);
|
||||
}
|
||||
break;
|
||||
case Payload.Local8:
|
||||
case Payload.Local16:
|
||||
if (Method.LocalVariables is object)
|
||||
{
|
||||
yield return Tuples.cil_access(this, Method.LocalVariables[(int)UnsignedPayloadValue]);
|
||||
yield return Tuples.cil_access(this, Method.LocalVariables[(int)unsignedPayloadValue]);
|
||||
}
|
||||
break;
|
||||
case Payload.None:
|
||||
@@ -454,17 +454,17 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
switch (PayloadType)
|
||||
{
|
||||
case Payload.Target8:
|
||||
target = Offset + PayloadValue + 2;
|
||||
target = Offset + payloadValue + 2;
|
||||
break;
|
||||
case Payload.Target32:
|
||||
target = Offset + PayloadValue + 5;
|
||||
target = Offset + payloadValue + 5;
|
||||
break;
|
||||
case Payload.Switch:
|
||||
var end = Offset + Width;
|
||||
|
||||
var offset = Offset + 5;
|
||||
|
||||
for (var b = 0; b < PayloadValue; ++b, offset += 4)
|
||||
for (var b = 0; b < payloadValue; ++b, offset += 4)
|
||||
{
|
||||
target = BitConverter.ToInt32(data, offset) + end;
|
||||
if (jump_table.TryGetValue(target, out inst))
|
||||
|
||||
@@ -78,13 +78,13 @@ namespace Semmle.BuildAnalyser
|
||||
.ToArray();
|
||||
|
||||
var dllDirNames = options.DllDirs.Select(Path.GetFullPath).ToList();
|
||||
PackageDirectory = new TemporaryDirectory(ComputeTempDirectory(sourceDir.FullName));
|
||||
packageDirectory = new TemporaryDirectory(ComputeTempDirectory(sourceDir.FullName));
|
||||
|
||||
if (options.UseNuGet)
|
||||
{
|
||||
try
|
||||
{
|
||||
var nuget = new NugetPackages(sourceDir.FullName, PackageDirectory);
|
||||
var nuget = new NugetPackages(sourceDir.FullName, packageDirectory);
|
||||
nuget.InstallPackages(progressMonitor);
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
@@ -110,7 +110,7 @@ namespace Semmle.BuildAnalyser
|
||||
sourceDir.GetFiles("*.sln", SearchOption.AllDirectories).Select(d => d.FullName);
|
||||
|
||||
RestoreSolutions(solutions);
|
||||
dllDirNames.Add(PackageDirectory.DirInfo.FullName);
|
||||
dllDirNames.Add(packageDirectory.DirInfo.FullName);
|
||||
assemblyCache = new BuildAnalyser.AssemblyCache(dllDirNames, progress);
|
||||
AnalyseSolutions(solutions);
|
||||
|
||||
@@ -268,7 +268,7 @@ namespace Semmle.BuildAnalyser
|
||||
unresolvedReferences[id] = projectFile;
|
||||
}
|
||||
|
||||
private readonly TemporaryDirectory PackageDirectory;
|
||||
private readonly TemporaryDirectory packageDirectory;
|
||||
|
||||
/// <summary>
|
||||
/// Reads all the source files and references from the given list of projects.
|
||||
@@ -325,7 +325,7 @@ namespace Semmle.BuildAnalyser
|
||||
|
||||
private void Restore(string projectOrSolution)
|
||||
{
|
||||
var exit = DotNet.RestoreToDirectory(projectOrSolution, PackageDirectory.DirInfo.FullName);
|
||||
var exit = DotNet.RestoreToDirectory(projectOrSolution, packageDirectory.DirInfo.FullName);
|
||||
switch (exit)
|
||||
{
|
||||
case 0:
|
||||
@@ -362,7 +362,7 @@ namespace Semmle.BuildAnalyser
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
PackageDirectory?.Dispose();
|
||||
packageDirectory?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,27 +9,27 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
bool IExpressionParentEntity.IsTopLevelParent => true;
|
||||
|
||||
private readonly AttributeData AttributeData;
|
||||
private readonly IEntity Entity;
|
||||
private readonly AttributeData attribute;
|
||||
private readonly IEntity entity;
|
||||
|
||||
public Attribute(Context cx, AttributeData attribute, IEntity entity)
|
||||
: base(cx)
|
||||
{
|
||||
AttributeData = attribute;
|
||||
Entity = entity;
|
||||
this.attribute = attribute;
|
||||
this.entity = entity;
|
||||
TryPopulate();
|
||||
}
|
||||
|
||||
protected override void Populate(TextWriter trapFile)
|
||||
{
|
||||
if (AttributeData.ApplicationSyntaxReference != null)
|
||||
if (attribute.ApplicationSyntaxReference != null)
|
||||
{
|
||||
// !! Extract attributes from assemblies.
|
||||
// This is harder because the "expression" entities presume the
|
||||
// existence of a syntax tree. This is not the case for compiled
|
||||
// attributes.
|
||||
var syntax = AttributeData.ApplicationSyntaxReference.GetSyntax() as AttributeSyntax;
|
||||
ExtractAttribute(cx.TrapWriter.Writer, syntax, AttributeData.AttributeClass, Entity);
|
||||
var syntax = attribute.ApplicationSyntaxReference.GetSyntax() as AttributeSyntax;
|
||||
ExtractAttribute(cx.TrapWriter.Writer, syntax, attribute.AttributeClass, entity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
internal class Expression : FreshEntity, IExpressionParentEntity
|
||||
{
|
||||
private readonly IExpressionInfo Info;
|
||||
private readonly IExpressionInfo info;
|
||||
public readonly AnnotatedType Type;
|
||||
public readonly Extraction.Entities.Location Location;
|
||||
public readonly ExprKind Kind;
|
||||
@@ -27,7 +27,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
internal Expression(IExpressionInfo info)
|
||||
: base(info.Context)
|
||||
{
|
||||
Info = info;
|
||||
this.info = info;
|
||||
Location = info.Location;
|
||||
Kind = info.Kind;
|
||||
Type = info.Type;
|
||||
@@ -40,10 +40,10 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
protected sealed override void Populate(TextWriter trapFile)
|
||||
{
|
||||
trapFile.expressions(this, Kind, Type.Type.TypeRef);
|
||||
if (Info.Parent.IsTopLevelParent)
|
||||
trapFile.expr_parent_top_level(this, Info.Child, Info.Parent);
|
||||
if (info.Parent.IsTopLevelParent)
|
||||
trapFile.expr_parent_top_level(this, info.Child, info.Parent);
|
||||
else
|
||||
trapFile.expr_parent(this, Info.Child, Info.Parent);
|
||||
trapFile.expr_parent(this, info.Child, info.Parent);
|
||||
trapFile.expr_location(this, Location);
|
||||
|
||||
var annotatedType = Type.Symbol;
|
||||
@@ -53,15 +53,15 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
trapFile.type_nullability(this, n);
|
||||
}
|
||||
|
||||
if (Info.FlowState != NullableFlowState.None)
|
||||
if (info.FlowState != NullableFlowState.None)
|
||||
{
|
||||
trapFile.expr_flowstate(this, (int)Info.FlowState);
|
||||
trapFile.expr_flowstate(this, (int)info.FlowState);
|
||||
}
|
||||
|
||||
if (Info.IsCompilerGenerated)
|
||||
if (info.IsCompilerGenerated)
|
||||
trapFile.expr_compiler_generated(this);
|
||||
|
||||
if (Info.ExprValue is string value)
|
||||
if (info.ExprValue is string value)
|
||||
trapFile.expr_value(this, value);
|
||||
|
||||
Type.Type.PopulateGenerics();
|
||||
|
||||
@@ -11,28 +11,28 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
protected ElementAccess(ExpressionNodeInfo info, ExpressionSyntax qualifier, BracketedArgumentListSyntax argumentList)
|
||||
: base(info.SetKind(GetKind(info.Context, qualifier)))
|
||||
{
|
||||
Qualifier = qualifier;
|
||||
ArgumentList = argumentList;
|
||||
this.qualifier = qualifier;
|
||||
this.argumentList = argumentList;
|
||||
}
|
||||
|
||||
private readonly ExpressionSyntax Qualifier;
|
||||
private readonly BracketedArgumentListSyntax ArgumentList;
|
||||
private readonly ExpressionSyntax qualifier;
|
||||
private readonly BracketedArgumentListSyntax argumentList;
|
||||
|
||||
protected override void PopulateExpression(TextWriter trapFile)
|
||||
{
|
||||
if (Kind == ExprKind.POINTER_INDIRECTION)
|
||||
{
|
||||
var qualifierInfo = new ExpressionNodeInfo(cx, Qualifier, this, 0);
|
||||
var qualifierInfo = new ExpressionNodeInfo(cx, qualifier, this, 0);
|
||||
var add = new Expression(new ExpressionInfo(cx, qualifierInfo.Type, Location, ExprKind.ADD, this, 0, false, null));
|
||||
qualifierInfo.SetParent(add, 0);
|
||||
CreateFromNode(qualifierInfo);
|
||||
PopulateArguments(trapFile, ArgumentList, 1);
|
||||
PopulateArguments(trapFile, argumentList, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
var child = -1;
|
||||
Create(cx, Qualifier, this, child++);
|
||||
foreach (var a in ArgumentList.Arguments)
|
||||
Create(cx, qualifier, this, child++);
|
||||
foreach (var a in argumentList.Arguments)
|
||||
{
|
||||
cx.Extract(a, this, child++);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
internal class MemberAccess : Expression
|
||||
{
|
||||
private readonly IEntity Target;
|
||||
private readonly IEntity target;
|
||||
|
||||
private MemberAccess(ExpressionNodeInfo info, ExpressionSyntax qualifier, ISymbol target) : base(info)
|
||||
{
|
||||
@@ -20,8 +20,8 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
}
|
||||
else
|
||||
{
|
||||
Target = cx.CreateEntity(target);
|
||||
trapFile.expr_access(this, Target);
|
||||
this.target = cx.CreateEntity(target);
|
||||
trapFile.expr_access(this, this.target);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,21 +9,21 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
private PostfixUnary(ExpressionNodeInfo info, ExprKind kind, ExpressionSyntax operand)
|
||||
: base(info.SetKind(UnaryOperatorKind(info.Context, kind, info.Node)))
|
||||
{
|
||||
Operand = operand;
|
||||
OperatorKind = kind;
|
||||
this.operand = operand;
|
||||
operatorKind = kind;
|
||||
}
|
||||
|
||||
private readonly ExpressionSyntax Operand;
|
||||
private 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();
|
||||
|
||||
protected override void PopulateExpression(TextWriter trapFile)
|
||||
{
|
||||
Create(cx, Operand, this, 0);
|
||||
Create(cx, operand, this, 0);
|
||||
OperatorCall(trapFile, Syntax);
|
||||
|
||||
if ((OperatorKind == ExprKind.POST_INCR || OperatorKind == ExprKind.POST_DECR) &&
|
||||
if ((operatorKind == ExprKind.POST_INCR || operatorKind == ExprKind.POST_DECR) &&
|
||||
Kind == ExprKind.OPERATOR_INVOCATION)
|
||||
{
|
||||
trapFile.mutator_invocation_mode(this, 2);
|
||||
|
||||
@@ -9,10 +9,10 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
private Unary(ExpressionNodeInfo info, ExprKind kind)
|
||||
: base(info.SetKind(UnaryOperatorKind(info.Context, info.Kind, info.Node)))
|
||||
{
|
||||
OperatorKind = kind;
|
||||
operatorKind = kind;
|
||||
}
|
||||
|
||||
private readonly ExprKind OperatorKind;
|
||||
private readonly ExprKind operatorKind;
|
||||
|
||||
public static Unary Create(ExpressionNodeInfo info)
|
||||
{
|
||||
@@ -26,7 +26,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
Create(cx, Syntax.Operand, this, 0);
|
||||
OperatorCall(trapFile, Syntax);
|
||||
|
||||
if ((OperatorKind == ExprKind.PRE_INCR || OperatorKind == ExprKind.PRE_DECR) &&
|
||||
if ((operatorKind == ExprKind.PRE_INCR || operatorKind == ExprKind.PRE_DECR) &&
|
||||
Kind == ExprKind.OPERATOR_INVOCATION)
|
||||
{
|
||||
trapFile.mutator_invocation_mode(this, 1);
|
||||
|
||||
@@ -10,34 +10,34 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
internal class NamespaceDeclaration : FreshEntity
|
||||
{
|
||||
private readonly NamespaceDeclaration Parent;
|
||||
private readonly NamespaceDeclarationSyntax Node;
|
||||
private readonly NamespaceDeclaration parent;
|
||||
private readonly NamespaceDeclarationSyntax node;
|
||||
|
||||
public NamespaceDeclaration(Context cx, NamespaceDeclarationSyntax node, NamespaceDeclaration parent)
|
||||
: base(cx)
|
||||
{
|
||||
Node = node;
|
||||
Parent = parent;
|
||||
this.node = node;
|
||||
this.parent = parent;
|
||||
TryPopulate();
|
||||
}
|
||||
|
||||
protected override void Populate(TextWriter trapFile)
|
||||
{
|
||||
var @namespace = (INamespaceSymbol)cx.GetModel(Node).GetSymbolInfo(Node.Name).Symbol;
|
||||
var @namespace = (INamespaceSymbol)cx.GetModel(node).GetSymbolInfo(node.Name).Symbol;
|
||||
var ns = Namespace.Create(cx, @namespace);
|
||||
trapFile.namespace_declarations(this, ns);
|
||||
trapFile.namespace_declaration_location(this, cx.Create(Node.Name.GetLocation()));
|
||||
trapFile.namespace_declaration_location(this, cx.Create(node.Name.GetLocation()));
|
||||
|
||||
var visitor = new Populators.TypeOrNamespaceVisitor(cx, trapFile, this);
|
||||
|
||||
foreach (var member in Node.Members.Cast<CSharpSyntaxNode>().Concat(Node.Usings))
|
||||
foreach (var member in node.Members.Cast<CSharpSyntaxNode>().Concat(node.Usings))
|
||||
{
|
||||
member.Accept(visitor);
|
||||
}
|
||||
|
||||
if (Parent != null)
|
||||
if (parent != null)
|
||||
{
|
||||
trapFile.parent_namespace_declaration(this, Parent);
|
||||
trapFile.parent_namespace_declaration(this, parent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -255,17 +255,17 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
internal class ConstructedExtensionParameter : Parameter
|
||||
{
|
||||
private readonly ITypeSymbol ConstructedType;
|
||||
private readonly ITypeSymbol constructedType;
|
||||
|
||||
private ConstructedExtensionParameter(Context cx, Method method, Parameter original)
|
||||
: base(cx, original.symbol, method, original)
|
||||
{
|
||||
ConstructedType = method.symbol.ReceiverType;
|
||||
constructedType = method.symbol.ReceiverType;
|
||||
}
|
||||
|
||||
public override void Populate(TextWriter trapFile)
|
||||
{
|
||||
var typeKey = Type.Create(Context, ConstructedType);
|
||||
var typeKey = Type.Create(Context, constructedType);
|
||||
trapFile.@params(this, Original.symbol.Name, typeKey.TypeRef, 0, Kind.This, Parent, Original);
|
||||
trapFile.param_location(this, Original.Location);
|
||||
}
|
||||
|
||||
@@ -41,10 +41,10 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
internal abstract class Statement<TSyntax> : Statement where TSyntax : CSharpSyntaxNode
|
||||
{
|
||||
protected readonly TSyntax Stmt;
|
||||
private readonly int Child;
|
||||
private readonly Kinds.StmtKind Kind;
|
||||
private readonly IStatementParentEntity Parent;
|
||||
private readonly Location Location;
|
||||
private readonly int child;
|
||||
private readonly Kinds.StmtKind kind;
|
||||
private readonly IStatementParentEntity parent;
|
||||
private readonly Location location;
|
||||
|
||||
protected override CSharpSyntaxNode GetStatementSyntax() => Stmt;
|
||||
|
||||
@@ -52,21 +52,21 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
: base(cx)
|
||||
{
|
||||
Stmt = stmt;
|
||||
Parent = parent;
|
||||
Child = child;
|
||||
Location = location;
|
||||
Kind = kind;
|
||||
this.parent = parent;
|
||||
this.child = child;
|
||||
this.location = location;
|
||||
this.kind = kind;
|
||||
cx.BindComments(this, location.symbol);
|
||||
}
|
||||
|
||||
protected sealed override void Populate(TextWriter trapFile)
|
||||
{
|
||||
trapFile.statements(this, Kind);
|
||||
if (Parent.IsTopLevelParent)
|
||||
trapFile.stmt_parent_top_level(this, Child, Parent);
|
||||
trapFile.statements(this, kind);
|
||||
if (parent.IsTopLevelParent)
|
||||
trapFile.stmt_parent_top_level(this, child, parent);
|
||||
else
|
||||
trapFile.stmt_parent(this, Child, Parent);
|
||||
trapFile.stmt_location(this, Location);
|
||||
trapFile.stmt_parent(this, child, parent);
|
||||
trapFile.stmt_location(this, location);
|
||||
PopulateStatement(trapFile);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Semmle.Extraction.CSharp.Entities.Statements
|
||||
{
|
||||
internal class Catch : Statement<CatchClauseSyntax>
|
||||
{
|
||||
private static readonly string SystemExceptionName = typeof(System.Exception).ToString();
|
||||
private static readonly string systemExceptionName = typeof(System.Exception).ToString();
|
||||
|
||||
private Catch(Context cx, CatchClauseSyntax node, Try parent, int child)
|
||||
: base(cx, node, StmtKind.CATCH, parent, child, cx.Create(node.GetLocation())) { }
|
||||
@@ -28,7 +28,7 @@ namespace Semmle.Extraction.CSharp.Entities.Statements
|
||||
}
|
||||
else // A catch clause of the form 'catch { ... }'
|
||||
{
|
||||
var exception = Type.Create(cx, cx.Compilation.GetTypeByMetadataName(SystemExceptionName));
|
||||
var exception = Type.Create(cx, cx.Compilation.GetTypeByMetadataName(systemExceptionName));
|
||||
trapFile.catch_type(this, exception, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,14 +6,14 @@ namespace Semmle.Extraction.CSharp.Entities.Statements
|
||||
{
|
||||
internal class Labeled : Statement<LabeledStatementSyntax>
|
||||
{
|
||||
private readonly Statement Parent;
|
||||
private readonly int Child;
|
||||
private readonly Statement parent;
|
||||
private readonly int child;
|
||||
|
||||
private Labeled(Context cx, LabeledStatementSyntax stmt, Statement parent, int child)
|
||||
: base(cx, stmt, StmtKind.LABEL, parent, child)
|
||||
{
|
||||
Parent = parent;
|
||||
Child = child;
|
||||
this.parent = parent;
|
||||
this.child = child;
|
||||
}
|
||||
|
||||
public static Labeled Create(Context cx, LabeledStatementSyntax node, Statement parent, int child)
|
||||
@@ -29,7 +29,7 @@ namespace Semmle.Extraction.CSharp.Entities.Statements
|
||||
|
||||
// For compatilibty with the Mono extractor, make insert the labelled statement into the same block
|
||||
// as this one. The parent MUST be a block statement.
|
||||
labelledStmt = Statement.Create(cx, Stmt.Statement, Parent, Child + 1);
|
||||
labelledStmt = Statement.Create(cx, Stmt.Statement, parent, child + 1);
|
||||
}
|
||||
|
||||
private Statement labelledStmt;
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Semmle.Extraction.CSharp.Entities.Statements
|
||||
{
|
||||
internal class Switch : Statement<SwitchStatementSyntax>
|
||||
{
|
||||
private static readonly object NullLabel = new object();
|
||||
private static readonly object nullLabel = new object();
|
||||
public static readonly object DefaultLabel = new object();
|
||||
|
||||
// Sometimes, the literal "null" is used as a label.
|
||||
@@ -15,7 +15,7 @@ namespace Semmle.Extraction.CSharp.Entities.Statements
|
||||
// This cannot be stored in a Dictionary<>, so substitute an object which can be.
|
||||
public static object LabelForValue(object label)
|
||||
{
|
||||
return label ?? NullLabel;
|
||||
return label ?? nullLabel;
|
||||
}
|
||||
|
||||
private Switch(Context cx, SwitchStatementSyntax node, IStatementParentEntity parent, int child)
|
||||
|
||||
@@ -9,18 +9,18 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
internal class TypeMention : FreshEntity
|
||||
{
|
||||
private readonly TypeSyntax Syntax;
|
||||
private readonly IEntity Parent;
|
||||
private readonly Type Type;
|
||||
private readonly Microsoft.CodeAnalysis.Location Loc;
|
||||
private readonly TypeSyntax syntax;
|
||||
private readonly IEntity parent;
|
||||
private readonly Type type;
|
||||
private readonly Microsoft.CodeAnalysis.Location loc;
|
||||
|
||||
private TypeMention(Context cx, TypeSyntax syntax, IEntity parent, Type type, Microsoft.CodeAnalysis.Location loc = null)
|
||||
: base(cx)
|
||||
{
|
||||
Syntax = syntax;
|
||||
Parent = parent;
|
||||
Type = type;
|
||||
Loc = loc;
|
||||
this.syntax = syntax;
|
||||
this.parent = parent;
|
||||
this.type = type;
|
||||
this.loc = loc;
|
||||
}
|
||||
|
||||
private static TypeSyntax GetElementType(TypeSyntax type)
|
||||
@@ -51,57 +51,57 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
protected override void Populate(TextWriter trapFile)
|
||||
{
|
||||
switch (Syntax.Kind())
|
||||
switch (syntax.Kind())
|
||||
{
|
||||
case SyntaxKind.ArrayType:
|
||||
Emit(trapFile, Loc ?? Syntax.GetLocation(), Parent, Type);
|
||||
Create(cx, GetElementType(Syntax), this, GetElementType(Type));
|
||||
Emit(trapFile, loc ?? syntax.GetLocation(), parent, type);
|
||||
Create(cx, GetElementType(syntax), this, GetElementType(type));
|
||||
return;
|
||||
case SyntaxKind.NullableType:
|
||||
var nts = (NullableTypeSyntax)Syntax;
|
||||
if (Type is NamedType nt)
|
||||
var nts = (NullableTypeSyntax)syntax;
|
||||
if (type is NamedType nt)
|
||||
{
|
||||
Emit(trapFile, Loc ?? Syntax.GetLocation(), Parent, Type);
|
||||
Emit(trapFile, loc ?? syntax.GetLocation(), parent, type);
|
||||
Create(cx, nts.ElementType, this, nt.symbol.IsReferenceType ? nt : nt.TypeArguments[0]);
|
||||
}
|
||||
else if (Type is ArrayType array)
|
||||
else if (type is ArrayType array)
|
||||
{
|
||||
Create(cx, nts.ElementType, Parent, array);
|
||||
Create(cx, nts.ElementType, parent, array);
|
||||
}
|
||||
return;
|
||||
case SyntaxKind.TupleType:
|
||||
var tts = (TupleTypeSyntax)Syntax;
|
||||
var tt = (TupleType)Type;
|
||||
Emit(trapFile, Loc ?? Syntax.GetLocation(), Parent, Type);
|
||||
var tts = (TupleTypeSyntax)syntax;
|
||||
var tt = (TupleType)type;
|
||||
Emit(trapFile, loc ?? syntax.GetLocation(), parent, type);
|
||||
tts.Elements.Zip(tt.TupleElements, (s, t) => Create(cx, s.Type, this, t.Type)).Enumerate();
|
||||
return;
|
||||
case SyntaxKind.PointerType:
|
||||
var pts = (PointerTypeSyntax)Syntax;
|
||||
var pt = (PointerType)Type;
|
||||
Emit(trapFile, Loc ?? Syntax.GetLocation(), Parent, Type);
|
||||
var pts = (PointerTypeSyntax)syntax;
|
||||
var pt = (PointerType)type;
|
||||
Emit(trapFile, loc ?? syntax.GetLocation(), parent, type);
|
||||
Create(cx, pts.ElementType, this, pt.PointedAtType);
|
||||
return;
|
||||
case SyntaxKind.GenericName:
|
||||
var gns = (GenericNameSyntax)Syntax;
|
||||
Emit(trapFile, Loc ?? gns.Identifier.GetLocation(), Parent, Type);
|
||||
cx.PopulateLater(() => gns.TypeArgumentList.Arguments.Zip(Type.TypeMentions, (s, t) => Create(cx, s, this, t)).Enumerate());
|
||||
var gns = (GenericNameSyntax)syntax;
|
||||
Emit(trapFile, loc ?? gns.Identifier.GetLocation(), parent, type);
|
||||
cx.PopulateLater(() => gns.TypeArgumentList.Arguments.Zip(type.TypeMentions, (s, t) => Create(cx, s, this, t)).Enumerate());
|
||||
return;
|
||||
case SyntaxKind.QualifiedName:
|
||||
if (Type.ContainingType == null)
|
||||
if (type.ContainingType == null)
|
||||
{
|
||||
// namespace qualifier
|
||||
Emit(trapFile, Loc ?? Syntax.GetLocation(), Parent, Type);
|
||||
Emit(trapFile, loc ?? syntax.GetLocation(), parent, type);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Type qualifier
|
||||
var qns = (QualifiedNameSyntax)Syntax;
|
||||
var right = Create(cx, qns.Right, Parent, Type);
|
||||
Create(cx, qns.Left, right, Type.ContainingType);
|
||||
var qns = (QualifiedNameSyntax)syntax;
|
||||
var right = Create(cx, qns.Right, parent, type);
|
||||
Create(cx, qns.Left, right, type.ContainingType);
|
||||
}
|
||||
return;
|
||||
default:
|
||||
Emit(trapFile, Loc ?? Syntax.GetLocation(), Parent, Type);
|
||||
Emit(trapFile, loc ?? syntax.GetLocation(), parent, type);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
public int Annotation { get; }
|
||||
|
||||
private static readonly Nullability[] EmptyArray = System.Array.Empty<Nullability>();
|
||||
private static readonly Nullability[] emptyArray = System.Array.Empty<Nullability>();
|
||||
public readonly Nullability[] NullableParameters;
|
||||
|
||||
public static Nullability Create(AnnotatedTypeSymbol ts)
|
||||
@@ -50,12 +50,12 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
Annotation = 0;
|
||||
break;
|
||||
}
|
||||
NullableParameters = EmptyArray;
|
||||
NullableParameters = emptyArray;
|
||||
}
|
||||
|
||||
private Nullability(AnnotatedTypeSymbol ts) : this(ts.Nullability)
|
||||
{
|
||||
NullableParameters = ts.HasConsistentNullability() ? EmptyArray : ts.GetAnnotatedTypeArguments().Select(Create).ToArray();
|
||||
NullableParameters = ts.HasConsistentNullability() ? emptyArray : ts.GetAnnotatedTypeArguments().Select(Create).ToArray();
|
||||
}
|
||||
|
||||
public Nullability(IMethodSymbol method)
|
||||
|
||||
@@ -8,22 +8,22 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
internal class UsingDirective : FreshEntity
|
||||
{
|
||||
private readonly UsingDirectiveSyntax Node;
|
||||
private readonly NamespaceDeclaration Parent;
|
||||
private readonly UsingDirectiveSyntax node;
|
||||
private readonly NamespaceDeclaration parent;
|
||||
|
||||
public UsingDirective(Context cx, UsingDirectiveSyntax usingDirective, NamespaceDeclaration parent)
|
||||
: base(cx)
|
||||
{
|
||||
Node = usingDirective;
|
||||
Parent = parent;
|
||||
node = usingDirective;
|
||||
this.parent = parent;
|
||||
TryPopulate();
|
||||
}
|
||||
|
||||
protected override void Populate(TextWriter trapFile)
|
||||
{
|
||||
var info = cx.GetModel(Node).GetSymbolInfo(Node.Name);
|
||||
var info = cx.GetModel(node).GetSymbolInfo(node.Name);
|
||||
|
||||
if (Node.StaticKeyword.Kind() == SyntaxKind.None)
|
||||
if (node.StaticKeyword.Kind() == SyntaxKind.None)
|
||||
{
|
||||
// A normal using
|
||||
if (info.Symbol is INamespaceSymbol namespaceSymbol)
|
||||
@@ -34,8 +34,8 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
}
|
||||
else
|
||||
{
|
||||
cx.Extractor.MissingNamespace(Node.Name.ToFullString(), cx.FromSource);
|
||||
cx.ModelError(Node, "Namespace not found");
|
||||
cx.Extractor.MissingNamespace(node.Name.ToFullString(), cx.FromSource);
|
||||
cx.ModelError(node, "Namespace not found");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -47,13 +47,13 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
trapFile.using_directive_location(this, cx.Create(ReportingLocation));
|
||||
}
|
||||
|
||||
if (Parent != null)
|
||||
if (parent != null)
|
||||
{
|
||||
trapFile.parent_namespace_declaration(this, Parent);
|
||||
trapFile.parent_namespace_declaration(this, parent);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed override Microsoft.CodeAnalysis.Location ReportingLocation => Node.GetLocation();
|
||||
public sealed override Microsoft.CodeAnalysis.Location ReportingLocation => node.GetLocation();
|
||||
|
||||
public override TrapStackBehaviour TrapStackBehaviour => TrapStackBehaviour.NoLabel;
|
||||
}
|
||||
|
||||
@@ -25,18 +25,18 @@ namespace Semmle.Extraction.CSharp
|
||||
|
||||
private class LogProgressMonitor : IProgressMonitor
|
||||
{
|
||||
private readonly ILogger Logger;
|
||||
private readonly ILogger logger;
|
||||
|
||||
public LogProgressMonitor(ILogger logger)
|
||||
{
|
||||
Logger = logger;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
public void Analysed(int item, int total, string source, string output, TimeSpan time, AnalysisAction action)
|
||||
{
|
||||
if (action != AnalysisAction.UpToDate)
|
||||
{
|
||||
Logger.Log(Severity.Info, " {0} ({1})", source,
|
||||
logger.Log(Severity.Info, " {0} ({1})", source,
|
||||
action == AnalysisAction.Extracted
|
||||
? time.ToString()
|
||||
: action == AnalysisAction.Excluded
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Semmle.Extraction.Tests
|
||||
|
||||
public class Layout
|
||||
{
|
||||
private readonly ILogger Logger = new LoggerMock();
|
||||
private readonly ILogger logger = new LoggerMock();
|
||||
|
||||
[Fact]
|
||||
public void TestDefaultLayout()
|
||||
@@ -54,13 +54,13 @@ namespace Semmle.Extraction.Tests
|
||||
tmpDir = tmpDir.Substring(0, tmpDir.Length - 1);
|
||||
Assert.Equal(Directory.GetCurrentDirectory(), tmpDir);
|
||||
}
|
||||
var f1 = project!.GetTrapPath(Logger, new TransformedPathStub("foo.cs"), TrapWriter.CompressionMode.Gzip);
|
||||
var g1 = TrapWriter.NestPaths(Logger, tmpDir, "foo.cs.trap.gz");
|
||||
var f1 = project!.GetTrapPath(logger, new TransformedPathStub("foo.cs"), TrapWriter.CompressionMode.Gzip);
|
||||
var g1 = TrapWriter.NestPaths(logger, tmpDir, "foo.cs.trap.gz");
|
||||
Assert.Equal(f1, g1);
|
||||
|
||||
// Test trap file generation
|
||||
var trapwriterFilename = project.GetTrapPath(Logger, new TransformedPathStub("foo.cs"), TrapWriter.CompressionMode.Gzip);
|
||||
using (var trapwriter = project.CreateTrapWriter(Logger, new TransformedPathStub("foo.cs"), false, TrapWriter.CompressionMode.Gzip))
|
||||
var trapwriterFilename = project.GetTrapPath(logger, new TransformedPathStub("foo.cs"), TrapWriter.CompressionMode.Gzip);
|
||||
using (var trapwriter = project.CreateTrapWriter(logger, new TransformedPathStub("foo.cs"), false, TrapWriter.CompressionMode.Gzip))
|
||||
{
|
||||
trapwriter.Emit("1=*");
|
||||
Assert.False(File.Exists(trapwriterFilename));
|
||||
@@ -99,14 +99,14 @@ namespace Semmle.Extraction.Tests
|
||||
// Test the trap file
|
||||
var project = layout.LookupProjectOrNull(new TransformedPathStub("bar.cs"));
|
||||
Assert.NotNull(project);
|
||||
var trapwriterFilename = project!.GetTrapPath(Logger, new TransformedPathStub("bar.cs"), TrapWriter.CompressionMode.Gzip);
|
||||
Assert.Equal(TrapWriter.NestPaths(Logger, Path.GetFullPath("snapshot\\trap"), "bar.cs.trap.gz"),
|
||||
var trapwriterFilename = project!.GetTrapPath(logger, new TransformedPathStub("bar.cs"), TrapWriter.CompressionMode.Gzip);
|
||||
Assert.Equal(TrapWriter.NestPaths(logger, Path.GetFullPath("snapshot\\trap"), "bar.cs.trap.gz"),
|
||||
trapwriterFilename);
|
||||
|
||||
// Test the source archive
|
||||
var trapWriter = project.CreateTrapWriter(Logger, new TransformedPathStub("bar.cs"), false, TrapWriter.CompressionMode.Gzip);
|
||||
var trapWriter = project.CreateTrapWriter(logger, new TransformedPathStub("bar.cs"), false, TrapWriter.CompressionMode.Gzip);
|
||||
trapWriter.Archive("layout.txt", new TransformedPathStub("layout.txt"), System.Text.Encoding.ASCII);
|
||||
var writtenFile = TrapWriter.NestPaths(Logger, Path.GetFullPath("snapshot\\archive"), "layout.txt");
|
||||
var writtenFile = TrapWriter.NestPaths(logger, Path.GetFullPath("snapshot\\archive"), "layout.txt");
|
||||
Assert.True(File.Exists(writtenFile));
|
||||
File.Delete("layout.txt");
|
||||
}
|
||||
@@ -119,8 +119,8 @@ namespace Semmle.Extraction.Tests
|
||||
Assert.True(layout.FileInLayout(new TransformedPathStub("bar.cs")));
|
||||
var subProject = layout.LookupProjectOrNull(new TransformedPathStub("foo.cs"));
|
||||
Assert.NotNull(subProject);
|
||||
var f1 = subProject!.GetTrapPath(Logger, new TransformedPathStub("foo.cs"), TrapWriter.CompressionMode.Gzip);
|
||||
var g1 = TrapWriter.NestPaths(Logger, Path.GetFullPath("snapshot\\trap"), "foo.cs.trap.gz");
|
||||
var f1 = subProject!.GetTrapPath(logger, new TransformedPathStub("foo.cs"), TrapWriter.CompressionMode.Gzip);
|
||||
var g1 = TrapWriter.NestPaths(logger, Path.GetFullPath("snapshot\\trap"), "foo.cs.trap.gz");
|
||||
Assert.Equal(f1, g1);
|
||||
}
|
||||
|
||||
@@ -149,22 +149,22 @@ namespace Semmle.Extraction.Tests
|
||||
Assert.True(layout.FileInLayout(new TransformedPathStub("bar.cs")));
|
||||
var subProject = layout.LookupProjectOrNull(new TransformedPathStub("bar.cs"));
|
||||
Assert.NotNull(subProject);
|
||||
var f1 = subProject!.GetTrapPath(Logger, new TransformedPathStub("bar.cs"), TrapWriter.CompressionMode.Gzip);
|
||||
var g1 = TrapWriter.NestPaths(Logger, Path.GetFullPath("snapshot\\trap2"), "bar.cs.trap.gz");
|
||||
var f1 = subProject!.GetTrapPath(logger, new TransformedPathStub("bar.cs"), TrapWriter.CompressionMode.Gzip);
|
||||
var g1 = TrapWriter.NestPaths(logger, Path.GetFullPath("snapshot\\trap2"), "bar.cs.trap.gz");
|
||||
Assert.Equal(f1, g1);
|
||||
|
||||
// Use Section 1
|
||||
Assert.True(layout.FileInLayout(new TransformedPathStub("foo.cs")));
|
||||
subProject = layout.LookupProjectOrNull(new TransformedPathStub("foo.cs"));
|
||||
Assert.NotNull(subProject);
|
||||
var f2 = subProject!.GetTrapPath(Logger, new TransformedPathStub("foo.cs"), TrapWriter.CompressionMode.Gzip);
|
||||
var g2 = TrapWriter.NestPaths(Logger, Path.GetFullPath("snapshot\\trap1"), "foo.cs.trap.gz");
|
||||
var f2 = subProject!.GetTrapPath(logger, new TransformedPathStub("foo.cs"), TrapWriter.CompressionMode.Gzip);
|
||||
var g2 = TrapWriter.NestPaths(logger, Path.GetFullPath("snapshot\\trap1"), "foo.cs.trap.gz");
|
||||
Assert.Equal(f2, g2);
|
||||
|
||||
// boo.dll is not in the layout, so use layout from first section.
|
||||
Assert.False(layout.FileInLayout(new TransformedPathStub("boo.dll")));
|
||||
var f3 = layout.LookupProjectOrDefault(new TransformedPathStub("boo.dll")).GetTrapPath(Logger, new TransformedPathStub("boo.dll"), TrapWriter.CompressionMode.Gzip);
|
||||
var g3 = TrapWriter.NestPaths(Logger, Path.GetFullPath("snapshot\\trap1"), "boo.dll.trap.gz");
|
||||
var f3 = layout.LookupProjectOrDefault(new TransformedPathStub("boo.dll")).GetTrapPath(logger, new TransformedPathStub("boo.dll"), TrapWriter.CompressionMode.Gzip);
|
||||
var g3 = TrapWriter.NestPaths(logger, Path.GetFullPath("snapshot\\trap1"), "boo.dll.trap.gz");
|
||||
Assert.Equal(f3, g3);
|
||||
|
||||
// boo.cs is not in the layout, so return null
|
||||
@@ -216,15 +216,15 @@ namespace Semmle.Extraction.Tests
|
||||
|
||||
private class StringTrapEmitter : ITrapEmitter
|
||||
{
|
||||
private readonly string Content;
|
||||
private readonly string content;
|
||||
public StringTrapEmitter(string content)
|
||||
{
|
||||
Content = content;
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public void EmitTrap(TextWriter trapFile)
|
||||
{
|
||||
trapFile.Write(Content);
|
||||
trapFile.Write(content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,11 +49,11 @@ namespace Semmle.Extraction
|
||||
private int GetNewId() => TrapWriter.IdCounter++;
|
||||
|
||||
// A recursion guard against writing to the trap file whilst writing an id to the trap file.
|
||||
private bool WritingLabel = false;
|
||||
private bool writingLabel = false;
|
||||
|
||||
public void DefineLabel(IEntity entity, TextWriter trapFile, IExtractor extractor)
|
||||
{
|
||||
if (WritingLabel)
|
||||
if (writingLabel)
|
||||
{
|
||||
// Don't define a label whilst writing a label.
|
||||
PopulateLater(() => DefineLabel(entity, trapFile, extractor));
|
||||
@@ -62,12 +62,12 @@ namespace Semmle.Extraction
|
||||
{
|
||||
try
|
||||
{
|
||||
WritingLabel = true;
|
||||
writingLabel = true;
|
||||
entity.DefineLabel(trapFile, extractor);
|
||||
}
|
||||
finally
|
||||
{
|
||||
WritingLabel = false;
|
||||
writingLabel = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -237,18 +237,18 @@ namespace Semmle.Extraction
|
||||
{
|
||||
Extractor = e;
|
||||
Compilation = c;
|
||||
Scope = scope;
|
||||
this.scope = scope;
|
||||
TrapWriter = trapWriter;
|
||||
ShouldAddAssemblyTrapPrefix = addAssemblyTrapPrefix;
|
||||
}
|
||||
|
||||
public bool FromSource => Scope.FromSource;
|
||||
public bool FromSource => scope.FromSource;
|
||||
|
||||
public bool IsGlobalContext => Scope.IsGlobalScope;
|
||||
public bool IsGlobalContext => scope.IsGlobalScope;
|
||||
|
||||
public readonly ICommentGenerator CommentGenerator = new CommentProcessor();
|
||||
|
||||
private readonly IExtractionScope Scope;
|
||||
private readonly IExtractionScope scope;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the given symbol needs to be defined in this context.
|
||||
@@ -258,13 +258,13 @@ namespace Semmle.Extraction
|
||||
/// <param name="symbol">The symbol to populate.</param>
|
||||
public bool Defines(ISymbol symbol) =>
|
||||
!SymbolEqualityComparer.Default.Equals(symbol, symbol.OriginalDefinition) ||
|
||||
Scope.InScope(symbol);
|
||||
scope.InScope(symbol);
|
||||
|
||||
/// <summary>
|
||||
/// Whether the current extraction context defines a given file.
|
||||
/// </summary>
|
||||
/// <param name="path">The path to query.</param>
|
||||
public bool DefinesFile(string path) => Scope.InFileScope(path);
|
||||
public bool DefinesFile(string path) => scope.InFileScope(path);
|
||||
|
||||
private int currentRecursiveDepth = 0;
|
||||
private const int maxRecursiveDepth = 150;
|
||||
@@ -301,17 +301,17 @@ namespace Semmle.Extraction
|
||||
|
||||
private class PushEmitter : ITrapEmitter
|
||||
{
|
||||
private readonly Key Key;
|
||||
private readonly Key key;
|
||||
|
||||
public PushEmitter(Key key)
|
||||
{
|
||||
Key = key;
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public void EmitTrap(TextWriter trapFile)
|
||||
{
|
||||
trapFile.Write(".push ");
|
||||
Key.AppendTo(trapFile);
|
||||
key.AppendTo(trapFile);
|
||||
trapFile.WriteLine();
|
||||
}
|
||||
}
|
||||
@@ -334,7 +334,7 @@ namespace Semmle.Extraction
|
||||
/// <exception cref="InternalError">Thrown on invalid trap stack behaviour.</exception>
|
||||
public void Populate(ISymbol? optionalSymbol, ICachedEntity entity)
|
||||
{
|
||||
if (WritingLabel)
|
||||
if (writingLabel)
|
||||
{
|
||||
// Don't write tuples etc if we're currently defining a label
|
||||
PopulateLater(() => Populate(optionalSymbol, entity));
|
||||
@@ -384,7 +384,7 @@ namespace Semmle.Extraction
|
||||
/// </summary>
|
||||
public void WithDuplicationGuard(Key key, Action a)
|
||||
{
|
||||
if (Scope is AssemblyScope)
|
||||
if (scope is AssemblyScope)
|
||||
{
|
||||
// No need for a duplication guard when extracting assemblies,
|
||||
// and the duplication guard could lead to method bodies being missed
|
||||
|
||||
@@ -10,15 +10,15 @@ namespace Semmle.Extraction.Entities
|
||||
private File(Context cx, string path)
|
||||
: base(cx, path)
|
||||
{
|
||||
OriginalPath = path;
|
||||
TransformedPathLazy = new Lazy<PathTransformer.ITransformedPath>(() => Context.Extractor.PathTransformer.Transform(OriginalPath));
|
||||
originalPath = path;
|
||||
transformedPathLazy = new Lazy<PathTransformer.ITransformedPath>(() => Context.Extractor.PathTransformer.Transform(originalPath));
|
||||
}
|
||||
|
||||
private readonly string OriginalPath;
|
||||
private readonly Lazy<PathTransformer.ITransformedPath> TransformedPathLazy;
|
||||
private PathTransformer.ITransformedPath TransformedPath => TransformedPathLazy.Value;
|
||||
private readonly string originalPath;
|
||||
private readonly Lazy<PathTransformer.ITransformedPath> transformedPathLazy;
|
||||
private PathTransformer.ITransformedPath TransformedPath => transformedPathLazy.Value;
|
||||
|
||||
public override bool NeedsPopulation => Context.DefinesFile(OriginalPath) || OriginalPath == Context.Extractor.OutputPath;
|
||||
public override bool NeedsPopulation => Context.DefinesFile(originalPath) || originalPath == Context.Extractor.OutputPath;
|
||||
|
||||
public override void Populate(TextWriter trapFile)
|
||||
{
|
||||
@@ -31,7 +31,7 @@ namespace Semmle.Extraction.Entities
|
||||
if (fromSource)
|
||||
{
|
||||
foreach (var text in Context.Compilation.SyntaxTrees
|
||||
.Where(t => t.FilePath == OriginalPath)
|
||||
.Where(t => t.FilePath == originalPath)
|
||||
.Select(tree => tree.GetText()))
|
||||
{
|
||||
var rawText = text.ToString() ?? "";
|
||||
@@ -40,7 +40,7 @@ namespace Semmle.Extraction.Entities
|
||||
lineCounts.Total++;
|
||||
|
||||
trapFile.numlines(this, lineCounts);
|
||||
Context.TrapWriter.Archive(OriginalPath, TransformedPath, text.Encoding ?? System.Text.Encoding.Default);
|
||||
Context.TrapWriter.Archive(originalPath, TransformedPath, text.Encoding ?? System.Text.Encoding.Default);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,23 +4,23 @@ namespace Semmle.Extraction.Entities
|
||||
{
|
||||
public class GeneratedLocation : SourceLocation
|
||||
{
|
||||
private readonly File GeneratedFile;
|
||||
private readonly File generatedFile;
|
||||
|
||||
private GeneratedLocation(Context cx)
|
||||
: base(cx, null)
|
||||
{
|
||||
GeneratedFile = File.CreateGenerated(cx);
|
||||
generatedFile = File.CreateGenerated(cx);
|
||||
}
|
||||
|
||||
public override void Populate(TextWriter trapFile)
|
||||
{
|
||||
trapFile.locations_default(this, GeneratedFile, 0, 0, 0, 0);
|
||||
trapFile.locations_default(this, generatedFile, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
public override void WriteId(TextWriter trapFile)
|
||||
{
|
||||
trapFile.Write("loc,");
|
||||
trapFile.WriteSubId(GeneratedFile);
|
||||
trapFile.WriteSubId(generatedFile);
|
||||
trapFile.Write(",0,0,0,0");
|
||||
}
|
||||
|
||||
|
||||
@@ -48,26 +48,26 @@ namespace Semmle.Extraction
|
||||
/// </summary>
|
||||
public class Key : IId
|
||||
{
|
||||
private readonly StringWriter TrapBuilder = new StringWriter();
|
||||
private readonly StringWriter trapBuilder = new StringWriter();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new key by concatenating the contents of the supplied arguments.
|
||||
/// </summary>
|
||||
public Key(params object[] args)
|
||||
{
|
||||
TrapBuilder = new StringWriter();
|
||||
trapBuilder = new StringWriter();
|
||||
foreach (var arg in args)
|
||||
{
|
||||
if (arg is IEntity entity)
|
||||
{
|
||||
var key = entity.Label;
|
||||
TrapBuilder.Write("{#");
|
||||
TrapBuilder.Write(key.Value.ToString());
|
||||
TrapBuilder.Write("}");
|
||||
trapBuilder.Write("{#");
|
||||
trapBuilder.Write(key.Value.ToString());
|
||||
trapBuilder.Write("}");
|
||||
}
|
||||
else
|
||||
{
|
||||
TrapBuilder.Write(arg.ToString());
|
||||
trapBuilder.Write(arg.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -78,12 +78,12 @@ namespace Semmle.Extraction
|
||||
/// </summary>
|
||||
public Key(Action<TextWriter> action)
|
||||
{
|
||||
action(TrapBuilder);
|
||||
action(trapBuilder);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return TrapBuilder.ToString();
|
||||
return trapBuilder.ToString();
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
@@ -91,15 +91,15 @@ namespace Semmle.Extraction
|
||||
if (obj is null || obj.GetType() != GetType())
|
||||
return false;
|
||||
var id = (Key)obj;
|
||||
return TrapBuilder.ToString() == id.TrapBuilder.ToString();
|
||||
return trapBuilder.ToString() == id.trapBuilder.ToString();
|
||||
}
|
||||
|
||||
public override int GetHashCode() => TrapBuilder.ToString().GetHashCode();
|
||||
public override int GetHashCode() => trapBuilder.ToString().GetHashCode();
|
||||
|
||||
public void AppendTo(TextWriter trapFile)
|
||||
{
|
||||
trapFile.Write("@\"");
|
||||
trapFile.Write(TrapBuilder.ToString());
|
||||
trapFile.Write(trapBuilder.ToString());
|
||||
trapFile.Write("\"");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace Semmle.Extraction
|
||||
new TrapWriter(logger, srcFile, TRAP_FOLDER, SOURCE_ARCHIVE, discardDuplicates, trapCompression);
|
||||
}
|
||||
|
||||
private readonly SubProject DefaultProject;
|
||||
private readonly SubProject defaultProject;
|
||||
|
||||
/// <summary>
|
||||
/// Finds the suitable directories for a given source file.
|
||||
@@ -77,7 +77,7 @@ namespace Semmle.Extraction
|
||||
public SubProject? LookupProjectOrNull(PathTransformer.ITransformedPath sourceFile)
|
||||
{
|
||||
if (!useLayoutFile)
|
||||
return DefaultProject;
|
||||
return defaultProject;
|
||||
|
||||
return blocks
|
||||
.Where(block => block.Matches(sourceFile))
|
||||
@@ -93,7 +93,7 @@ namespace Semmle.Extraction
|
||||
/// <returns>The relevant subproject, or DefaultProject if not found.</returns>
|
||||
public SubProject LookupProjectOrDefault(PathTransformer.ITransformedPath sourceFile)
|
||||
{
|
||||
return LookupProjectOrNull(sourceFile) ?? DefaultProject;
|
||||
return LookupProjectOrNull(sourceFile) ?? defaultProject;
|
||||
}
|
||||
|
||||
private readonly bool useLayoutFile;
|
||||
@@ -123,11 +123,11 @@ namespace Semmle.Extraction
|
||||
if (useLayoutFile)
|
||||
{
|
||||
ReadLayoutFile(layout!);
|
||||
DefaultProject = blocks[0].Directories;
|
||||
defaultProject = blocks[0].Directories;
|
||||
}
|
||||
else
|
||||
{
|
||||
DefaultProject = new SubProject(traps, archive);
|
||||
defaultProject = new SubProject(traps, archive);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,12 +185,12 @@ namespace Semmle.Extraction
|
||||
{
|
||||
// first line: #name
|
||||
i++;
|
||||
var TRAP_FOLDER = ReadVariable("TRAP_FOLDER", lines[i++]);
|
||||
var trapFolder = ReadVariable("TRAP_FOLDER", lines[i++]);
|
||||
// Don't care about ODASA_DB.
|
||||
ReadVariable("ODASA_DB", lines[i++]);
|
||||
var SOURCE_ARCHIVE = ReadVariable("SOURCE_ARCHIVE", lines[i++]);
|
||||
var sourceArchive = ReadVariable("SOURCE_ARCHIVE", lines[i++]);
|
||||
|
||||
Directories = new Layout.SubProject(TRAP_FOLDER, SOURCE_ARCHIVE);
|
||||
Directories = new Layout.SubProject(trapFolder, sourceArchive);
|
||||
// Don't care about ODASA_BUILD_ERROR_DIR.
|
||||
ReadVariable("ODASA_BUILD_ERROR_DIR", lines[i++]);
|
||||
while (i < lines.Length && !lines[i].StartsWith("#"))
|
||||
|
||||
@@ -25,28 +25,28 @@ namespace Semmle.Extraction
|
||||
/// The location of the src_archive directory.
|
||||
/// </summary>
|
||||
private readonly string? archive;
|
||||
private static readonly Encoding UTF8 = new UTF8Encoding(false);
|
||||
private static readonly Encoding utf8 = new UTF8Encoding(false);
|
||||
|
||||
private readonly bool discardDuplicates;
|
||||
|
||||
public int IdCounter { get; set; } = 1;
|
||||
|
||||
private readonly Lazy<StreamWriter> WriterLazy;
|
||||
private readonly Lazy<StreamWriter> writerLazy;
|
||||
|
||||
public StreamWriter Writer => WriterLazy.Value;
|
||||
public StreamWriter Writer => writerLazy.Value;
|
||||
|
||||
private readonly ILogger Logger;
|
||||
private readonly ILogger logger;
|
||||
|
||||
private readonly CompressionMode TrapCompression;
|
||||
private readonly CompressionMode trapCompression;
|
||||
|
||||
public TrapWriter(ILogger logger, PathTransformer.ITransformedPath outputfile, string? trap, string? archive, bool discardDuplicates, CompressionMode trapCompression)
|
||||
{
|
||||
Logger = logger;
|
||||
TrapCompression = trapCompression;
|
||||
this.logger = logger;
|
||||
this.trapCompression = trapCompression;
|
||||
|
||||
TrapFile = TrapPath(Logger, trap, outputfile, trapCompression);
|
||||
TrapFile = TrapPath(this.logger, trap, outputfile, trapCompression);
|
||||
|
||||
WriterLazy = new Lazy<StreamWriter>(() =>
|
||||
writerLazy = new Lazy<StreamWriter>(() =>
|
||||
{
|
||||
var tempPath = trap ?? Path.GetTempPath();
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace Semmle.Extraction
|
||||
}
|
||||
|
||||
|
||||
return new StreamWriter(compressionStream, UTF8, 2000000);
|
||||
return new StreamWriter(compressionStream, utf8, 2000000);
|
||||
});
|
||||
this.archive = archive;
|
||||
this.discardDuplicates = discardDuplicates;
|
||||
@@ -163,9 +163,9 @@ namespace Semmle.Extraction
|
||||
{
|
||||
try
|
||||
{
|
||||
if (WriterLazy.IsValueCreated)
|
||||
if (writerLazy.IsValueCreated)
|
||||
{
|
||||
WriterLazy.Value.Close();
|
||||
writerLazy.Value.Close();
|
||||
if (TryMove(tmpFile, TrapFile))
|
||||
return;
|
||||
|
||||
@@ -180,16 +180,16 @@ namespace Semmle.Extraction
|
||||
if (existingHash != hash)
|
||||
{
|
||||
var root = TrapFile.Substring(0, TrapFile.Length - 8); // Remove trailing ".trap.gz"
|
||||
if (TryMove(tmpFile, $"{root}-{hash}.trap{TrapExtension(TrapCompression)}"))
|
||||
if (TryMove(tmpFile, $"{root}-{hash}.trap{TrapExtension(trapCompression)}"))
|
||||
return;
|
||||
}
|
||||
Logger.Log(Severity.Info, "Identical trap file for {0} already exists", TrapFile);
|
||||
logger.Log(Severity.Info, "Identical trap file for {0} already exists", TrapFile);
|
||||
FileUtils.TryDelete(tmpFile);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) // lgtm[cs/catch-of-all-exceptions]
|
||||
{
|
||||
Logger.Log(Severity.Error, "Failed to move the trap file from {0} to {1} because {2}", tmpFile, TrapFile, ex);
|
||||
logger.Log(Severity.Error, "Failed to move the trap file from {0} to {1} because {2}", tmpFile, TrapFile, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,9 +216,9 @@ namespace Semmle.Extraction
|
||||
|
||||
private void ArchiveContents(PathTransformer.ITransformedPath transformedPath, string contents)
|
||||
{
|
||||
var dest = NestPaths(Logger, archive, transformedPath.Value);
|
||||
var dest = NestPaths(logger, archive, transformedPath.Value);
|
||||
var tmpSrcFile = Path.GetTempFileName();
|
||||
File.WriteAllText(tmpSrcFile, contents, UTF8);
|
||||
File.WriteAllText(tmpSrcFile, contents, utf8);
|
||||
try
|
||||
{
|
||||
FileUtils.MoveOrReplace(tmpSrcFile, dest);
|
||||
@@ -227,7 +227,7 @@ namespace Semmle.Extraction
|
||||
{
|
||||
// If this happened, it was probably because the same file was compiled multiple times.
|
||||
// In any case, this is not a fatal error.
|
||||
Logger.Log(Severity.Warning, "Problem archiving " + dest + ": " + ex);
|
||||
logger.Log(Severity.Warning, "Problem archiving " + dest + ": " + ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,13 +7,13 @@ namespace Semmle.Extraction
|
||||
/// </summary>
|
||||
public struct Tuple : ITrapEmitter
|
||||
{
|
||||
private readonly string Name;
|
||||
private readonly object[] Args;
|
||||
private readonly string name;
|
||||
private readonly object[] args;
|
||||
|
||||
public Tuple(string name, params object[] args)
|
||||
{
|
||||
Name = name;
|
||||
Args = args;
|
||||
this.name = name;
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -22,7 +22,7 @@ namespace Semmle.Extraction
|
||||
/// <param name="trapFile">The trap file to write to.</param>
|
||||
public void EmitTrap(TextWriter trapFile)
|
||||
{
|
||||
trapFile.WriteTuple(Name, Args);
|
||||
trapFile.WriteTuple(name, args);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
||||
@@ -96,15 +96,15 @@ namespace Semmle.Util
|
||||
length = Win32.GetFinalPathNameByHandle(hFile, outPath, outPath.Capacity, 0); // lgtm[cs/call-to-unmanaged-code]
|
||||
}
|
||||
|
||||
const int PREAMBLE = 4; // outPath always starts \\?\
|
||||
const int preamble = 4; // outPath always starts \\?\
|
||||
|
||||
if (length <= PREAMBLE)
|
||||
if (length <= preamble)
|
||||
{
|
||||
// Failed. GetFinalPathNameByHandle() failed somehow.
|
||||
return ConstructCanonicalPath(path, cache);
|
||||
}
|
||||
|
||||
var result = outPath.ToString(PREAMBLE, length - PREAMBLE); // Trim off leading \\?\
|
||||
var result = outPath.ToString(preamble, length - preamble); // Trim off leading \\?\
|
||||
|
||||
return result.StartsWith("UNC")
|
||||
? @"\" + result.Substring(3)
|
||||
|
||||
Reference in New Issue
Block a user