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

Skip to content

Commit cbdd131

Browse files
committed
C#: Convert publicly visible fields to properties
1 parent d5382f2 commit cbdd131

25 files changed

Lines changed: 119 additions & 109 deletions

File tree

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

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,24 @@ namespace Semmle.Autobuild.Shared
99
/// </summary>
1010
public class AutobuildOptions
1111
{
12-
public readonly int SearchDepth = 3;
13-
public readonly string RootDirectory;
1412
private const string prefix = "LGTM_INDEX_";
1513

16-
public readonly string? VsToolsVersion;
17-
public readonly string? MsBuildArguments;
18-
public readonly string? MsBuildPlatform;
19-
public readonly string? MsBuildConfiguration;
20-
public readonly string? MsBuildTarget;
21-
public readonly string? DotNetArguments;
22-
public readonly string? DotNetVersion;
23-
public readonly string? BuildCommand;
24-
public readonly string[] Solution;
25-
26-
public readonly bool IgnoreErrors;
27-
public readonly bool Buildless;
28-
public readonly bool AllSolutions;
29-
public readonly bool NugetRestore;
30-
31-
public readonly Language Language;
14+
public int SearchDepth { get; } = 3;
15+
public string RootDirectory { get; }
16+
public string? VsToolsVersion { get; }
17+
public string? MsBuildArguments { get; }
18+
public string? MsBuildPlatform { get; }
19+
public string? MsBuildConfiguration { get; }
20+
public string? MsBuildTarget { get; }
21+
public string? DotNetArguments { get; }
22+
public string? DotNetVersion { get; }
23+
public string? BuildCommand { get; }
24+
public string[] Solution { get; }
25+
public bool IgnoreErrors { get; }
26+
public bool Buildless { get; }
27+
public bool AllSolutions { get; }
28+
public bool NugetRestore { get; }
29+
public Language Language { get; }
3230

3331
/// <summary>
3432
/// Reads options from environment variables.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ namespace Semmle.Autobuild.Shared
99
/// </summary>
1010
public class VcVarsBatFile
1111
{
12-
public readonly int ToolsVersion;
13-
public readonly string Path;
12+
public int ToolsVersion { get; }
13+
public string Path { get; }
1414

1515
public VcVarsBatFile(string path, int version)
1616
{

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
{
33
public sealed class Language
44
{
5-
public static readonly Language Cpp = new Language(".vcxproj", "CPP");
6-
public static readonly Language CSharp = new Language(".csproj", "CSHARP");
5+
public static Language Cpp { get; } = new Language(".vcxproj", "CPP");
6+
public static Language CSharp { get; } = new Language(".csproj", "CSHARP");
77

88
public bool ProjectFileHasThisLanguage(string path) =>
99
System.IO.Path.GetExtension(path) == ProjectExtension;
1010

11-
public readonly string ProjectExtension;
12-
public readonly string UpperCaseName;
11+
public string ProjectExtension { get; }
12+
public string UpperCaseName { get; }
1313

1414
private Language(string extension, string name)
1515
{

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public void WriteAssemblyPrefix(TextWriter trapFile)
8787
trapFile.Write("::");
8888
}
8989

90-
public readonly Entities.TypeSignatureDecoder TypeSignatureDecoder;
90+
public Entities.TypeSignatureDecoder TypeSignatureDecoder { get; }
9191

9292
/// <summary>
9393
/// A type used to signify something we can't handle yet.
@@ -123,7 +123,7 @@ public Entities.Type ErrorType
123123
/// </summary>
124124
public abstract class GenericContext
125125
{
126-
public Context cx;
126+
public Context cx { get; }
127127

128128
protected GenericContext(Context cx)
129129
{

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ internal interface IFile : IFileOrFolder
1313

1414
public class File : LabelledEntity, IFile
1515
{
16-
protected readonly string OriginalPath;
17-
protected readonly PathTransformer.ITransformedPath TransformedPath;
16+
protected string OriginalPath { get; }
17+
protected PathTransformer.ITransformedPath TransformedPath { get; }
1818

1919
public File(Context cx, string path) : base(cx)
2020
{

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ internal interface INamespace : ITypeContainer
1616
/// </summary>
1717
public sealed class Namespace : TypeContainer, INamespace
1818
{
19-
public Namespace? ParentNamespace;
20-
public readonly string Name;
19+
public Namespace? ParentNamespace { get; }
20+
public string Name { get; }
2121

2222
public bool IsGlobalNamespace => ParentNamespace is null;
2323

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ public abstract class TypeContainer : GenericContext, ITypeContainer
5050
{
5151
protected TypeContainer(Context cx) : base(cx)
5252
{
53-
this.cx = cx;
5453
}
5554

5655
public virtual Label Label { get; set; }

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public virtual void Extract(Context cx2)
6363
cx2.Extract(this);
6464
}
6565

66-
public readonly Context cx;
66+
public Context cx { get; }
6767

6868
protected UnlabelledEntity(Context cx)
6969
{
@@ -101,7 +101,7 @@ public void Extract(Context cx2)
101101
cx2.Populate(this);
102102
}
103103

104-
public readonly Context cx;
104+
public Context cx { get; }
105105

106106
protected LabelledEntity(Context cx)
107107
{

csharp/extractor/Semmle.Extraction.CIL/PDB/PdbReader.cs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ public struct SequencePoint
1515
/// <summary>
1616
/// The byte-offset of the instruction.
1717
/// </summary>
18-
public readonly int Offset;
18+
public int Offset { get; }
1919

2020
/// <summary>
2121
/// The source location of the instruction.
2222
/// </summary>
23-
public readonly Location Location;
23+
public Location Location { get; }
2424

2525
public override string ToString()
2626
{
@@ -42,12 +42,27 @@ public sealed class Location
4242
/// <summary>
4343
/// The file containing the code.
4444
/// </summary>
45-
public readonly ISourceFile File;
45+
public ISourceFile File { get; }
4646

4747
/// <summary>
48-
/// The span of text within the text file.
48+
/// The start line of text within the source file.
4949
/// </summary>
50-
public readonly int StartLine, StartColumn, EndLine, EndColumn;
50+
public int StartLine { get; }
51+
52+
/// <summary>
53+
/// The start column of text within the source file.
54+
/// </summary>
55+
public int StartColumn { get; }
56+
57+
/// <summary>
58+
/// The end line of text within the source file.
59+
/// </summary>
60+
public int EndLine { get; }
61+
62+
/// <summary>
63+
/// The end column of text within the source file.
64+
/// </summary>
65+
public int EndColumn { get; }
5166

5267
public override string ToString()
5368
{

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

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -80,67 +80,63 @@ public override void InvalidArgument(string argument)
8080
/// <summary>
8181
/// Files/patterns to exclude.
8282
/// </summary>
83-
public IList<string> Excludes = new List<string>();
83+
public IList<string> Excludes { get; } = new List<string>();
8484

85-
/// <summary>
86-
/// The number of concurrent threads to use.
87-
/// </summary>
88-
public int NumberOfThreads = Semmle.Extraction.Extractor.DefaultNumberOfThreads;
8985

9086
/// <summary>
9187
/// The directory containing the source code;
9288
/// </summary>
93-
public readonly string SrcDir = System.IO.Directory.GetCurrentDirectory();
89+
public string SrcDir { get; } = System.IO.Directory.GetCurrentDirectory();
9490

9591
/// <summary>
9692
/// Whether to analyse NuGet packages.
9793
/// </summary>
98-
public bool UseNuGet = true;
94+
public bool UseNuGet { get; private set; } = true;
9995

10096
/// <summary>
10197
/// Directories to search DLLs in.
10298
/// </summary>
103-
public IList<string> DllDirs = new List<string>();
99+
public IList<string> DllDirs { get; } = new List<string>();
104100

105101
/// <summary>
106102
/// Whether to search the .Net framework directory.
107103
/// </summary>
108-
public bool ScanNetFrameworkDlls = true;
104+
public bool ScanNetFrameworkDlls { get; private set; } = true;
109105

110106
/// <summary>
111107
/// Whether to use mscorlib as a reference.
112108
/// </summary>
113-
public bool UseMscorlib = true;
109+
public bool UseMscorlib { get; private set; } = true;
114110

115111
/// <summary>
116112
/// Whether to search .csproj files.
117113
/// </summary>
118-
public bool AnalyseCsProjFiles = true;
114+
public bool AnalyseCsProjFiles { get; private set; } = true;
119115

120116
/// <summary>
121117
/// The solution file to analyse, or null if not specified.
122118
/// </summary>
123-
public string? SolutionFile;
119+
public string? SolutionFile { get; private set; }
124120

125121
/// <summary>
126122
/// Whether the extraction phase should be skipped (dry-run).
127123
/// </summary>
128-
public bool SkipExtraction = false;
124+
public bool SkipExtraction { get; private set; } = false;
129125

130126
/// <summary>
131127
/// Whether errors were encountered parsing the arguments.
132128
/// </summary>
133-
public bool Errors = false;
129+
public bool Errors { get; private set; } = false;
134130

135131
/// <summary>
136132
/// Whether to show help.
137133
/// </summary>
138-
public bool Help = false;
134+
public bool Help { get; private set; } = false;
139135

140136
/// <summary>
141137
/// Whether to use the packaged dotnet runtime.
142138
/// </summary>
143-
public bool UseSelfContainedDotnet = false;
139+
public bool UseSelfContainedDotnet { get; private set; } = false;
144140

145141
/// <summary>
146142
/// Determine whether the given path should be excluded.

0 commit comments

Comments
 (0)