octokit.net icon indicating copy to clipboard operation
octokit.net copied to clipboard

If used in IL-merged assembly, GetVersionInformation crashes octokit connection

Open Licho1 opened this issue 6 years ago • 4 comments

We are building single executable using ilmerge. After we do this, octokit crashes with:

System.NullReferenceException: Object reference not set to an instance of an object.
   at Octokit.Connection.GetVersionInformation()
   at Octokit.Connection.FormatUserAgent(ProductHeaderValue productInformation)
   at Octokit.Connection..ctor(ProductHeaderValue productInformation, Uri baseAddress, ICredentialStore credentialStore, IHttpClient httpClient, IJsonSerializer serializer)
   at Octokit.Connection..ctor(ProductHeaderValue productInformation, Uri baseAddress, ICredentialStore credentialStore)

It is due to bug here:

private static string _versionInformation;
        static string GetVersionInformation()
        {
            if (string.IsNullOrEmpty(_versionInformation))
            {
                _versionInformation = typeof(IGitHubClient)
                    .GetTypeInfo()
                    .Assembly
                    .GetCustomAttribute<AssemblyInformationalVersionAttribute>()
                    .InformationalVersion;
            }

            return _versionInformation;
        }

Licho1 avatar Mar 10 '18 07:03 Licho1

Hi @Licho1,

Would this be because your assembly doesn't have an InformationalVersionAttribute set or is it not even possible to work around?

ryangribble avatar Mar 10 '18 08:03 ryangribble

It indeed is because the final assembly is missing and AssemblyInformationalVersion and you can add this attribute to your assembly as a workaround.

Licho1 avatar Mar 10 '18 13:03 Licho1

Marking this one as a bug, but because there's a workaround and plenty of other work I'm not sure when we'll get to it.

shiftkey avatar Sep 10 '19 21:09 shiftkey

Not to necro or anything, but since this is still open I will concur: As of 02/21/22, this is still present.

TopazTK avatar Feb 20 '22 21:02 TopazTK

👋 Hey Friends, this issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please add the Status: Pinned label if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!

github-actions[bot] avatar Jul 24 '23 01:07 github-actions[bot]