-
Notifications
You must be signed in to change notification settings - Fork 753
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
Fix breaking dll rename of SharpZipLib - issue #2095 #2118
Fix breaking dll rename of SharpZipLib - issue #2095 #2118
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this solution. Very clean 👍
I suppose we could revert #2019 once this is merged?
} | ||
catch | ||
{ | ||
/* ignore */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In what circumstances is an exception here possible? Swallowing it will mean that the redirect will not fire, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is to ensure that if anything at all goes wrong when registering this, it won't break DNN.
{ | ||
// only check for access to old SharpZipLib | ||
if (!args.Name.StartsWith(OldName)) | ||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add braces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is that the DNN convention? or your personal preference? just to be sure...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a DNN convention, given that no official conventions exist. It is however a sensible choice always to add curly brackets and also a StyleCop inspection, enabled by default I think
/// </summary> | ||
public static void RegisterSharpZipLibRedirect() | ||
{ | ||
if (AlreadyRun) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add braces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DNN convention?
@tpluscode it doesn't look like #2019 was ever merged |
Oh, true. Good :) |
private static Assembly Handler(object sender, ResolveEventArgs args) | ||
{ | ||
// only check for access to old SharpZipLib | ||
if (!args.Name.StartsWith(OldName)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add StringComparison.Ordinal
as second parameter to StartsWith
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason this is using StartsWith
instead of Equals
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, will do. I think I originally used the name without DLL, so equals should be ok. i'll change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// final solution taken from https://raw.githubusercontent.com/2sic/2sxc/master/2sxc%20Dnn/Dnn920/SharpZipLibRedirect.cs | ||
/// read the readme.md in this folder for more info | ||
/// </remarks> | ||
public class SharpZipLibRedirect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not real excited about this being public
, seems like it will confuse folks that there's a DotNetNuke.Services.Zip
namespace that doesn't have anything useful for them inside of it. Should this just live next to (or inside of) DotNetNukeHttpApplication
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, internal would be better if we can
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok great suggestion! I found that I can make it internal
@@ -0,0 +1,11 @@ | |||
# Zip Services in DNN | |||
|
|||
DNN uses SharpZipLib as the zip system of choice. Because of this, it is bundled with DNN. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer that this be included as comments in the SharpZipLibRedirect
class, rather than as a markdown document.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer markdown - because often explanations will need multiple code files, but I'll put the same info into the class file as well - ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with the rest of the project I would ONLY have this in the code comments. Multi-line XML comments can support HTML formatting and will be automatically built into the documentation. THis is used universally across the entire solution
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mitchelsellers ok, I just moved all the docs into code-comments only
Thanks for the thorough review! I'm updating everything as discussed, after testing I'll republish... |
Changes made and published, pls re-check, thx! |
I'm guessing we need to update this function as well with both assembly names? or change the Dnn.Platform/DNN Platform/Library/Framework/Reflections/TypeLocator.cs Lines 105 to 112 in 6387dd1
|
@tpluscode @bdukes @ohine I believe I did everything you guys asked for. Ok for now, or anything still pending? |
/// </remarks> | ||
internal class SharpZipLibRedirect | ||
{ | ||
internal static bool AlreadyRun { get; private set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I notice this changed from public
to internal
. But does it really have to be accessible from anywhere? I'd expect such property to be private
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would leave it in for debugging - in case this is ever questioned. But I can change it if that is preferred.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No strong opinion here. Let's leave it as is
Good catch @ohine, I'd just add both |
@iJungleboy I've never seen that code either, I was researching the SQL dependency issue (#2116) and stumbled across that function in the process. We should add both of the assembly names to that function. If you can do it in this pull request that would be great, if not I'll start up another pull request with that change. |
@ohine I would rather not touch that - I don't know anything about it and it's not related to the sharpziplib issue directly - ok? I believe we've covered everything - shall we finish the pull @bdukes and @tpluscode ? |
Maybe @ashishpd might know some history on that function/class and it's purpose in the platform? Dnn.Platform/DNN Platform/Library/Framework/Reflections/TypeLocator.cs Lines 69 to 124 in 6387dd1
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved. @ohine is going to create a secondary PR to fix the identified issue
Created PR #2126 with the fix to the |
Summary
Fixes #2095 by registering an assembly-resolver that is used by .net when an assembly isn't found. So if something tries to get SharpZipLib.dll and fails, this resolver will kick in and tell .net that it's in the new assembly
ICSharpCode.SharpZipLib
.I also added a readme.md explaining it some more, and the "register assembly handler" must happen very early, which is why I needed to put it into the application start.