libgit2 / libgit2/libgit2sharp
Please consider adding AOT support for .Diff.Compare<T>()
まだ誰も着手していません。
- 主要言語
- C#
- スター
- 3.5k
- フォーク
- 925
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
When utilizing libgit2sharp in combination with the .NET 8 PublishAot feature, all repository creation, file staging and committing operations are successful, however, the git diff function throws a NullReferenceException.
Is there a way to get this working under AOT?
Steps To Reproduce:
- Create a .NET 8 console project
dotnet new console -o aot-test cd aot-test - Adjust aot-test.csproj to include libgit2sharp reference and activate PublishAot feature
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>net8.0</TargetFramework> <RootNamespace>aot_test</RootNamespace> <ImplicitUsings>enable</ImplicitUsings> <Nullable>enable</Nullable> <PublishAot>true</PublishAot> </PropertyGroup> <ItemGroup> <PackageReference Include="libgit2sharp" Version="0.29.0" /> </ItemGroup> </Project> - Insert the following code into Progmram.cs:
using LibGit2Sharp;
var path = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
Directory.CreateDirectory(path);
Repository.Init(path, false);
var userName = "Tester";
var email = "tester@mail.net";
Func<Signature> getSignature = () => new Signature(userName, email, DateTimeOffset.Now);
using (var repo = new Repository(path))
{
var fileName = "test.txt";
var filePath = Path.Combine(path, fileName);
File.WriteAllText(filePath, "Hello, World!");
Commands.Stage(repo, fileName);
var commit1 = repo.Commit("Initial commit", getSignature(), getSignature());
File.AppendAllText(filePath, "\nAppended Line");
Commands.Stage(repo, fileName);
var commit2 = repo.Commit("Second commit", getSignature(), getSignature());
Console.WriteLine($"Commits Count {repo.Commits.Count()}");
var changes = repo.Diff.Compare<Patch>(commit1.Tree, commit2.Tree);
Console.WriteLine($"Diff Changes Count = {changes.Count()}");
}
- Use
dotnet runfor testing, it will display:
Commits Count 2
Diff Changes Count = 1
- Use
dotnet publish,.\bin\Release\net8.0\win-x64\publish\aot-test.exeto test the native AOT version, it throws an exception onrepo.Diff.Compare<Patch>():
Commits Count 2
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at aot-test!<BaseAddress>+0x19af4c
at aot-test!<BaseAddress>+0x199437
Current Behavior:
The native AOT functions for repository creation, file staging, and committing operations are functional, but the git diff function is not.
Anticipated Behavior:
Please consider adding AOT support for the git diff API.
Version of LibGit2Sharp (release number or SHA1)
0.29.0
Operating system(s) tested; .NET runtime tested
- OS: Windows 11
- .NET: 8.0.100
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
.NET 8 コンソールプロジェクトとその aot-test.csproj/Program.cs のセットアップから始め、dotnet publish と repo.Diff.Compare(commit1.Tree, commit2.Tree) を使って失敗を再現します。ネイティブ AOT 実行可能ファイルが diff 呼び出しを完了し、NullReferenceException をスローする代わりに 1 件の diff 変更を報告すれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- csharp
- 領域
- api
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100