-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Mark Assembly.CodeBase / Assembly.EscapedCodeBase as obsolete (#31127) #39261
Mark Assembly.CodeBase / Assembly.EscapedCodeBase as obsolete (#31127) #39261
Conversation
I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label. |
...em.ComponentModel.TypeConverter/src/System/ComponentModel/Design/DesigntimeLicenseContext.cs
Outdated
Show resolved
Hide resolved
...em.ComponentModel.TypeConverter/src/System/ComponentModel/Design/DesigntimeLicenseContext.cs
Outdated
Show resolved
Hide resolved
...em.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Assemblies/RoAssembly.cs
Outdated
Show resolved
Hide resolved
16d8a3f
to
a0562f3
Compare
...em.ComponentModel.TypeConverter/src/System/ComponentModel/Design/DesigntimeLicenseContext.cs
Outdated
Show resolved
Hide resolved
...em.ComponentModel.TypeConverter/src/System/ComponentModel/Design/DesigntimeLicenseContext.cs
Outdated
Show resolved
Hide resolved
...entModel.Composition/tests/System/ComponentModel/Composition/Hosting/AssemblyCatalogTests.cs
Outdated
Show resolved
Hide resolved
...em.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Assemblies/RoAssembly.cs
Outdated
Show resolved
Hide resolved
a0562f3
to
34c156d
Compare
67d8bdf
to
9f63055
Compare
src/libraries/System.Reflection.Emit/ref/System.Reflection.Emit.csproj
Outdated
Show resolved
Hide resolved
1af9f58
to
b560587
Compare
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.
One tweak needed in a ref file; otherwise the obsoletion looks good. I am not familiar with the functional changes being made though, so we need to get another reviewer for those changes.
Thanks!
@@ -9,6 +9,7 @@ namespace System.Reflection.Emit | |||
public sealed partial class AssemblyBuilder : System.Reflection.Assembly | |||
{ | |||
internal AssemblyBuilder() { } | |||
[Obsolete("CodeBase and EscapedCodeBase are only included for .NET Framework compatibility. Use Location instead.", DiagnosticId = "SYSLIB0012", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] |
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.
Ref sources also need to fully qualify System.ObsoleteAttribute
.
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.
@jeffhandley your one from #39269 didn't have this which I copied 😄
329f0db#diff-ef696a2876ba83b0d62cc5506022975c
Do you want me to update both?
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.
Have updated both of these to use System.ObsoleteAttribute
...em.ComponentModel.TypeConverter/src/System/ComponentModel/Design/DesigntimeLicenseContext.cs
Show resolved
Hide resolved
// Assemblies loaded in memory return empty string from Location. | ||
// The code below throws an exception if this happens. | ||
// Catching exceptions here is not a bad thing. | ||
if (asm.Location == string.Empty) |
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.
It would be nice to cache asm.Location
in a local to avoid calling it twice.
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.
Have updated
// The code below throws an exception if this happens. | ||
// Catching exceptions here is not a bad thing. |
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.
// The code below throws an exception if this happens. | |
// Catching exceptions here is not a bad thing. |
These comments do not look helpful.
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.
Removed comment
// Location is not supported by emitted assemblies and this will throw an exception | ||
// down below. | ||
else if (!resourceAssembly.IsDynamic && resourceAssembly.Location != string.Empty) |
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.
// Location is not supported by emitted assemblies and this will throw an exception | |
// down below. | |
else if (!resourceAssembly.IsDynamic && resourceAssembly.Location != string.Empty) | |
else if (!resourceAssembly.IsDynamic) |
I do not think it is necessary to check for empty location up-front here.
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.
@jkotas do you think it should be something more like
else if (!resourceAssembly.IsDynamic)
{
// Emitted assemblies return empty string from Location.
var location = asm.Location;
if (location != string.Empty)
{
string fileName = new FileInfo(location).Name;
...
}
}
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 think it can be:
else
{
string location = asm.Location;
if (location != string.Empty)
{
string fileName = Path.GetFileName(location);
...
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.
Have updated as suggested, thanks!
29f2876
to
0f514c4
Compare
0f514c4
to
43a8c26
Compare
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.
Thank you!
No description provided.