Skip to content

Add Native AOT compatibility  #683

Description

@mcdis
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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions