Skip to content

Commit

Permalink
Cross-build to .NET 7.0 and 6.0 (#24)
Browse files Browse the repository at this point in the history
Previously, scip-dotnet was only built against net7.0. Given that 6.0 is
an LTS version it makes sense to cross-build it against net6.0 as well.

There are minor differences in the snapshots between net6.0 and net7.0
(some occurrences are missing in net6.0) so I figured it was easiest to
have two separate snapshot directories. Thankfully, you can run the
tests for net6.0 and net7.0 with one `dotnet test` command. Use `dotnet
test --framework net7.0` if you only want to run the tests for a single
framework.
  • Loading branch information
olafurpg authored Apr 28, 2023
1 parent dec7570 commit 7a54bab
Show file tree
Hide file tree
Showing 42 changed files with 2,349 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ScipDotnet.Tests/ScipDotnet.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
Expand Down
10 changes: 6 additions & 4 deletions ScipDotnet.Tests/SnapshotTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ public void Snapshot(string inputDirectory)
var indexFile = IndexDirectory(inputDirectory);
var indexBytes = File.ReadAllBytes(indexFile);
var index = Index.Parser.ParseFrom(indexBytes);
var snapshots = index.Documents.ToDictionary(document => document.RelativePath,
document => FormatDocument(index, document));
var snapshots = index.Documents
.DistinctBy(document => document.RelativePath)
.ToDictionary(document => document.RelativePath, document => FormatDocument(index, document));
var outputDirectory =
Path.GetFullPath(Path.Join(inputDirectory, "../../", "output", Path.GetFileName(inputDirectory)));
Path.GetFullPath(Path.Join(inputDirectory, "../../", $"output-net{Environment.Version.Major}.0", Path.GetFileName(inputDirectory)));
var isUpdateSnapshots = Environment.GetEnvironmentVariable("SCIP_UPDATE_SNAPSHOTS") != null;
if (isUpdateSnapshots)
{
Expand Down Expand Up @@ -140,8 +141,9 @@ private static string[] ListSnapshotInputDirectories()
private static string IndexDirectory(string directory)
{
var include = Environment.GetEnvironmentVariable("SCIP_INCLUDE");
var framework = $"net{Environment.Version.Major}.0";
var includeOption = include != null ? $" --include {include}" : "";
var arguments = $"run --project ScipDotnet -- index --working-directory {directory}{includeOption}";
var arguments = $"run --project ScipDotnet --framework {framework} -- index --working-directory {directory}{includeOption}";
var process = new Process()
{
StartInfo = new ProcessStartInfo()
Expand Down
2 changes: 1 addition & 1 deletion ScipDotnet/ScipDotnet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageReadmeFile>readme.md</PackageReadmeFile>
<PackageType>DotnetTool</PackageType>
<TargetFramework>net7.0</TargetFramework>
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
<PackAsTool>true</PackAsTool>
<AssemblyName>scip-dotnet</AssemblyName>
<RepositoryUrl>https://github.com/sourcegraph/scip-dotnet</RepositoryUrl>
Expand Down
2 changes: 1 addition & 1 deletion snapshots/input/syntax/Main/Main.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>preview</LangVersion>
Expand Down
185 changes: 185 additions & 0 deletions snapshots/output-net6.0/syntax/Main/Classes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
using System.Diagnostics.CodeAnalysis;

namespace Main;
// ^^^^ reference scip-dotnet nuget . . Main/

[SuppressMessage("ReSharper", "all")]
public class Classes
// ^^^^^^^ definition scip-dotnet nuget . . Main/Classes#
// documentation ```cs\nclass Classes\n```
{
public string Name;
// ^^^^ definition scip-dotnet nuget . . Main/Classes#Name.
// documentation ```cs\npublic string Classes.Name\n```
public const int IntConstant = 1;
// ^^^^^^^^^^^ definition scip-dotnet nuget . . Main/Classes#IntConstant.
// documentation ```cs\npublic const int Classes.IntConstant\n```
public const string StringConstant = $"hello";
// ^^^^^^^^^^^^^^ definition scip-dotnet nuget . . Main/Classes#StringConstant.
// documentation ```cs\npublic const string Classes.StringConstant\n```

public Classes(int name)
// ^^^^^^^ definition scip-dotnet nuget . . Main/Classes#`.ctor`().
// documentation ```cs\npublic Classes.Classes(int name)\n```
// ^^^^ definition scip-dotnet nuget . . Main/Classes#`.ctor`().(name)
// documentation ```cs\nint name\n```
{
Name = "name";
// ^^^^ reference scip-dotnet nuget . . Main/Classes#Name.
}

public Classes(string name) => Name = name;
// ^^^^^^^ definition scip-dotnet nuget . . Main/Classes#`.ctor`(+1).
// documentation ```cs\npublic Classes.Classes(string name)\n```
// ^^^^ definition scip-dotnet nuget . . Main/Classes#`.ctor`(+1).(name)
// documentation ```cs\nstring name\n```
// ^^^^ reference scip-dotnet nuget . . Main/Classes#Name.
// ^^^^ reference scip-dotnet nuget . . Main/Classes#`.ctor`(+1).(name)

~Classes()
// ^^^^^^^ definition scip-dotnet nuget . . Main/Classes#Finalize().
// documentation ```cs\nprotected Classes.~Classes()\n```
{
Console.WriteLine(42);
}


public class ObjectClass : object, SomeInterface
// ^^^^^^^^^^^ definition scip-dotnet nuget . . Main/Classes#ObjectClass#
// documentation ```cs\nclass ObjectClass\n```
// relationship implementation scip-dotnet nuget . . Main/SomeInterface#
// ^^^^^^^^^^^^^ reference scip-dotnet nuget . . Main/SomeInterface#
{
}

public partial class PartialClass
// ^^^^^^^^^^^^ definition scip-dotnet nuget . . Main/Classes#PartialClass#
// documentation ```cs\nclass PartialClass\n```
{
}

class TypeParameterClass<T>
// ^^^^^^^^^^^^^^^^^^ definition scip-dotnet nuget . . Main/Classes#TypeParameterClass#
// documentation ```cs\nclass TypeParameterClass<T>\n```
{
}

internal class InternalMultipleTypeParametersClass<T1, T2>
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition scip-dotnet nuget . . Main/Classes#InternalMultipleTypeParametersClass#
// documentation ```cs\nclass InternalMultipleTypeParametersClass<T1, T2>\n```
{
}

interface ICovariantContravariant<in T1, out T2>
// ^^^^^^^^^^^^^^^^^^^^^^^ definition scip-dotnet nuget . . Main/Classes#ICovariantContravariant#
// documentation ```cs\ninterface ICovariantContravariant<in T1, out T2>\n```
{
public void Method1(T1 t1)
// ^^^^^^^ definition scip-dotnet nuget . . Main/Classes#ICovariantContravariant#Method1().
// documentation ```cs\nvoid ICovariantContravariant<in T1, out T2>.Method1(T1 t1)\n```
// ^^ reference scip-dotnet nuget . . Main/Classes#ICovariantContravariant#[T1]
// ^^ definition scip-dotnet nuget . . Main/Classes#ICovariantContravariant#Method1().(t1)
// documentation ```cs\nT1 t1\n```
{
Console.WriteLine(t1);
// ^^ reference scip-dotnet nuget . . Main/Classes#ICovariantContravariant#Method1().(t1)
}

public T2? Method2()
// ^^ reference scip-dotnet nuget . . Main/Classes#ICovariantContravariant#[T2]
// ^^^^^^^ definition scip-dotnet nuget . . Main/Classes#ICovariantContravariant#Method2().
// documentation ```cs\nT2? ICovariantContravariant<in T1, out T2>.Method2()\n```
{
return default(T2);
// ^^ reference scip-dotnet nuget . . Main/Classes#ICovariantContravariant#[T2]
}
}

public class StructConstraintClass<T> where T : struct
// ^^^^^^^^^^^^^^^^^^^^^ definition scip-dotnet nuget . . Main/Classes#StructConstraintClass#
// documentation ```cs\nclass StructConstraintClass<T> where T : struct\n```
// ^ reference scip-dotnet nuget . . Main/Classes#StructConstraintClass#[T]
{
}

public class UnmanagedConstraintClass<T> where T : unmanaged
// ^^^^^^^^^^^^^^^^^^^^^^^^ definition scip-dotnet nuget . . Main/Classes#UnmanagedConstraintClass#
// documentation ```cs\nclass UnmanagedConstraintClass<T> where T : unmanaged\n```
// ^ reference scip-dotnet nuget . . Main/Classes#UnmanagedConstraintClass#[T]
{
}

public class ClassConstraintClass<T> where T : class
// ^^^^^^^^^^^^^^^^^^^^ definition scip-dotnet nuget . . Main/Classes#ClassConstraintClass#
// documentation ```cs\nclass ClassConstraintClass<T> where T : class\n```
// ^ reference scip-dotnet nuget . . Main/Classes#ClassConstraintClass#[T]
{
}

public class NonNullableConstraintClass<T> where T : notnull
// ^^^^^^^^^^^^^^^^^^^^^^^^^^ definition scip-dotnet nuget . . Main/Classes#NonNullableConstraintClass#
// documentation ```cs\nclass NonNullableConstraintClass<T> where T : notnull\n```
// ^ reference scip-dotnet nuget . . Main/Classes#NonNullableConstraintClass#[T]
{
}

public class NewConstraintClass<T> where T : new()
// ^^^^^^^^^^^^^^^^^^ definition scip-dotnet nuget . . Main/Classes#NewConstraintClass#
// documentation ```cs\nclass NewConstraintClass<T> where T : new()\n```
// ^ reference scip-dotnet nuget . . Main/Classes#NewConstraintClass#[T]
{
}

public class TypeParameterConstraintClass<T> where T : SomeInterface
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition scip-dotnet nuget . . Main/Classes#TypeParameterConstraintClass#
// documentation ```cs\nclass TypeParameterConstraintClass<T> where T : SomeInterface\n```
// ^ reference scip-dotnet nuget . . Main/Classes#TypeParameterConstraintClass#[T]
// ^^^^^^^^^^^^^ reference scip-dotnet nuget . . Main/SomeInterface#
{
}

private class MultipleTypeParameterConstraintsClass<T1, T2> where T1 : SomeInterface, SomeInterface2, new()
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition scip-dotnet nuget . . Main/Classes#MultipleTypeParameterConstraintsClass#
// documentation ```cs\nclass MultipleTypeParameterConstraintsClass<T1, T2> where T1 : SomeInterface, SomeInterface2, new() where T2 : SomeInterface2\n```
// ^^ reference scip-dotnet nuget . . Main/Classes#MultipleTypeParameterConstraintsClass#[T1]
// ^^^^^^^^^^^^^ reference scip-dotnet nuget . . Main/SomeInterface#
// ^^^^^^^^^^^^^^ reference scip-dotnet nuget . . Main/SomeInterface2#
where T2 : SomeInterface2
// ^^ reference scip-dotnet nuget . . Main/Classes#MultipleTypeParameterConstraintsClass#[T2]
// ^^^^^^^^^^^^^^ reference scip-dotnet nuget . . Main/SomeInterface2#
{
}

class IndexClass
// ^^^^^^^^^^ definition scip-dotnet nuget . . Main/Classes#IndexClass#
// documentation ```cs\nclass IndexClass\n```
{
private bool a;
// ^ definition scip-dotnet nuget . . Main/Classes#IndexClass#a.
// documentation ```cs\nprivate bool IndexClass.a\n```

public bool this[int index]
// ^^^^^ definition scip-dotnet nuget . . Main/Classes#IndexClass#`this[]`.(index)
// documentation ```cs\nint index\n```
{
get { return a; }
// ^ reference scip-dotnet nuget . . Main/Classes#IndexClass#a.
set { a = value; }
// ^ reference scip-dotnet nuget . . Main/Classes#IndexClass#a.
// ^^^^^ reference scip-dotnet nuget . . Main/Classes#IndexClass#set_Item().(value)
}
}

}

public interface SomeInterface
// ^^^^^^^^^^^^^ definition scip-dotnet nuget . . Main/SomeInterface#
// documentation ```cs\ninterface SomeInterface\n```
{
}

internal interface SomeInterface2
// ^^^^^^^^^^^^^^ definition scip-dotnet nuget . . Main/SomeInterface2#
// documentation ```cs\ninterface SomeInterface2\n```
{
}
34 changes: 34 additions & 0 deletions snapshots/output-net6.0/syntax/Main/Enums.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System.Diagnostics.CodeAnalysis;

namespace Main;
// ^^^^ reference scip-dotnet nuget . . Main/

[SuppressMessage("ReSharper", "all")]
public class Enums
// ^^^^^ definition scip-dotnet nuget . . Main/Enums#
// documentation ```cs\nclass Enums\n```
{
enum EnumWithIntValues
// ^^^^^^^^^^^^^^^^^ definition scip-dotnet nuget . . Main/Enums#EnumWithIntValues#
// documentation ```cs\nenum EnumWithIntValues\n```
{
Ten = 10,
// ^^^ definition scip-dotnet nuget . . Main/Enums#EnumWithIntValues#Ten.
// documentation ```cs\nEnumWithIntValues.Ten\n```
Twenty = 20
// ^^^^^^ definition scip-dotnet nuget . . Main/Enums#EnumWithIntValues#Twenty.
// documentation ```cs\nEnumWithIntValues.Twenty\n```
}

enum EnumWithByteValues
// ^^^^^^^^^^^^^^^^^^ definition scip-dotnet nuget . . Main/Enums#EnumWithByteValues#
// documentation ```cs\nenum EnumWithByteValues\n```
{
Five = 0x05,
// ^^^^ definition scip-dotnet nuget . . Main/Enums#EnumWithByteValues#Five.
// documentation ```cs\nEnumWithByteValues.Five\n```
Fifteen = 0x0F
// ^^^^^^^ definition scip-dotnet nuget . . Main/Enums#EnumWithByteValues#Fifteen.
// documentation ```cs\nEnumWithByteValues.Fifteen\n```
}
}
42 changes: 42 additions & 0 deletions snapshots/output-net6.0/syntax/Main/Events.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System.Diagnostics.CodeAnalysis;

namespace Main;
// ^^^^ reference scip-dotnet nuget . . Main/

[SuppressMessage("ReSharper", "all")]
public class Events
// ^^^^^^ definition scip-dotnet nuget . . Main/Events#
// documentation ```cs\nclass Events\n```
{
public event EventHandler<int> Event1
// ^^^^^^ definition scip-dotnet nuget . . Main/Events#Event1#
// documentation ```cs\npublic event EventHandler<int> Events.Event1\n```
{
add { }
remove { }
}

public event EventHandler Event2
// ^^^^^^ definition scip-dotnet nuget . . Main/Events#Event2#
// documentation ```cs\npublic event EventHandler Events.Event2\n```
{
add => addSomething();
// ^^^^^^^^^^^^ reference scip-dotnet nuget . . Main/Events#addSomething().
remove => removeSomething();
// ^^^^^^^^^^^^^^^ reference scip-dotnet nuget . . Main/Events#removeSomething().
}

private void removeSomething()
// ^^^^^^^^^^^^^^^ definition scip-dotnet nuget . . Main/Events#removeSomething().
// documentation ```cs\nprivate void Events.removeSomething()\n```
{
throw new NotImplementedException();
}

private void addSomething()
// ^^^^^^^^^^^^ definition scip-dotnet nuget . . Main/Events#addSomething().
// documentation ```cs\nprivate void Events.addSomething()\n```
{
throw new NotImplementedException();
}
}
Loading

0 comments on commit 7a54bab

Please sign in to comment.