PandaWood/ExceptionReporter.NET

Feature Request - Net6 support

OGMichel opened this issue · 7 comments

Hello,

We are using ExceptionReporter in one of our projects and we are currently migrating it to .Net6.

As a consequence, we created a fork and tried our own migration in the following branch: https://github.com/OGMichel/ExceptionReporter.NET/tree/Net6

Is it possible to integrate our modifications in the main branch ?
If so, what is the correct process to follow ?

Is it possible to integrate our modifications in the main branch ? If so, what is the correct process to follow ?

Firstly, you should mention that you commented out some unit tests
(for example ExceptionReporter_Tests)

Also I have found this comment from the maintainer about problems with behavioral and API compatibility:

I'm no longer convinced this is actually necessary, apart from the need to support .NET5 with it's own issues (eg deployment API is gone), so I'm going to close this one

link to comment

Yeah support for the Deployment API (used to interact with ClickOnce version info) is completely removed in .NET5 and I can't see any way to provide a backwards compatible migration to it.
I actually rely on Deployment API, in my current company, so merging these .NET5/6 changes would prevent me from using the library.
I was hoping I could add some kind of #if NET5 precompile options to work it out, but I can't see how to do that in this case, where we still need to add/include references to the library.
addendum... I'm not sure if .NET6 fixes this

PS The DeploymentAPI I referred to is in ReportGenerator.cs (line 47 right now)
It requires a reference to System.Deployment.Application

private string GetAppVersion()
{
	return ApplicationDeployment.IsNetworkDeployed ? 
		ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString() : _info.AppAssembly.GetName().Version.ToString();
}

Firstly, you should mention that you commented out some unit tests (for example ExceptionReporter_Tests)

Sorry I deactivated some of the tests during the working process and forgot to decomment them. I have corrected this issue thanks to your feedback.

Regarding the System.Deployment.Application, I have not found any way to get around its removal in .Net5 and 6.

Is it possible some precompile options, like below, could solve your issues ?

#if !NET5_0_OR_GREATER
using System.Deployment.Application;
#endif
private string GetAppVersion()
{
#if !NET5_0_OR_GREATER
    return ApplicationDeployment.IsNetworkDeployed ? 
        ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString() : _info.AppAssembly.GetName().Version.ToString();
#else
    return _info.AppAssembly.GetName().Version?.ToString() ?? "";
#endif
}

Hey, yeah I wish that code could work - the only problem I think I had from there is including a reference to the System.Deployment.Application assembly - I think I hit a brickwall with conditional assembly referencing... (ie in the project file)

Hey,

There are conditional references for csproj file :)

In this case I suppose, you are looking for :
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
and
<ItemGroup Condition=" '$(TargetFramework)' == 'net5.0' ">
please see Microsoft documentation : https://docs.microsoft.com/en-us/dotnet/standard/frameworks

You could do the same thing using

<Choose>
 <When Condition=" '$(TargetFramework)' == 'net5.0' ">
  <ItemGroup>
...

But this solution seems less clear then add condition inside ItemGroup.

I hope this could help.
Have a good week.

Thanks for that, I'll have another try, based on your help/links and see if I can get any further.