Skip to content

Commit

Permalink
Merge pull request #16376 from github/criemen/dotnet-paket
Browse files Browse the repository at this point in the history
C#/C++: Convert C# code to use `paket` package manager
  • Loading branch information
criemen committed May 16, 2024
2 parents 2dd42f7 + 74e446e commit 8dc9c95
Show file tree
Hide file tree
Showing 44 changed files with 1,285 additions and 111 deletions.
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,8 @@ python/ql/lib/semmle/python/frameworks/data/internal/subclass-capture/*.yml ling
# auto-generated bazel lock file
ruby/extractor/cargo-bazel-lock.json linguist-generated=true
ruby/extractor/cargo-bazel-lock.json -merge

# auto-generated files for the C# build
csharp/paket.lock linguist-generated=true
# needs eol=crlf, as `paket` touches this file and saves it als crlf
csharp/.paket/Paket.Restore.targets linguist-generated=true eol=crlf
4 changes: 3 additions & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ jobs:
# uses a compiled language

- run: |
dotnet build csharp
cd csharp
dotnet tool restore
dotnet build .
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@main
3 changes: 2 additions & 1 deletion .github/workflows/csharp-qltest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,11 @@ jobs:
dotnet-version: 8.0.101
- name: Extractor unit tests
run: |
dotnet tool restore
dotnet test -p:RuntimeFrameworkVersion=8.0.1 extractor/Semmle.Util.Tests
dotnet test -p:RuntimeFrameworkVersion=8.0.1 extractor/Semmle.Extraction.Tests
dotnet test -p:RuntimeFrameworkVersion=8.0.1 autobuilder/Semmle.Autobuild.CSharp.Tests
dotnet test -p:RuntimeFrameworkVersion=8.0.1 "${{ github.workspace }}/csharp/autobuilder/Semmle.Autobuild.Cpp.Tests"
dotnet test -p:RuntimeFrameworkVersion=8.0.1 autobuilder/Semmle.Autobuild.Cpp.Tests
shell: bash
stubgentest:
runs-on: ubuntu-latest
Expand Down
12 changes: 12 additions & 0 deletions csharp/.config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"paket": {
"version": "8.0.3",
"commands": [
"paket"
]
}
}
}
3 changes: 2 additions & 1 deletion csharp/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ csharp.log
.vscode/launch.json

extractor/Semmle.Extraction.CSharp.Driver/Properties/launchSettings.json
extractor-pack
extractor-pack
paket-files/
560 changes: 560 additions & 0 deletions csharp/.paket/Paket.Restore.targets

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions csharp/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project>
<Import Project=".paket\Paket.Restore.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,6 @@
<RuntimeIdentifiers>win-x64;linux-x64;osx-x64</RuntimeIdentifiers>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.IO.FileSystem" Version="4.3.0" />
<PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0" />
<PackageReference Include="xunit" Version="2.6.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Semmle.Autobuild.CSharp\Semmle.Autobuild.CSharp.csproj" />
<ProjectReference Include="..\Semmle.Autobuild.Shared\Semmle.Autobuild.Shared.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
System.IO.FileSystem
xunit
xunit.runner.visualstudio
Microsoft.NET.Test.Sdk
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<AssemblyName>Semmle.Autobuild.CSharp</AssemblyName>
<RootNamespace>Semmle.Autobuild.CSharp</RootNamespace>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<StartupObject />
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<RuntimeIdentifiers>win-x64;linux-x64;osx-x64</RuntimeIdentifiers>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Build" Version="17.8.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\extractor\Semmle.Util\Semmle.Util.csproj" />
<ProjectReference Include="..\..\extractor\Semmle.Extraction.CSharp\Semmle.Extraction.CSharp.csproj" />
<ProjectReference Include="..\..\extractor\Semmle.Extraction.CSharp.DependencyFetching\Semmle.Extraction.CSharp.DependencyFetching.csproj" />
<ProjectReference Include="..\Semmle.Autobuild.Shared\Semmle.Autobuild.Shared.csproj" />
</ItemGroup>
</Project>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<AssemblyName>Semmle.Autobuild.CSharp</AssemblyName>
<RootNamespace>Semmle.Autobuild.CSharp</RootNamespace>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<StartupObject />
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<RuntimeIdentifiers>win-x64;linux-x64;osx-x64</RuntimeIdentifiers>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\extractor\Semmle.Util\Semmle.Util.csproj" />
<ProjectReference Include="..\..\extractor\Semmle.Extraction.CSharp\Semmle.Extraction.CSharp.csproj" />
<ProjectReference Include="..\..\extractor\Semmle.Extraction.CSharp.DependencyFetching\Semmle.Extraction.CSharp.DependencyFetching.csproj" />
<ProjectReference Include="..\Semmle.Autobuild.Shared\Semmle.Autobuild.Shared.csproj" />
</ItemGroup>
</Project>
2 changes: 2 additions & 0 deletions csharp/autobuilder/Semmle.Autobuild.CSharp/paket.references
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Newtonsoft.Json
Microsoft.Build
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,8 @@
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.IO.FileSystem" Version="4.3.0" />
<PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0" />
<PackageReference Include="xunit" Version="2.6.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Semmle.Autobuild.Cpp\Semmle.Autobuild.Cpp.csproj" />
<ProjectReference Include="..\..\autobuilder\Semmle.Autobuild.Shared\Semmle.Autobuild.Shared.csproj" />
<ProjectReference Include="..\Semmle.Autobuild.Shared\Semmle.Autobuild.Shared.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
System.IO.FileSystem
xunit
xunit.runner.visualstudio
Microsoft.NET.Test.Sdk
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,8 @@
<Folder Include="Properties\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Build" Version="17.8.3" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\extractor\Semmle.Util\Semmle.Util.csproj" />
<ProjectReference Include="..\..\autobuilder\Semmle.Autobuild.Shared\Semmle.Autobuild.Shared.csproj" />
<ProjectReference Include="..\Semmle.Autobuild.Shared\Semmle.Autobuild.Shared.csproj" />
</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions csharp/autobuilder/Semmle.Autobuild.Cpp/paket.references
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Microsoft.Build
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Build" Version="17.8.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\extractor\Semmle.Util\Semmle.Util.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Microsoft.Build
6 changes: 6 additions & 0 deletions csharp/before.CSharp.sln.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Project InitialTargets="LocalToolRestore">
<Target Name="LocalToolRestore">
<Message Text="Restoring tools" Importance="High" />
<Exec Command="dotnet tool restore" />
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>

</Project>
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@
<ProjectReference Include="..\Semmle.Extraction.CSharp.DependencyFetching\Semmle.Extraction.CSharp.DependencyFetching.csproj" />
<ProjectReference Include="..\Semmle.Extraction.CSharp.StubGenerator\Semmle.Extraction.CSharp.StubGenerator.csproj" />
</ItemGroup>

</Project>
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@
<ItemGroup>
<ProjectReference Include="..\Semmle.Extraction.CSharp\Semmle.Extraction.CSharp.csproj" />
</ItemGroup>

</Project>
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,4 @@
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Build" Version="17.8.3" />
<PackageReference Include="Microsoft.Win32.Primitives" Version="4.3.0" />
<PackageReference Include="System.Net.Primitives" Version="4.3.1" />
<PackageReference Include="System.Security.Principal" Version="4.3.0" />
<PackageReference Include="System.Threading.ThreadPool" Version="4.3.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Microsoft.Build
Microsoft.Win32.Primitives
System.Net.Primitives
System.Security.Principal
System.Threading.ThreadPool
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,4 @@
<ProjectReference Include="..\Semmle.Extraction.CSharp.DependencyFetching\Semmle.Extraction.CSharp.DependencyFetching.csproj" />
<ProjectReference Include="..\Semmle.Extraction.CSharp.Util\Semmle.Extraction.CSharp.Util.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Microsoft.CodeAnalysis.CSharp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,4 @@
<ItemGroup>
<ProjectReference Include="..\Semmle.Util\Semmle.Util.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Microsoft.CodeAnalysis.CSharp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,4 @@
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" />
<PackageReference Include="Microsoft.Build" Version="17.8.3" />
</ItemGroup>
</Project>
3 changes: 3 additions & 0 deletions csharp/extractor/Semmle.Extraction.CSharp/paket.references
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Microsoft.Build
Microsoft.CodeAnalysis.CSharp

Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,6 @@
<RuntimeIdentifiers>win-x64;linux-x64;osx-x64</RuntimeIdentifiers>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.IO.FileSystem" Version="4.3.0" />
<PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0" />
<PackageReference Include="xunit" Version="2.6.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Semmle.Extraction.CSharp.StubGenerator\Semmle.Extraction.CSharp.StubGenerator.csproj" />
<ProjectReference Include="..\Semmle.Extraction.CSharp.Standalone\Semmle.Extraction.CSharp.Standalone.csproj" />
Expand Down
4 changes: 4 additions & 0 deletions csharp/extractor/Semmle.Extraction.Tests/paket.references
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
System.IO.FileSystem
xunit
xunit.runner.visualstudio
Microsoft.NET.Test.Sdk
8 changes: 0 additions & 8 deletions csharp/extractor/Semmle.Extraction/Semmle.Extraction.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>TRACE;DEBUG;DEBUG_LABELS</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Build" Version="17.8.3" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="4.8.0" />
<PackageReference Include="GitInfo" Version="3.3.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Semmle.Util\Semmle.Util.csproj" />
</ItemGroup>
Expand Down
3 changes: 3 additions & 0 deletions csharp/extractor/Semmle.Extraction/paket.references
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Microsoft.Build
Microsoft.CodeAnalysis
GitInfo
8 changes: 0 additions & 8 deletions csharp/extractor/Semmle.Util.Tests/Semmle.Util.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@
<RuntimeIdentifiers>win-x64;linux-x64;osx-x64</RuntimeIdentifiers>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="xunit" Version="2.6.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Semmle.Util\Semmle.Util.csproj" />
</ItemGroup>
Expand Down
3 changes: 3 additions & 0 deletions csharp/extractor/Semmle.Util.Tests/paket.references
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
xunit
xunit.runner.visualstudio
Microsoft.NET.Test.Sdk
6 changes: 0 additions & 6 deletions csharp/extractor/Semmle.Util/Semmle.Util.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,4 @@
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Mono.Posix.NETStandard" Version="1.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

</Project>
2 changes: 2 additions & 0 deletions csharp/extractor/Semmle.Util/paket.references
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Mono.Posix.NETStandard
Newtonsoft.Json
20 changes: 20 additions & 0 deletions csharp/paket.dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
framework: net8.0
storage: none
source https://api.nuget.org/v3/index.json
# behave like nuget in choosing transitive dependency versions
strategy: min

nuget Mono.Posix.NETStandard 1.0.0
nuget Newtonsoft.Json 13.0.3
nuget xunit 2.6.2
nuget xunit.runner.visualstudio 2.5.4
nuget Microsoft.NET.Test.Sdk 17.8.0
nuget Microsoft.CodeAnalysis.CSharp 4.8.0
nuget Microsoft.CodeAnalysis 4.8.0
nuget Microsoft.Build 17.8.3
nuget Microsoft.Win32.Primitives 4.3.0
nuget System.Net.Primitives 4.3.1
nuget System.Security.Principal 4.3.0
nuget System.Threading.ThreadPool 4.3.0
nuget System.IO.FileSystem 4.3.0
nuget GitInfo 3.3.3

0 comments on commit 8dc9c95

Please sign in to comment.