Skip to content

Commit 7075c6f

Browse files
committed
C#: Fix public property naming
1 parent a4fec39 commit 7075c6f

File tree

14 files changed

+180
-180
lines changed

14 files changed

+180
-180
lines changed

csharp/extractor/Semmle.Extraction.CIL/Context.cs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,30 @@ public sealed partial class Context : IDisposable
1717
private readonly FileStream stream;
1818
private Entities.Assembly? assemblyNull;
1919

20-
public Extraction.Context cx { get; }
21-
public MetadataReader mdReader { get; }
22-
public PEReader peReader { get; }
23-
public string assemblyPath { get; }
24-
public Entities.Assembly assembly
20+
public Extraction.Context Cx { get; }
21+
public MetadataReader MdReader { get; }
22+
public PEReader PeReader { get; }
23+
public string AssemblyPath { get; }
24+
public Entities.Assembly Assembly
2525
{
2626
get { return assemblyNull!; }
2727
set { assemblyNull = value; }
2828
}
29-
public PDB.IPdb? pdb { get; }
29+
public PDB.IPdb? Pdb { get; }
3030

3131
public Context(Extraction.Context cx, string assemblyPath, bool extractPdbs)
3232
{
33-
this.cx = cx;
34-
this.assemblyPath = assemblyPath;
33+
this.Cx = cx;
34+
this.AssemblyPath = assemblyPath;
3535
stream = File.OpenRead(assemblyPath);
36-
peReader = new PEReader(stream, PEStreamOptions.PrefetchEntireImage);
37-
mdReader = peReader.GetMetadataReader();
36+
PeReader = new PEReader(stream, PEStreamOptions.PrefetchEntireImage);
37+
MdReader = PeReader.GetMetadataReader();
3838
TypeSignatureDecoder = new Entities.TypeSignatureDecoder(this);
3939

4040
globalNamespace = new Lazy<Entities.Namespace>(() => Populate(new Entities.Namespace(this, "", null)));
4141
systemNamespace = new Lazy<Entities.Namespace>(() => Populate(new Entities.Namespace(this, "System")));
4242
genericHandleFactory = new CachedFunction<GenericContext, Handle, IExtractedEntity>(CreateGenericHandle);
43-
namespaceFactory = new CachedFunction<StringHandle, Entities.Namespace>(n => CreateNamespace(mdReader.GetString(n)));
43+
namespaceFactory = new CachedFunction<StringHandle, Entities.Namespace>(n => CreateNamespace(MdReader.GetString(n)));
4444
namespaceDefinitionFactory = new CachedFunction<NamespaceDefinitionHandle, Entities.Namespace>(CreateNamespace);
4545
sourceFiles = new CachedFunction<PDB.ISourceFile, Entities.PdbSourceFile>(path => new Entities.PdbSourceFile(this, path));
4646
folders = new CachedFunction<PathTransformer.ITransformedPath, Entities.Folder>(path => new Entities.Folder(this, path));
@@ -50,8 +50,8 @@ public Context(Extraction.Context cx, string assemblyPath, bool extractPdbs)
5050

5151
if (extractPdbs)
5252
{
53-
pdb = PDB.PdbReader.Create(assemblyPath, peReader);
54-
if (pdb != null)
53+
Pdb = PDB.PdbReader.Create(assemblyPath, PeReader);
54+
if (Pdb != null)
5555
{
5656
cx.Extractor.Logger.Log(Util.Logging.Severity.Info, string.Format("Found PDB information for {0}", assemblyPath));
5757
}
@@ -60,9 +60,9 @@ public Context(Extraction.Context cx, string assemblyPath, bool extractPdbs)
6060

6161
public void Dispose()
6262
{
63-
if (pdb != null)
64-
pdb.Dispose();
65-
peReader.Dispose();
63+
if (Pdb != null)
64+
Pdb.Dispose();
65+
PeReader.Dispose();
6666
stream.Dispose();
6767
}
6868

@@ -80,7 +80,7 @@ public void Extract(IExtractedEntity entity)
8080

8181
public void WriteAssemblyPrefix(TextWriter trapFile)
8282
{
83-
var def = mdReader.GetAssemblyDefinition();
83+
var def = MdReader.GetAssemblyDefinition();
8484
trapFile.Write(GetString(def.Name));
8585
trapFile.Write('_');
8686
trapFile.Write(def.Version.ToString());
@@ -113,7 +113,7 @@ public Entities.Type ErrorType
113113
/// <returns>The debugging information, or null if the information could not be located.</returns>
114114
public PDB.IMethod? GetMethodDebugInformation(MethodDefinitionHandle handle)
115115
{
116-
return pdb?.GetMethod(handle.ToDebugInformationHandle());
116+
return Pdb?.GetMethod(handle.ToDebugInformationHandle());
117117
}
118118
}
119119

@@ -123,11 +123,11 @@ public Entities.Type ErrorType
123123
/// </summary>
124124
public abstract class GenericContext
125125
{
126-
public Context cx { get; }
126+
public Context Cx { get; }
127127

128128
protected GenericContext(Context cx)
129129
{
130-
this.cx = cx;
130+
this.Cx = cx;
131131
}
132132

133133
/// <summary>

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

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,27 @@ public class Assembly : LabelledEntity, IAssembly
2727

2828
public Assembly(Context cx) : base(cx)
2929
{
30-
cx.assembly = this;
31-
var def = cx.mdReader.GetAssemblyDefinition();
30+
cx.Assembly = this;
31+
var def = cx.MdReader.GetAssemblyDefinition();
3232

3333
assemblyName = new AssemblyName
3434
{
35-
Name = cx.mdReader.GetString(def.Name),
35+
Name = cx.MdReader.GetString(def.Name),
3636
Version = def.Version,
37-
CultureInfo = new CultureInfo(cx.mdReader.GetString(def.Culture))
37+
CultureInfo = new CultureInfo(cx.MdReader.GetString(def.Culture))
3838
};
3939

4040
if (!def.PublicKey.IsNil)
41-
assemblyName.SetPublicKey(cx.mdReader.GetBlobBytes(def.PublicKey));
41+
assemblyName.SetPublicKey(cx.MdReader.GetBlobBytes(def.PublicKey));
4242

43-
file = new File(cx, cx.assemblyPath);
43+
file = new File(cx, cx.AssemblyPath);
4444
}
4545

4646
public override void WriteId(TextWriter trapFile)
4747
{
4848
trapFile.Write(FullName);
4949
trapFile.Write("#file:///");
50-
trapFile.Write(cx.assemblyPath.Replace("\\", "/"));
50+
trapFile.Write(Cx.AssemblyPath.Replace("\\", "/"));
5151
}
5252

5353
public override bool Equals(object? obj)
@@ -68,41 +68,41 @@ public override IEnumerable<IExtractionProduct> Contents
6868
yield return file;
6969
yield return Tuples.assemblies(this, file, FullName, assemblyName.Name ?? string.Empty, assemblyName.Version?.ToString() ?? string.Empty);
7070

71-
if (cx.pdb != null)
71+
if (Cx.Pdb != null)
7272
{
73-
foreach (var f in cx.pdb.SourceFiles)
73+
foreach (var f in Cx.Pdb.SourceFiles)
7474
{
75-
yield return cx.CreateSourceFile(f);
75+
yield return Cx.CreateSourceFile(f);
7676
}
7777
}
7878

79-
foreach (var handle in cx.mdReader.TypeDefinitions)
79+
foreach (var handle in Cx.MdReader.TypeDefinitions)
8080
{
8181
IExtractionProduct? product = null;
8282
try
8383
{
84-
product = cx.Create(handle);
84+
product = Cx.Create(handle);
8585
}
8686
catch (InternalError e)
8787
{
88-
cx.cx.ExtractionError("Error processing type definition", e.Message, GeneratedLocation.Create(cx.cx), e.StackTrace);
88+
Cx.Cx.ExtractionError("Error processing type definition", e.Message, GeneratedLocation.Create(Cx.Cx), e.StackTrace);
8989
}
9090

9191
// Limitation of C#: Cannot yield return inside a try-catch.
9292
if (product != null)
9393
yield return product;
9494
}
9595

96-
foreach (var handle in cx.mdReader.MethodDefinitions)
96+
foreach (var handle in Cx.MdReader.MethodDefinitions)
9797
{
9898
IExtractionProduct? product = null;
9999
try
100100
{
101-
product = cx.Create(handle);
101+
product = Cx.Create(handle);
102102
}
103103
catch (InternalError e)
104104
{
105-
cx.cx.ExtractionError("Error processing bytecode", e.Message, GeneratedLocation.Create(cx.cx), e.StackTrace);
105+
Cx.Cx.ExtractionError("Error processing bytecode", e.Message, GeneratedLocation.Create(Cx.Cx), e.StackTrace);
106106
}
107107

108108
if (product != null)
@@ -115,7 +115,7 @@ private static void ExtractCIL(Extraction.Context cx, string assemblyPath, bool
115115
{
116116
using var cilContext = new Context(cx, assemblyPath, extractPdbs);
117117
cilContext.Populate(new Assembly(cilContext));
118-
cilContext.cx.PopulateAll();
118+
cilContext.Cx.PopulateAll();
119119
}
120120

121121
/// <summary>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ internal sealed class Attribute : UnlabelledEntity, IAttribute
2222

2323
public Attribute(Context cx, IEntity @object, CustomAttributeHandle handle) : base(cx)
2424
{
25-
attrib = cx.mdReader.GetCustomAttribute(handle);
25+
attrib = cx.MdReader.GetCustomAttribute(handle);
2626
this.handle = handle;
2727
this.@object = @object;
2828
}
@@ -38,7 +38,7 @@ public override IEnumerable<IExtractionProduct> Contents
3838
{
3939
get
4040
{
41-
var constructor = (Method)cx.Create(attrib.Constructor);
41+
var constructor = (Method)Cx.Create(attrib.Constructor);
4242
yield return constructor;
4343

4444
yield return Tuples.cil_attribute(this, @object, constructor);
@@ -47,7 +47,7 @@ public override IEnumerable<IExtractionProduct> Contents
4747

4848
try
4949
{
50-
decoded = attrib.DecodeValue(new CustomAttributeDecoder(cx));
50+
decoded = attrib.DecodeValue(new CustomAttributeDecoder(Cx));
5151
}
5252
catch (NotImplementedException)
5353
{

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ public Event(Context cx, Type parent, EventDefinitionHandle handle) : base(cx)
2424
{
2525
this.handle = handle;
2626
this.parent = parent;
27-
ed = cx.mdReader.GetEventDefinition(handle);
27+
ed = cx.MdReader.GetEventDefinition(handle);
2828
}
2929

3030
public override void WriteId(TextWriter trapFile)
3131
{
3232
parent.WriteId(trapFile);
3333
trapFile.Write('.');
34-
trapFile.Write(cx.ShortName(ed.Name));
34+
trapFile.Write(Cx.ShortName(ed.Name));
3535
}
3636

3737
public override string IdSuffix => ";cil-event";
@@ -47,34 +47,34 @@ public override IEnumerable<IExtractionProduct> Contents
4747
{
4848
get
4949
{
50-
var signature = (Type)cx.CreateGeneric(parent, ed.Type);
50+
var signature = (Type)Cx.CreateGeneric(parent, ed.Type);
5151
yield return signature;
5252

53-
yield return Tuples.cil_event(this, parent, cx.ShortName(ed.Name), signature);
53+
yield return Tuples.cil_event(this, parent, Cx.ShortName(ed.Name), signature);
5454

5555
var accessors = ed.GetAccessors();
5656
if (!accessors.Adder.IsNil)
5757
{
58-
var adder = (Method)cx.CreateGeneric(parent, accessors.Adder);
58+
var adder = (Method)Cx.CreateGeneric(parent, accessors.Adder);
5959
yield return adder;
6060
yield return Tuples.cil_adder(this, adder);
6161
}
6262

6363
if (!accessors.Remover.IsNil)
6464
{
65-
var remover = (Method)cx.CreateGeneric(parent, accessors.Remover);
65+
var remover = (Method)Cx.CreateGeneric(parent, accessors.Remover);
6666
yield return remover;
6767
yield return Tuples.cil_remover(this, remover);
6868
}
6969

7070
if (!accessors.Raiser.IsNil)
7171
{
72-
var raiser = (Method)cx.CreateGeneric(parent, accessors.Raiser);
72+
var raiser = (Method)Cx.CreateGeneric(parent, accessors.Raiser);
7373
yield return raiser;
7474
yield return Tuples.cil_raiser(this, raiser);
7575
}
7676

77-
foreach (var c in Attribute.Populate(cx, this, ed.GetCustomAttributes()))
77+
foreach (var c in Attribute.Populate(Cx, this, ed.GetCustomAttributes()))
7878
yield return c;
7979
}
8080
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ internal class ExceptionRegion : UnlabelledEntity, IExceptionRegion
1717
private readonly System.Reflection.Metadata.ExceptionRegion r;
1818
private readonly Dictionary<int, IInstruction> jump_table;
1919

20-
public ExceptionRegion(GenericContext gc, MethodImplementation method, int index, System.Reflection.Metadata.ExceptionRegion r, Dictionary<int, IInstruction> jump_table) : base(gc.cx)
20+
public ExceptionRegion(GenericContext gc, MethodImplementation method, int index, System.Reflection.Metadata.ExceptionRegion r, Dictionary<int, IInstruction> jump_table) : base(gc.Cx)
2121
{
2222
this.gc = gc;
2323
this.method = method;
@@ -50,7 +50,7 @@ public override IEnumerable<IExtractionProduct> Contents
5050

5151
if (!r.CatchType.IsNil)
5252
{
53-
var catchType = (Type)cx.CreateGeneric(gc, r.CatchType);
53+
var catchType = (Type)Cx.CreateGeneric(gc, r.CatchType);
5454
yield return catchType;
5555
yield return Tuples.cil_handler_type(this, catchType);
5656
}

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ internal sealed class DefinitionField : Field
8181
private readonly Handle handle;
8282
private readonly FieldDefinition fd;
8383

84-
public DefinitionField(GenericContext gc, FieldDefinitionHandle handle) : base(gc.cx)
84+
public DefinitionField(GenericContext gc, FieldDefinitionHandle handle) : base(gc.Cx)
8585
{
8686
this.handle = handle;
87-
fd = cx.mdReader.GetFieldDefinition(handle);
87+
fd = Cx.MdReader.GetFieldDefinition(handle);
8888
}
8989

9090
public override bool Equals(object? obj)
@@ -98,7 +98,7 @@ public override IEnumerable<IExtractionProduct> Contents
9898
{
9999
get
100100
{
101-
yield return Tuples.metadata_handle(this, cx.assembly, MetadataTokens.GetToken(handle));
101+
yield return Tuples.metadata_handle(this, Cx.Assembly, MetadataTokens.GetToken(handle));
102102

103103
foreach (var c in base.Contents)
104104
yield return c;
@@ -118,16 +118,16 @@ public override IEnumerable<IExtractionProduct> Contents
118118
if (fd.Attributes.HasFlag(FieldAttributes.Assembly))
119119
yield return Tuples.cil_internal(this);
120120

121-
foreach (var c in Attribute.Populate(cx, this, fd.GetCustomAttributes()))
121+
foreach (var c in Attribute.Populate(Cx, this, fd.GetCustomAttributes()))
122122
yield return c;
123123
}
124124
}
125125

126-
public override string Name => cx.GetString(fd.Name);
126+
public override string Name => Cx.GetString(fd.Name);
127127

128-
public override Type DeclaringType => (Type)cx.Create(fd.GetDeclaringType());
128+
public override Type DeclaringType => (Type)Cx.Create(fd.GetDeclaringType());
129129

130-
public override Type Type => fd.DecodeSignature(cx.TypeSignatureDecoder, DeclaringType);
130+
public override Type Type => fd.DecodeSignature(Cx.TypeSignatureDecoder, DeclaringType);
131131

132132
public override IEnumerable<Type> TypeParameters => throw new NotImplementedException();
133133

@@ -141,12 +141,12 @@ internal sealed class MemberReferenceField : Field
141141
private readonly GenericContext gc;
142142
private readonly Type declType;
143143

144-
public MemberReferenceField(GenericContext gc, MemberReferenceHandle handle) : base(gc.cx)
144+
public MemberReferenceField(GenericContext gc, MemberReferenceHandle handle) : base(gc.Cx)
145145
{
146146
this.handle = handle;
147147
this.gc = gc;
148-
mr = cx.mdReader.GetMemberReference(handle);
149-
declType = (Type)cx.CreateGeneric(gc, mr.Parent);
148+
mr = Cx.MdReader.GetMemberReference(handle);
149+
declType = (Type)Cx.CreateGeneric(gc, mr.Parent);
150150
}
151151

152152
public override bool Equals(object? obj)
@@ -159,11 +159,11 @@ public override int GetHashCode()
159159
return handle.GetHashCode();
160160
}
161161

162-
public override string Name => cx.GetString(mr.Name);
162+
public override string Name => Cx.GetString(mr.Name);
163163

164164
public override Type DeclaringType => declType;
165165

166-
public override Type Type => mr.DecodeFieldSignature(cx.TypeSignatureDecoder, this);
166+
public override Type Type => mr.DecodeFieldSignature(Cx.TypeSignatureDecoder, this);
167167

168168
public override IEnumerable<Type> TypeParameters => gc.TypeParameters.Concat(declType.TypeParameters);
169169

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class File : LabelledEntity, IFile
1919
public File(Context cx, string path) : base(cx)
2020
{
2121
this.OriginalPath = path;
22-
TransformedPath = cx.cx.Extractor.PathTransformer.Transform(OriginalPath);
22+
TransformedPath = cx.Cx.Extractor.PathTransformer.Transform(OriginalPath);
2323
}
2424

2525
public override void WriteId(TextWriter trapFile)
@@ -40,7 +40,7 @@ public override IEnumerable<IExtractionProduct> Contents
4040
{
4141
if (TransformedPath.ParentDirectory is PathTransformer.ITransformedPath dir)
4242
{
43-
var parent = cx.CreateFolder(dir);
43+
var parent = Cx.CreateFolder(dir);
4444
yield return parent;
4545
yield return Tuples.containerparent(parent, this);
4646
}
@@ -70,9 +70,9 @@ public override IEnumerable<IExtractionProduct> Contents
7070
var text = file.Contents;
7171

7272
if (text == null)
73-
cx.cx.Extractor.Logger.Log(Util.Logging.Severity.Warning, string.Format("PDB source file {0} could not be found", OriginalPath));
73+
Cx.Cx.Extractor.Logger.Log(Util.Logging.Severity.Warning, string.Format("PDB source file {0} could not be found", OriginalPath));
7474
else
75-
cx.cx.TrapWriter.Archive(TransformedPath, text);
75+
Cx.Cx.TrapWriter.Archive(TransformedPath, text);
7676

7777
yield return Tuples.file_extraction_mode(this, 2);
7878
}

0 commit comments

Comments
 (0)