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

support AOT compilation #1466

Open
mizantrop777 opened this issue Oct 30, 2024 · 4 comments
Open

support AOT compilation #1466

mizantrop777 opened this issue Oct 30, 2024 · 4 comments

Comments

@mizantrop777
Copy link

mizantrop777 commented Oct 30, 2024

What problem is this feature trying to solve?

with native AOT compilation (publish):
I'm trying to download an item from the workshop, but I'm getting an error here:

public async Task<PublishedFileDetails> GetPublishedFileDetails(uint appId, PublishedFileID pubFile)
{
    //ProtoBuf.Meta.RuntimeTypeModel.Default.AutoCompile = false;
    //ProtoBuf.Meta.RuntimeTypeModel.Default.CompileInPlace();
    var pubFileRequest = new CPublishedFile_GetDetails_Request
    {
        appid = appId
    };
    pubFileRequest.publishedfileids.Add(pubFile);

    var callback = await steamPublishedFile.GetDetails(pubFileRequest);

    if (callback.Result == EResult.OK)
    {
        var response = callback.Body;
        return response.publishedfiledetails.FirstOrDefault();
    }

    throw new Exception($"EResult {(int)callback.Result} ({callback.Result}) while retrieving file details for pubfile {pubFile}.");
}

Error: 'ProtoBuf.Serializers.RepeatedSerializer.CreateList[System.UInt64]()' is missing native code. MethodInfo.MakeGenericMethod() is not compatible with AOT compilation. Inspect and fix AOT related warnings that were generated when the app was published. For more information see https://aka.ms/nativeaot-compatibility

How would you like it to be solved?

I would like this to work with AOT compilation. I think the problem is with protobuf-net

Have you considered any alternative solutions

maybe switching to Google.protobuf will solve this problem. I tried to do it myself, but it's too difficult for me =(

That didn't help either:
ProtoBuf.Meta.RuntimeTypeModel.Default.AutoCompile = false;
ProtoBuf.Meta.RuntimeTypeModel.Default.CompileInPlace();

Additional Information

No response

@xPaw
Copy link
Member

xPaw commented Oct 30, 2024

Not much can be done about this until protobuf-net supports AOT (v4 probably), or we switch to google.protobuf

@yaakov-h
Copy link
Member

Another option I was looking into is to hand-deserialise the protos that SK2 cares about internally, but that still makes it harder for consumers like DD to also go AOT.

@xPaw
Copy link
Member

xPaw commented Oct 30, 2024

Wouldn't that be every single proto being used in all the handlers?

@yaakov-h
Copy link
Member

Yep. We could generate it, but I'd still rather a generalised approach consumers could use as well instead of something internal-only.

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

No branches or pull requests

3 participants