Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Native AOT compatibility #683

Open
mcdis opened this issue May 18, 2024 · 1 comment
Open

Add Native AOT compatibility #683

mcdis opened this issue May 18, 2024 · 1 comment

Comments

@mcdis
Copy link

mcdis commented May 18, 2024

var client = new GitLabClient("https://git.xxx.yy", "XXX");

var groupQueryAllAvailable = new GroupQuery
{
  AllAvailable = true,
};

foreach (var group in client.Groups.GetAsync(groupQueryAllAvailable))
  Console.WriteLine(group.Name);

csproj

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <PublishAot>true</PublishAot>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="NGitLab" Version="6.50.2" />
  </ItemGroup>
</Project>

Error occurs:

System.InvalidOperationException: 
'Reflection-based serialization has been disabled for this application. 
Either use the source generator APIs or explicitly 
configure the 'JsonSerializerOptions.TypeInfoResolver' property.'

Stack-trace:

   at System.Text.Json.ThrowHelper.ThrowInvalidOperationException_JsonSerializerIsReflectionDisabled()
   at System.Text.Json.JsonSerializerOptions.ConfigureForJsonSerializer()
   at System.Text.Json.JsonSerializer.GetTypeInfo(JsonSerializerOptions options, Type inputType)
   at System.Text.Json.JsonSerializer.GetTypeInfo[T](JsonSerializerOptions options)
   at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options)
   at NGitLab.Impl.Json.Serializer.Deserialize[T](String json) <-- HERE
   at NGitLab.Impl.HttpRequestor.Enumerable`1.<GetEnumerator>d__5.MoveNext() <-- HERE
   at Program.<Main>$(String[] args) in D:\imba.sandbox\gitlab-roles\gitlab-roles\Program.cs:line 12
@jairbubbles
Copy link
Collaborator

Hi @mcdis, indeed it would be great to have NGitLab ready for AOT.

I created a draft PR regarding the serialisation : #687

But there are other method calls which are problematic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants