Skip to content

Commit db685e5

Browse files
committed
C#: Tidy up.
1 parent e24fa47 commit db685e5

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

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

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ internal sealed partial class BuildAnalysis : IDisposable
3030
private readonly DirectoryInfo sourceDir;
3131
private readonly DotNet dotnet;
3232
private readonly Lazy<IEnumerable<string>> allFiles;
33+
private readonly TemporaryDirectory packageDirectory;
34+
3335

3436
/// <summary>
3537
/// Performs a C# build analysis.
@@ -196,6 +198,7 @@ private void ResolveConflicts()
196198
{
197199
finalAssemblyList[r.Name] = r;
198200
}
201+
199202
// Update the used references list
200203
usedReferences.Clear();
201204
foreach (var r in finalAssemblyList.Select(r => r.Value.Filename))
@@ -219,25 +222,23 @@ private void ResolveConflicts()
219222
/// Store that a particular reference file is used.
220223
/// </summary>
221224
/// <param name="reference">The filename of the reference.</param>
222-
private void UseReference(string reference) =>
223-
usedReferences[reference] = true;
225+
private void UseReference(string reference) => usedReferences[reference] = true;
224226

225227
/// <summary>
226228
/// Store that a particular source file is used (by a project file).
227229
/// </summary>
228230
/// <param name="sourceFile">The source file.</param>
229-
private void UseSource(FileInfo sourceFile) =>
230-
sources[sourceFile.FullName] = sourceFile.Exists;
231+
private void UseSource(FileInfo sourceFile) => sources[sourceFile.FullName] = sourceFile.Exists;
231232

232233
/// <summary>
233234
/// All files in the source directory.
234235
/// </summary>
235-
private IEnumerable<string> AllFiles => this.allFiles.Value;
236+
private IEnumerable<string> AllFiles => allFiles.Value;
236237

237238
/// <summary>
238239
/// The list of resolved reference files.
239240
/// </summary>
240-
public IEnumerable<string> ReferenceFiles => this.usedReferences.Keys;
241+
public IEnumerable<string> ReferenceFiles => usedReferences.Keys;
241242

242243
/// <summary>
243244
/// The list of source files used in projects.
@@ -252,7 +253,7 @@ private void UseSource(FileInfo sourceFile) =>
252253
/// <summary>
253254
/// List of assembly IDs which couldn't be resolved.
254255
/// </summary>
255-
public IEnumerable<string> UnresolvedReferences => this.unresolvedReferences.Select(r => r.Key);
256+
public IEnumerable<string> UnresolvedReferences => unresolvedReferences.Select(r => r.Key);
256257

257258
/// <summary>
258259
/// List of source files which were mentioned in project files but
@@ -266,10 +267,7 @@ private void UseSource(FileInfo sourceFile) =>
266267
/// </summary>
267268
/// <param name="id">The assembly ID.</param>
268269
/// <param name="projectFile">The project file making the reference.</param>
269-
private void UnresolvedReference(string id, string projectFile) =>
270-
unresolvedReferences[id] = projectFile;
271-
272-
private readonly TemporaryDirectory packageDirectory;
270+
private void UnresolvedReference(string id, string projectFile) => unresolvedReferences[id] = projectFile;
273271

274272
/// <summary>
275273
/// Reads all the source files and references from the given list of projects.
@@ -368,11 +366,11 @@ private static bool IsGroupMatch(ReadOnlySpan<char> line, Regex regex, string gr
368366
}
369367

370368
/// <summary>
371-
/// Returns true if the given project uses the ASP.NET components.
369+
/// Returns true if any file in the source directory indicates that ASP.NET is used.
372370
/// The following heuristic is used to decide, if ASP.NET is used:
373-
/// If any file in the project contains either of (this will most like be a .csproj file)
374-
/// <Project Sdk="Microsoft.NET.Sdk.Web" ...
375-
/// <FrameworkReference Include="Microsoft.AspNetCore.App" ...
371+
/// If any file in the source directory contains something like (this will most like be a .csproj file)
372+
/// <Project Sdk="Microsoft.NET.Sdk.Web">
373+
/// <FrameworkReference Include="Microsoft.AspNetCore.App"/>
376374
/// </summary>
377375
private bool UseAspNetDlls()
378376
{
@@ -488,8 +486,7 @@ private void AnalyseSolutions(IEnumerable<string> solutions)
488486
});
489487
}
490488

491-
public void Dispose() =>
492-
packageDirectory?.Dispose();
489+
public void Dispose() => packageDirectory?.Dispose();
493490

494491
[GeneratedRegex("<PackageReference\\s+Include=\"(.*?)\".*/?>", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline)]
495492
private static partial Regex PackageReference();

0 commit comments

Comments
 (0)