Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2e350ca

Browse files
committed
C#: Fix private field and local variable naming
1 parent ecb29a2 commit 2e350ca

32 files changed

Lines changed: 673 additions & 673 deletions

File tree

csharp/autobuilder/Semmle.Autobuild.CSharp.Tests/BuildScripts.cs

Lines changed: 414 additions & 414 deletions
Large diffs are not rendered by default.

csharp/autobuilder/Semmle.Autobuild.Shared/BuildScript.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -228,19 +228,19 @@ public static BuildScript Bind(BuildScript s1, Func<int, BuildScript> s2) =>
228228
public static BuildScript Bind(BuildScript s1, Func<IList<string>, int, BuildScript> s2) =>
229229
new BindBuildScript(s1, s2);
230230

231-
private const int SuccessCode = 0;
231+
private const int successCode = 0;
232232
/// <summary>
233233
/// The empty build script that always returns exit code 0.
234234
/// </summary>
235-
public static readonly BuildScript Success = Create(actions => SuccessCode);
235+
public static readonly BuildScript Success = Create(actions => successCode);
236236

237-
private const int FailureCode = 1;
237+
private const int failureCode = 1;
238238
/// <summary>
239239
/// The empty build script that always returns exit code 1.
240240
/// </summary>
241-
public static readonly BuildScript Failure = Create(actions => FailureCode);
241+
public static readonly BuildScript Failure = Create(actions => failureCode);
242242

243-
private static bool Succeeded(int i) => i == SuccessCode;
243+
private static bool Succeeded(int i) => i == successCode;
244244

245245
public static BuildScript operator &(BuildScript s1, BuildScript s2) =>
246246
new BindBuildScript(s1, ret1 => Succeeded(ret1) ? s2 : Create(actions => ret1));
@@ -267,17 +267,17 @@ public static BuildScript DeleteDirectory(string dir) =>
267267
Create(actions =>
268268
{
269269
if (string.IsNullOrEmpty(dir) || !actions.DirectoryExists(dir))
270-
return FailureCode;
270+
return failureCode;
271271

272272
try
273273
{
274274
actions.DirectoryDelete(dir, true);
275275
}
276276
catch // lgtm[cs/catch-of-all-exceptions]
277277
{
278-
return FailureCode;
278+
return failureCode;
279279
}
280-
return SuccessCode;
280+
return successCode;
281281
});
282282

283283
/// <summary>
@@ -287,17 +287,17 @@ public static BuildScript DeleteFile(string file) =>
287287
Create(actions =>
288288
{
289289
if (string.IsNullOrEmpty(file) || !actions.FileExists(file))
290-
return FailureCode;
290+
return failureCode;
291291

292292
try
293293
{
294294
actions.FileDelete(file);
295295
}
296296
catch // lgtm[cs/catch-of-all-exceptions]
297297
{
298-
return FailureCode;
298+
return failureCode;
299299
}
300-
return SuccessCode;
300+
return successCode;
301301
});
302302
}
303303
}

csharp/autobuilder/Semmle.Autobuild.Shared/MsBuildRule.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class MsBuildRule : IBuildRule
1111
/// <summary>
1212
/// The name of the msbuild command.
1313
/// </summary>
14-
private const string MsBuild = "msbuild";
14+
private const string msBuild = "msbuild";
1515

1616
public BuildScript Analyse(Autobuilder builder, bool auto)
1717
{
@@ -57,7 +57,7 @@ BuildScript GetNugetRestoreScript() =>
5757
Script;
5858
var nugetRestore = GetNugetRestoreScript();
5959
var msbuildRestoreCommand = new CommandBuilder(builder.Actions).
60-
RunCommand(MsBuild).
60+
RunCommand(msBuild).
6161
Argument("/t:restore").
6262
QuoteArgument(projectOrSolution.FullPath);
6363

@@ -95,7 +95,7 @@ BuildScript GetNugetRestoreScript() =>
9595
command.RunCommand("set Platform=&& type NUL", quoteExe: false);
9696
}
9797

98-
builder.MaybeIndex(command, MsBuild);
98+
builder.MaybeIndex(command, msBuild);
9999
command.QuoteArgument(projectOrSolution.FullPath);
100100

