Skip to content

Gdi+ related errors are now wrapped in a specific exception with more detailed information #502

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

Merged
merged 3 commits into from
Jun 27, 2019

Conversation

gvheertum
Copy link
Member

Reference Issue

Fixes #501

What does this implement/fix? Explain your changes.

SvgDocument.Open now has some additional checks to see if the error might be related to the gdi+ issues described in #501. We scan the exception for the presence of a certain type of exception and message in the exception. The specific exceptions is re-thrown (while other exceptions are only logged and not thrown) and is handled at the end of the Load function. If we are handling the specific gdi+ exception, we will wrap it in an exception with a bit more detail.

Any other comments?

Added a commented ItemGroup for the CoreCompat package in the Svg.csproj file. This is commented by default, to enable building/running on Mac uncomment the ItemGroup.

@gvheertum gvheertum changed the title Gdiplus mac Gdi+ related errors are now wrapped in a specific exception with more detailed information Jun 26, 2019
@gvheertum
Copy link
Member Author

I just noticed that this also pushed the netcore changes... This one is kinda related to that branch, so once that is merged I think this one can be merge in.

@mrbean-bremen
Copy link
Member

Hm, I'm not sure that it is a good idea to mix these branches... the netcore branch seems to be branched from another test branch I made earlier for the netstandard stuff, and I'm not sure how that merge would work out - there has been the netstandard stuff added, adapted, partly removed again... I would prefer to have a cleaner PR here, otherwise it is difficult to understand the changes.
I can check that tonight, maybe I can merge your changes, and the relevant changes @tebjan made separately.
Thanks for the PR by the way - good to have someone getting this to work on MacOs!

@tebjan
Copy link
Contributor

tebjan commented Jun 27, 2019

i can merge this PR into the netcore branch, make a new prerelease and see how it works.

@tebjan tebjan changed the base branch from master to netcore2.2 June 27, 2019 14:18
@tebjan tebjan merged commit 13e9855 into svg-net:netcore2.2 Jun 27, 2019
@tebjan
Copy link
Contributor

tebjan commented Jun 27, 2019

also merged master into the netcore branch, new nuget preview is ready to test:
https://www.nuget.org/packages/Svg/3.0.9-g6ea47b4039

@mrbean-bremen
Copy link
Member

Thanks @tebjan! I'm still a bit unclear what are the changes of the .NetCore2.2 branch w/r to master (except the automatic git versioning). Shall we merge this change also to master?

@tebjan
Copy link
Contributor

tebjan commented Jun 27, 2019

it's based on the older netstadard2.0 branch, has the new SDK style project format with automatic nuget build, auto versioning and the netcore build target. if we get positive feedback from @gvheertum about his changes for macOS we can merge back, i'd say.

@gvheertum gvheertum deleted the gdiplus-mac branch June 27, 2019 14:50
@mrbean-bremen
Copy link
Member

ah ok - I had abandonded that branch in favor of the changes for .NetCore2.2, and probably should have deleted it, as it has diverged from master. We have to be careful how to merge back these changes to master, but I agree that it would be a good idea to do after the feedback.

@gvheertum
Copy link
Member Author

it's based on the older netstadard2.0 branch, has the new SDK style project format with automatic nuget build, auto versioning and the netcore build target. if we get positive feedback from @gvheertum about his changes for macOS we can merge back, i'd say.

Looks good to me. Did a testrun on MacOs and it seems to work as expected. So you've got my blessing. :)

I still have to do some research on how to get it as easy as possible for MacOs to get it compiling, maybe I'll add a platform specific csproj or buildstep somewhere, because currently I have to remove the net35 target from the project file before I can build with the additional CoreCompat package (as long as the net35 is in the frameworks the package will yield errors). But that's something for another time (I still have to get used to VSCode and working with csproj files, because I am a bit too used to the VS 2017/2019 way of working).

@tebjan
Copy link
Contributor

tebjan commented Jun 27, 2019

Did a testrun on MacOs and it seems to work as expected.

did you use the nuget or built from source?

@gvheertum
Copy link
Member Author

Did a testrun on MacOs and it seems to work as expected.

did you use the nuget or built from source?

Source build, do you want me to test the NuGet (that'll take a bit longer since I don't have MacOs projects/builds that use the Svg package, only been playing with the unittests directly from the repo sources).

@gvheertum
Copy link
Member Author

@tebjan I found a way to test the NuGet version also (changed the unit-test project to use the NuGet instead of the project reference). That however required me to also put the package include for the CoreCompat in the project file (since that one was previously carried over from the Svg project include).

But I now can confirm that both the nuget and the source behave as expected.

@mrbean-bremen
Copy link
Member

I created a separate PR (#503) to merge the changes together with the .NetCore changes made by @tebjan, to be sure to not get any leftovers from my botched netstandard branch. Still works nicely under Windows :)

catch (Exception ex)
{
Trace.TraceWarning(ex.Message);
if(ExceptionCaughtIsGdiPlusRelated(ex)) { throw; } //Gdi+ errors should be rethrown
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block is application of styles.
In my understanding, I think that GDI+ is irrelevant in this process.

Is this necessary ?

@gvheertum
Copy link
Member Author

gvheertum commented Jul 9, 2019 via email

@H1Gdev
Copy link
Contributor

H1Gdev commented Jul 10, 2019

@gvheertum

Thanks for your response.

I think leaving it in is not that much of an issue, if so I think that the check can be removed there.

If this is not a direct solution to this issue, I think that it should be removed.
Increasing insurance code significantly reduces readability.

@gvheertum
Copy link
Member Author

gvheertum commented Jul 10, 2019 via email

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

Successfully merging this pull request may close these issues.

4 participants