octokit.net
octokit.net copied to clipboard
If used in IL-merged assembly, GetVersionInformation crashes octokit connection
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;
}
Hi @Licho1,
Would this be because your assembly doesn't have an InformationalVersionAttribute
set or is it not even possible to work around?
It indeed is because the final assembly is missing and AssemblyInformationalVersion and you can add this attribute to your assembly as a workaround.
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.
Not to necro or anything, but since this is still open I will concur: As of 02/21/22, this is still present.
👋 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!