101101
command.Argument("/p:UseSharedCompilation=false");

csharp/extractor/Semmle.Extraction.CIL/Entities/Field.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ public void WriteQuotedId(TextWriter trapFile)
4646
{
4747
trapFile.Write("@\"");
4848
WriteId(trapFile);
49-
trapFile.Write(IdSuffix);
49+
trapFile.Write(idSuffix);
5050
trapFile.Write('\"');
5151
}
5252

53-
private const string IdSuffix = ";cil-field";
53+
private const string idSuffix = ";cil-field";
5454

5555
public abstract string Name { get; }
5656

@@ -136,27 +136,27 @@ public override IEnumerable<IExtractionProduct> Contents
136136

137137
internal sealed class MemberReferenceField : Field
138138
{
139-
private readonly MemberReferenceHandle Handle;
139+
private readonly MemberReferenceHandle handle;
140140
private readonly MemberReference mr;
141141
private readonly GenericContext gc;
142142
private readonly Type declType;
143143

144144
public MemberReferenceField(GenericContext gc, MemberReferenceHandle handle) : base(gc.cx)
145145
{
146-
Handle = handle;
146+
this.handle = handle;
147147
this.gc = gc;
148148
mr = cx.mdReader.GetMemberReference(handle);
149149
declType = (Type)cx.CreateGeneric(gc, mr.Parent);
150150
}
151151

152152
public override bool Equals(object? obj)
153153
{
154-
return obj is MemberReferenceField field && Handle.Equals(field.Handle);
154+
return obj is MemberReferenceField field && handle.Equals(field.handle);
155155
}
156156

157157
public override int GetHashCode()
158158
{
159-
return Handle.GetHashCode();
159+
return handle.GetHashCode();
160160
}
161161

162162
public override string Name => cx.GetString(mr.Name);

csharp/extractor/Semmle.Extraction.CIL/Entities/Folder.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ internal interface IFolder : IFileOrFolder
99

1010
public sealed class Folder : LabelledEntity, IFolder
1111
{
12-
private readonly PathTransformer.ITransformedPath TransformedPath;
12+
private readonly PathTransformer.ITransformedPath transformedPath;
1313

1414
public Folder(Context cx, PathTransformer.ITransformedPath path) : base(cx)
1515
{
16-
this.TransformedPath = path;
16+
this.transformedPath = path;
1717
}
1818

1919
public override void WriteId(TextWriter trapFile)
2020
{
21-
trapFile.Write(TransformedPath.DatabaseId);
21+
trapFile.Write(transformedPath.DatabaseId);
2222
}
2323

2424
public override string IdSuffix => ";folder";
@@ -27,21 +27,21 @@ public override IEnumerable<IExtractionProduct> Contents
2727
{
2828
get
2929
{
30-
if (TransformedPath.ParentDirectory is PathTransformer.ITransformedPath parent)
30+
if (transformedPath.ParentDirectory is PathTransformer.ITransformedPath parent)
3131
{
3232
var parentFolder = cx.CreateFolder(parent);
3333
yield return parentFolder;
3434
yield return Tuples.containerparent(parentFolder, this);
3535
}
36-
yield return Tuples.folders(this, TransformedPath.Value, TransformedPath.NameWithoutExtension);
36+
yield return Tuples.folders(this, transformedPath.Value, transformedPath.NameWithoutExtension);
3737
}
3838
}
3939

4040
public override bool Equals(object? obj)
4141
{
42-
return obj is Folder folder && TransformedPath == folder.TransformedPath;
42+
return obj is Folder folder && transformedPath == folder.transformedPath;
4343
}
4444

45-
public override int GetHashCode() => TransformedPath.GetHashCode();
45+
public override int GetHashCode() => transformedPath.GetHashCode();
4646
}
4747
}

csharp/extractor/Semmle.Extraction.CIL/Entities/Instruction.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,8 @@ public enum Payload
272272
public readonly ILOpCode OpCode;
273273
public readonly int Offset;
274274
public readonly int Index;
275-
private readonly int PayloadValue;
276-
private readonly uint UnsignedPayloadValue;
275+
private readonly int payloadValue;
276+
private readonly uint unsignedPayloadValue;
277277

