Skip to content

Commit 016474c

Browse files
authored
Add .net8 targeting and cleanup (#58)
The main purpose of this PR is to add targeting for .net8. **Changes** 1. Add targeting for .net 8 3. Remove incorrect statement in readme.md 4. Add debug/launch config for vs code 5. Upgrade `Microsoft.Build.Locator` 6. Adds snapshot test for .net8 (which is what the majority of files are) 7. Add logic to pick right framework version when targeting a solution
1 parent 87075c4 commit 016474c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+5517
-205
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,3 +351,5 @@ MigrationBackup/
351351
# Ionide (cross platform F# VS Code tools) working folder
352352
.ionide/
353353

354+
# Ignore generated scip files
355+
index.scip

.vscode/launch.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Index project at path",
9+
"type": "coreclr",
10+
"request": "launch",
11+
"preLaunchTask": "build",
12+
"program": "${workspaceFolder}/ScipDotnet/bin/Debug/net8.0/scip-dotnet.dll",
13+
"args": ["index", "--working-directory", "${input:path}"],
14+
"cwd": "${workspaceFolder}",
15+
"stopAtEntry": false,
16+
"console": "internalConsole"
17+
}
18+
],
19+
"inputs": [
20+
{
21+
"id": "path",
22+
"description": "Please enter the path to the project to index",
23+
"default": "",
24+
"type": "promptString"
25+
}
26+
]
27+
}

.vscode/tasks.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
// See https://go.microsoft.com/fwlink/?LinkId=733558
3+
// for the documentation about the tasks.json format
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
"label": "build",
8+
"command": "dotnet",
9+
"type": "shell",
10+
"args": [
11+
"build",
12+
// Ask dotnet build to generate full paths for file names.
13+
"/property:GenerateFullPaths=true",
14+
// Do not generate summary otherwise it leads to duplicate errors in Problems panel
15+
"/consoleloggerparameters:NoSummary"
16+
],
17+
"group": "build",
18+
"presentation": {
19+
"reveal": "silent"
20+
},
21+
"problemMatcher": "$msCompile"
22+
}
23+
]
24+
}

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM mcr.microsoft.com/dotnet/sdk:7.0
1+
FROM mcr.microsoft.com/dotnet/sdk:8.0
22
WORKDIR /scip-dotnet
33
ADD . /scip-dotnet
44
RUN dotnet pack

ScipDotnet.Tests/ScipDotnet.Tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
4+
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<IsPackable>false</IsPackable>
@@ -19,7 +19,7 @@
1919
</ItemGroup>
2020

2121
<ItemGroup>
22-
<ProjectReference Include="..\ScipDotnet\ScipDotnet.csproj" />
22+
<ProjectReference Include="..\ScipDotnet\ScipDotnet.csproj" />
2323
</ItemGroup>
2424

2525
</Project>

ScipDotnet.Tests/SnapshotTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ private static string[] ListSnapshotInputDirectories()
131131
{
132132
var inputs = Path.Join(RootDirectory(), "snapshots", "input");
133133

134-
#if NET7_0
134+
#if NET7_0_OR_GREATER
135135
return Directory.GetDirectories(inputs).Where(x => !x.Contains("WpfApplication")).ToArray();
136136
#else
137137
return Directory.GetDirectories(inputs);
@@ -150,11 +150,12 @@ private static string IndexDirectory(string directory)
150150
{
151151
FileName = "dotnet",
152152
Arguments = arguments,
153-
WorkingDirectory = RootDirectory(),
153+
WorkingDirectory = RootDirectory()
154154
}
155155
};
156156
process.Start();
157157
process.WaitForExit();
158+
158159
if (process.ExitCode != 0)
159160
{
160161
Assert.Fail(

ScipDotnet/ScipDotnet.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<PackageLicenseFile>LICENSE</PackageLicenseFile>
99
<PackageReadmeFile>readme.md</PackageReadmeFile>
1010
<PackageType>DotnetTool</PackageType>
11-
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
11+
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
1212
<PackAsTool>true</PackAsTool>
1313
<AssemblyName>scip-dotnet</AssemblyName>
1414
<RepositoryUrl>https://github.com/sourcegraph/scip-dotnet</RepositoryUrl>
@@ -18,7 +18,7 @@
1818
<None Include="../LICENSE" Pack="true" PackagePath="" />
1919
<None Include="../readme.md" Pack="true" PackagePath="" />
2020
<PackageReference Include="Google.Protobuf" Version="3.21.9" />
21-
<PackageReference Include="Microsoft.Build.Locator" Version="1.5.5" />
21+
<PackageReference Include="Microsoft.Build.Locator" Version="1.7.8" />
2222
<PackageReference Include="Microsoft.CodeAnalysis" Version="4.4.0" />
2323
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Features" Version="4.4.0" />
2424
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.4.0" />

ScipDotnet/ScipProjectIndexer.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,26 @@ private void Restore(IndexCommandOptions options, FileInfo project)
5656
HashSet<ProjectId> indexedProjects)
5757
{
5858
Restore(options, rootProject);
59-
IEnumerable<Project> projects = string.Equals(rootProject.Extension, ".csproj") || string.Equals(rootProject.Extension, ".vbproj")
59+
var projects = (string.Equals(rootProject.Extension, ".csproj") || string.Equals(rootProject.Extension, ".vbproj")
6060
? new[]
6161
{
6262
await host.Services.GetRequiredService<MSBuildWorkspace>()
6363
.OpenProjectAsync(rootProject.FullName)
6464
}
6565
: (await host.Services.GetRequiredService<MSBuildWorkspace>()
66-
.OpenSolutionAsync(rootProject.FullName)).Projects;
66+
.OpenSolutionAsync(rootProject.FullName)).Projects).ToList();
6767

68-
foreach (var project in projects)
68+
69+
var projectsPerProjFile = projects.GroupBy(x => x.FilePath);
70+
var framework = $"net{Environment.Version.Major}.0";
71+
foreach (var projectGroup in projectsPerProjFile)
6972
{
73+
74+
// If the project was found by opening the solution, we need to find the project that matches the framework.
75+
// if we can' fall back to the first one. Without this, we will process the same document multiple times
76+
// once for each framework version being targeting and it leads to unpredictable results since the scip file
77+
// will contain the same document multiple times iwth different symbols.
78+
var project = projectGroup.FirstOrDefault(x => x.Name.Contains($"({framework})", StringComparison.OrdinalIgnoreCase)) ?? projectGroup.First();
7079
if (project.Language != "C#" && project.Language != "Visual Basic")
7180
{
7281
Logger.LogWarning(

readme.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,8 @@ src code-intel upload
3131
The following steps show you how to install a `scip-dotnet` command-line tool to
3232
your local computer.
3333

34-
First, install .NET 7.0
35-
https://dotnet.microsoft.com/en-us/download/dotnet-framework.
36-
37-
> Note that `scip-dotnet` is built against .NET 7.0 and won't run with older
38-
> versions. Please open a
39-
> [feature request](https://github.com/sourcegraph/scip-dotnet/issues/new) if
40-
> you want cross-built support for older .NET versions.
34+
First, install .NET 8.0
35+
https://dotnet.microsoft.com/en-us/download.
4136

4237
Next, run `dotnet tool install`.
4338

snapshots/input/syntax/Main/Main.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
5+
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
88
<LangVersion>preview</LangVersion>
@@ -13,4 +13,4 @@
1313
<PackageReference Include="DiffPlex" Version="1.7.1" />
1414
</ItemGroup>
1515

16-
</Project>
16+
</Project>

0 commit comments

Comments
 (0)