forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDotNetVersion.cs
More file actions
54 lines (46 loc) · 1.74 KB
/
DotNetVersion.cs
File metadata and controls
54 lines (46 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System;
using System.IO;
using NuGet.Versioning;
namespace Semmle.Extraction.CSharp.DependencyFetching
{
internal record DotNetVersion : IComparable<DotNetVersion>
{
private readonly string dir;
private readonly NuGetVersion version;
private string FullVersion =>
version.ToString();
public string FullPath => Path.Combine(dir, FullVersion);
/**
* The full path to the reference assemblies for this runtime.
* This is the same as FullPath, except that we assume that the
* reference assemblies are in a directory called "packs" and
* the reference assemblies themselves are in a directory called
* "[Framework].Ref/ref".
* Example:
* FullPath: /usr/share/dotnet/shared/Microsoft.NETCore.App/7.0.2
* FullPathReferenceAssemblies: /usr/share/dotnet/packs/Microsoft.NETCore.App.Ref/7.0.2/ref
*/
public string? FullPathReferenceAssemblies
{
get
{
var directories = dir.Split(Path.DirectorySeparatorChar);
if (directories.Length >= 2)
{
directories[^2] = "packs";
directories[^1] = $"{directories[^1]}.Ref";
return Path.Combine(string.Join(Path.DirectorySeparatorChar, directories), FullVersion, "ref");
}
return null;
}
}
public DotNetVersion(string dir, NuGetVersion version)
{
this.dir = dir;
this.version = version;
}
public int CompareTo(DotNetVersion? other) =>
version.CompareTo(other?.version);
public override string ToString() => FullPath;
}
}