278278
public Payload PayloadType
279279
{
@@ -296,7 +296,7 @@ public int Width
296296
get
297297
{
298298
if (OpCode == ILOpCode.Switch)
299-
return 5 + 4 * PayloadValue;
299+
return 5 + 4 * payloadValue;
300300

301301
return ((int)OpCode > 255 ? 2 : 1) + PayloadSize;
302302
}
@@ -337,19 +337,19 @@ public Instruction(Context cx, DefinitionMethod method, byte[] data, int offset,
337337
switch (PayloadSize)
338338
{
339339
case 0:
340-
PayloadValue = 0;
340+
payloadValue = 0;
341341
break;
342342
case 1:
343-
PayloadValue = (sbyte)data[offset];
344-
UnsignedPayloadValue = data[offset];
343+
payloadValue = (sbyte)data[offset];
344+
unsignedPayloadValue = data[offset];
345345
break;
346346
case 2:
347-
PayloadValue = BitConverter.ToInt16(data, offset);
348-
UnsignedPayloadValue = BitConverter.ToUInt16(data, offset);
347+
payloadValue = BitConverter.ToInt16(data, offset);
348+
unsignedPayloadValue = BitConverter.ToUInt16(data, offset);
349349
break;
350350
case -1: // Switch
351351
case 4:
352-
PayloadValue = BitConverter.ToInt32(data, offset);
352+
payloadValue = BitConverter.ToInt32(data, offset);
353353
break;
354354
case 8: // Not handled here.
355355
break;
@@ -374,7 +374,7 @@ public override IEnumerable<IExtractionProduct> Contents
374374
switch (PayloadType)
375375
{
376376
case Payload.String:
377-
yield return Tuples.cil_value(this, cx.mdReader.GetUserString(MetadataTokens.UserStringHandle(PayloadValue)));
377+
yield return Tuples.cil_value(this, cx.mdReader.GetUserString(MetadataTokens.UserStringHandle(payloadValue)));
378378
break;
379379
case Payload.Float32:
380380
yield return Tuples.cil_value(this, BitConverter.ToSingle(data, offset).ToString());
@@ -404,7 +404,7 @@ public override IEnumerable<IExtractionProduct> Contents
404404
case Payload.Field:
405405
case Payload.ValueType:
406406
// A generic EntityHandle.
407-
var handle = MetadataTokens.EntityHandle(PayloadValue);
407+
var handle = MetadataTokens.EntityHandle(payloadValue);
408408
var target = cx.CreateGeneric(Method, handle);
409409
yield return target;
410410
if (target != null)
@@ -420,14 +420,14 @@ public override IEnumerable<IExtractionProduct> Contents
420420
case Payload.Arg16:
421421
if (Method.Parameters is object)
422422
{
423-
yield return Tuples.cil_access(this, Method.Parameters[(int)UnsignedPayloadValue]);
423+
yield return Tuples.cil_access(this, Method.Parameters[(int)unsignedPayloadValue]);
424424
}
425425
break;
426426
case Payload.Local8:
427427
case Payload.Local16:
428428
if (Method.LocalVariables is object)
429429
{
430-
yield return Tuples.cil_access(this, Method.LocalVariables[(int)UnsignedPayloadValue]);
430+
yield return Tuples.cil_access(this, Method.LocalVariables[(int)unsignedPayloadValue]);
431431
}
432432
break;
433433
case Payload.None:
@@ -454,17 +454,17 @@ public IEnumerable<IExtractionProduct> JumpContents(Dictionary<int, IInstruction
454454
switch (PayloadType)
455455
{
456456
case Payload.Target8:
457-
target = Offset + PayloadValue + 2;
457+
target = Offset + payloadValue + 2;
458458
break;
459459
case Payload.Target32:
460-
target = Offset + PayloadValue + 5;
460+
target = Offset + payloadValue + 5;
461461
break;
462462
case Payload.Switch:
463463
var end = Offset + Width;
464464

465465
var offset = Offset + 5;
466466

467-
for (var b = 0; b < PayloadValue; ++b, offset += 4)
467+
for (var b = 0; b < payloadValue; ++b, offset += 4)
468468
{
469469
target = BitConverter.ToInt32(data, offset) + end;
470470
if (jump_table.TryGetValue(target, out inst))

csharp/extractor/Semmle.Extraction.CSharp.Standalone/BuildAnalysis.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ public BuildAnalysis(Options options, IProgressMonitor progress)
7878
.ToArray();
7979

8080
var dllDirNames = options.DllDirs.Select(Path.GetFullPath).ToList();
81-
PackageDirectory = new TemporaryDirectory(ComputeTempDirectory(sourceDir.FullName));
81+
packageDirectory = new TemporaryDirectory(ComputeTempDirectory(sourceDir.FullName));
8282

8383
if (options.UseNuGet)
8484
{
8585
try
8686
{
87-
var nuget = new NugetPackages(sourceDir.FullName, PackageDirectory);
87+
var nuget = new NugetPackages(sourceDir.FullName, packageDirectory);
8888
nuget.InstallPackages(progressMonitor);
8989
}
9090
catch (FileNotFoundException)
@@ -110,7 +110,7 @@ public BuildAnalysis(Options options, IProgressMonitor progress)
110110
sourceDir.GetFiles("*.sln", SearchOption.AllDirectories).Select(d => d.FullName);
111111

112112
RestoreSolutions(solutions);
113-
dllDirNames.Add(PackageDirectory.DirInfo.FullName);
113+
dllDirNames.Add(packageDirectory.DirInfo.FullName);
114114
assemblyCache = new BuildAnalyser.AssemblyCache(dllDirNames, progress);
115115
AnalyseSolutions(solutions);
116116

@@ -268,7 +268,7 @@ private void UnresolvedReference(string id, string projectFile)
268268
unresolvedReferences[id] = projectFile;
269269
}
270270

271-
private readonly TemporaryDirectory PackageDirectory;
271+
private readonly TemporaryDirectory packageDirectory;
272272

273273
/// <summary>
274274
/// Reads all the source files and references from the given list of projects.
@@ -325,7 +325,7 @@ private void AnalyseProject(FileInfo project)
325325

326326
private void Restore(string projectOrSolution)
327327
{
328-
var exit = DotNet.RestoreToDirectory(projectOrSolution, PackageDirectory.DirInfo.FullName);
328+
var exit = DotNet.RestoreToDirectory(projectOrSolution, packageDirectory.DirInfo.FullName);
329329
switch (exit)
330330
{
331331
case 0:
@@ -362,7 +362,7 @@ public void AnalyseSolutions(IEnumerable<string> solutions)
362362

363363
public void Dispose()
364364
{
365-
PackageDirectory?.Dispose();
365+
packageDirectory?.Dispose();
366366
}
367367
}
368368
}

csharp/extractor/Semmle.Extraction.CSharp/Entities/Attribute.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,27 @@ internal class Attribute : FreshEntity, IExpressionParentEntity
99
{
1010
bool IExpressionParentEntity.IsTopLevelParent => true;
1111

12-
private readonly AttributeData AttributeData;
13-
private readonly IEntity Entity;
12+
private readonly AttributeData attribute;
13+
private readonly IEntity entity;
1414

1515
public Attribute(Context cx, AttributeData attribute, IEntity entity)
1616
: base(cx)
1717
{
18-
AttributeData = attribute;
19-
Entity = entity;
18+
this.attribute = attribute;
19+
this.entity = entity;
2020
TryPopulate();
2121
}
2222

2323
protected override void Populate(TextWriter trapFile)
2424
{
25-
if (AttributeData.ApplicationSyntaxReference != null)
25+
if (attribute.ApplicationSyntaxReference != null)
2626
{
2727
// !! Extract attributes from assemblies.
2828
// This is harder because the "expression" entities presume the
2929
// existence of a syntax tree. This is not the case for compiled
3030
// attributes.
31-
var syntax = AttributeData.ApplicationSyntaxReference.GetSyntax() as AttributeSyntax;
32-
ExtractAttribute(cx.TrapWriter.Writer, syntax, AttributeData.AttributeClass, Entity);
31+
var syntax = attribute.ApplicationSyntaxReference.GetSyntax() as AttributeSyntax;
32+
ExtractAttribute(cx.TrapWriter.Writer, syntax, attribute.AttributeClass, entity);
3333
}
3434
}
3535

0 commit comments

Comments
 (0)