Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
bindings/typescript/scip_pb.ts linguist-generated=true
bindings/go/scip/scip.pb.go linguist-generated=true
bindings/rust/src/generated/scip.rs linguist-generated=true
bindings/dotnet/src/Scip.cs linguist-generated=true
bindings/haskell/src/Proto/**.hs linguist-generated=true
bindings/java/src/main/java/org/scip_code/scip/**.java linguist-generated=true
bindings/kotlin/src/main/kotlin/org/scip_code/scip/**.kt linguist-generated=true
Expand Down
4 changes: 2 additions & 2 deletions .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"packageRules": [
{
"description": "Bump manually in lock-step with flake.nix's protoc.",
"matchManagers": ["maven"],
"matchPackageNames": ["com.google.protobuf:*"],
"matchManagers": ["maven", "nuget"],
"matchPackageNames": ["com.google.protobuf:*", "Google.Protobuf"],
"enabled": false
},
{
Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/dotnet-bindings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: .NET bindings

# The Nix `dotnet-bindings` check already builds and packs this project with
# the pinned SDK. This workflow covers the toolchain a contributor without
# Nix uses, and annotates the exact file when the package version drifts
# from cmd/scip/version.txt.

on:
pull_request:
paths:
- bindings/dotnet/**
- cmd/scip/version.txt
- scip.proto
- .github/workflows/dotnet-bindings.yaml

permissions:
contents: read

concurrency:
group: dotnet-bindings-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7

- uses: actions/setup-dotnet@v5
with:
dotnet-version: '10.0.x'

- name: Validate Scip.csproj version matches cmd/scip/version.txt
run: |
set -euo pipefail
expected=$(cat cmd/scip/version.txt)
actual=$(dotnet msbuild bindings/dotnet/Scip.csproj -getProperty:Version)
if [ "$actual" != "$expected" ]; then
echo "::error file=bindings/dotnet/Scip.csproj::version is '$actual', expected '$expected'"
exit 1
fi

- name: Pack the Scip package
run: dotnet pack -c Release bindings/dotnet/Scip.csproj
30 changes: 29 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,34 @@ jobs:
fi
working-directory: bindings/rust

publish-dotnet-bindings:
needs: publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
ref: v${{ needs.publish.outputs.version }}
- uses: DeterminateSystems/nix-installer-action@v22
- uses: DeterminateSystems/magic-nix-cache-action@v14
with:
use-flakehub: "disabled"
# LICENSE and README.md are packed into the nupkg; LICENSE is a symlink
# in-tree (matches bindings/{haskell,rust,typescript}) and dotnet pack
# follows it, so no materialization step is needed.
- name: Pack
working-directory: bindings/dotnet
run: nix develop -c dotnet pack -c Release
- name: Publish to NuGet
working-directory: bindings/dotnet
# --skip-duplicate keeps re-runs of a partially failed release green;
# NuGet publications are irreversible, like the other registries here.
run: |
nix develop -c dotnet nuget push \
'bin/Release/Scip.${{ needs.publish.outputs.version }}.nupkg' \
--source https://api.nuget.org/v3/index.json \
--api-key '${{ secrets.NUGET_API_KEY }}' \
--skip-duplicate

publish-haskell-bindings:
needs: publish
runs-on: ubuntu-latest
Expand Down Expand Up @@ -262,7 +290,7 @@ jobs:
gh release upload "$TAG" "$ASSET.tar.gz" "$ASSET.tar.gz.sha256" --clobber

finalize-release:
needs: [publish, release-crate, publish-haskell-bindings, build-go-binaries, publish-jvm-bindings, publish-npm]
needs: [publish, release-crate, publish-dotnet-bindings, publish-haskell-bindings, build-go-binaries, publish-jvm-bindings, publish-npm]
runs-on: ubuntu-latest
permissions:
contents: write
Expand Down
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ reprolang/target
reprolang/src/grammar.json
reprolang/src/node-types.json
bindings/typescript
bindings/dotnet/bin
bindings/dotnet/obj
docs/scip.md
.bin
2 changes: 2 additions & 0 deletions bindings/dotnet/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bin/
obj/
1 change: 1 addition & 0 deletions bindings/dotnet/LICENSE
42 changes: 42 additions & 0 deletions bindings/dotnet/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# `Scip`

Generated .NET bindings for the [SCIP Code Intelligence Protocol].

## Install

```sh
dotnet add package Scip
```

The package targets `netstandard2.0` and depends on [`Google.Protobuf`], which
is installed transitively.

## Use

```csharp
using Scip;
// Alias `Scip.Index`, which is ambiguous with `System.Index` under
// implicit usings.
using ScipIndex = Scip.Index;

using var stream = File.OpenRead("index.scip");
var index = ScipIndex.Parser.ParseFrom(stream);

Console.WriteLine(index.Metadata.ProjectRoot);
foreach (var document in index.Documents)
{
Console.WriteLine($"{document.RelativePath} {document.Occurrences.Count}");
}
```

## Naming

The `scip.Descriptor` message is generated as `Scip.SymbolDescriptor`: C#
rejects a class whose member has the same name as the class itself, and every
generated message carries a static `Descriptor` property. The name matches the
schema's own comments and the [scip-dotnet] indexer. Nothing else is renamed,
and the Protobuf descriptor still reports `scip.Descriptor`.

[SCIP Code Intelligence Protocol]: https://github.com/scip-code/scip
[scip-dotnet]: https://github.com/sourcegraph/scip-dotnet
[`Google.Protobuf`]: https://www.nuget.org/packages/Google.Protobuf
48 changes: 48 additions & 0 deletions bindings/dotnet/Scip.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<!--
The generated code is plain data types with no framework-specific API
surface, so netstandard2.0 costs nothing and reaches the widest set of
consumers: .NET Framework 4.6.1+, Mono/Unity and every .NET (Core)
release. Google.Protobuf ships a netstandard2.0 assembly too.
-->
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>Scip</AssemblyName>
<RootNamespace>Scip</RootNamespace>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<PropertyGroup>
<PackageId>Scip</PackageId>
<!-- Must match cmd/scip/version.txt (enforced by .github/workflows/dotnet-bindings.yaml). -->
<Version>0.9.0</Version>
<Description>
Generated .NET bindings for the Semantic Code Intelligence Protocol (SCIP).
</Description>
<Authors>SCIP Maintainers</Authors>
<Company>scip-code</Company>
<PackageProjectUrl>https://github.com/scip-code/scip</PackageProjectUrl>
<RepositoryUrl>https://github.com/scip-code/scip.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageTags>scip;protobuf;code-intelligence;code-navigation</PackageTags>
</PropertyGroup>

<ItemGroup>
<!--
Must match the protoc version used for code generation (see flake.nix).
The C# runtime is versioned 3.MAJOR.MINOR against protoc's MAJOR.MINOR,
so protoc 34.x pairs with Google.Protobuf 3.34.x. Generated code only
needs the runtime to be at least as new as the compiler that emitted it.
-->
<PackageReference Include="Google.Protobuf" Version="3.34.2" />
</ItemGroup>

<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="" />
<None Include="LICENSE" Pack="true" PackagePath="" />
</ItemGroup>

</Project>
37 changes: 37 additions & 0 deletions bindings/dotnet/deps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[
{
"pname": "Google.Protobuf",
"version": "3.34.2",
"hash": "sha256-2Ll4KYge9xzqBGP80aRbkJ2Nxc9lhvv7Oa1xBPJU0+k="
},
{
"pname": "Microsoft.NETCore.Platforms",
"version": "1.1.0",
"hash": "sha256-FeM40ktcObQJk4nMYShB61H/E8B7tIKfl9ObJ0IOcCM="
},
{
"pname": "NETStandard.Library",
"version": "2.0.3",
"hash": "sha256-Prh2RPebz/s8AzHb2sPHg3Jl8s31inv9k+Qxd293ybo="
},
{
"pname": "System.Buffers",
"version": "4.4.0",
"hash": "sha256-KTxAhYawFG2V5VX1jw3pzx3IrQXRgn1TsvgjPgxAbqA="
},
{
"pname": "System.Memory",
"version": "4.5.3",
"hash": "sha256-Cvl7RbRbRu9qKzeRBWjavUkseT2jhZBUWV1SPipUWFk="
},
{
"pname": "System.Numerics.Vectors",
"version": "4.4.0",
"hash": "sha256-auXQK2flL/JpnB/rEcAcUm4vYMCYMEMiWOCAlIaqu2U="
},
{
"pname": "System.Runtime.CompilerServices.Unsafe",
"version": "4.5.2",
"hash": "sha256-8eUXXGWO2LL7uATMZye2iCpQOETn2jCcjUhG6coR5O8="
}
]
Loading