Repository navigation
Fix the assembly metadata extractor to use the filename instead of the full name - #3334
Conversation
31f96f5 to
790b85e
Compare
| private static T CreateInstance<T>(this AppDomain domain) | ||
| { | ||
| return (T)domain.CreateInstanceAndUnwrap(typeof(T).Assembly.FullName, typeof(T).FullName); | ||
| return (T)domain.CreateInstanceFromAndUnwrap(Assembly.GetExecutingAssembly().Location, typeof(T).FullName); |
There was a problem hiding this comment.
Please add comments why choose the CreateInstanceFromAndUnwrap instead of CreateInstanceAndUnwrap.
There was a problem hiding this comment.
Because it works when an assembly is renamed? :)
There are tests covering this scenario, and I don't see this as a complex change that requires additional explanation.
My thought is adding a comment is too much, but can add it if we think it's necessary.
| private static T CreateInstance<T>(this AppDomain domain) | ||
| { | ||
| return (T)domain.CreateInstanceAndUnwrap(typeof(T).Assembly.FullName, typeof(T).FullName); | ||
| return (T)domain.CreateInstanceFromAndUnwrap(Assembly.GetExecutingAssembly().Location, typeof(T).FullName); |
There was a problem hiding this comment.
Given nuget.exe is ILMerged, it probably doesn't matter, but would keeping the typeof(T) be a bit safer, rather than Assembly.GetExecutingAssembly()?
There was a problem hiding this comment.
Technically yeah, if anyone ever moves these types around it would be safer, but there's a test to catch this.
If you care I can change it but I'd reallly hate to try to fight with CI because of a change like that :D
lmk, this merge is not time critical so we can go through the CI churn if necessary.
There was a problem hiding this comment.
@zivkan Do you care about this or should I merge?
Bug
Fixes: NuGet/Home#4234
Regression: yes
Fix
Details:
Use CreateInstanceFromAndUnwrap instead of CreateInstanceAndUnwrap to allow the assembly resolution to work when the exe is renamed.
Testing/Validation
Tests Added: Yes
Reason for not adding tests:
Validation: Manual, tests