You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Assembly.Location is strictly better than Assembly.CodeBase.
Assembly.CodeBase is an obsolete property. The only reason why it was included in .NET Core was .NET Framework compatibility. The original purpose of Assembly.CodeBase was CAS (Code Access Security). It was meant to describe where the assembly was downloaded from for the Internet Zone security checks. It also explains some of its weird behaviors. For example, if the assembly is loaded as byte array, it returns the location of the caller of the Assembly.Load method.
Just out of curiosity: Since those APIs are part of .NET Standard, what implications does marking APIs as obsolete have for .NET Standard?
Since in .NET Standard, APIs cannot be removed, only added, does that mean you will only obsolete those APs but never remove them? Or will .NET Standard itself become obsolete due to the unification in .NET 5.
I started looking at this, but need a little clarification as I'm unfamiliar with the code structure.
With my change, I'm getting the following errors where CodeBase / EscapedCodeBase are used elsewhere (DesigntimeLicenseContext, Helper.Win32Unix, RoAssembly). Can I please get some tips on the best way to resolve these?
System\ComponentModel\Design\DesigntimeLicenseContext.cs(88,56): error CS0618: 'Assembly.EscapedCodeBase' is obsolete: 'EscapedCodeBase is only included for .NET Framework compatibility. Use Location instead.' [C:\Work\dotnetruntime\src\libraries\System.ComponentModel.TypeConverter\src\System.ComponentModel.TypeConverter.csproj]
System\ComponentModel\Design\DesigntimeLicenseContext.cs(111,45): error CS0618: 'Assembly.EscapedCodeBase' is obsolete: 'EscapedCodeBase is only included for .NET Framework compatibility. Use Location instead.' [C:\Work\dotnetruntime\src\libraries\System.ComponentModel.TypeConverter\src\System.ComponentModel.TypeConverter.csproj]
System\IO\IsolatedStorage\Helper.Win32Unix.cs(57,36): error CS0618: 'Assembly.CodeBase' is obsolete: 'CodeBase is only included for .NET Framework compatibility. Use Location instead.' [C:\Work\dotnetruntime\src\libraries\System.IO.IsolatedStorage\src\System.IO.IsolatedStorage.csproj]
System\Reflection\TypeLoading\Assemblies\RoAssembly.cs(44,39): error CS0672: Member 'RoAssembly.CodeBase' overrides obsolete member 'Assembly.CodeBase'. Add the Obsolete attribute to 'RoAssembly.CodeBase'. [C:\Work\dotnetruntime\src\libraries\System.Reflection.MetadataLoadContext\src\System.Reflection.MetadataLoadContext.csproj]
System\Reflection\TypeLoading\Assemblies\RoAssembly.cs(45,39): error CS0672: Member 'RoAssembly.EscapedCodeBase' overrides obsolete member 'Assembly.EscapedCodeBase'. Add the Obsolete attribute to 'RoAssembly.EscapedCodeBase'. [C:\Work\dotnetruntime\src\libraries\System.Reflection.MetadataLoadContext\src\System.Reflection.MetadataLoadContext.csproj]
We should also mark it as [EditorBrowsable(Never)]
@terrajobst Is marking it as [EditorBrowsable(Never)] still valid with the new obsoletion plan? We are marking a lot of other methods obsolete, but we are not marking them as [EditorBrowsable(Never)]. What is special about this method that it deserves to be marked with [EditorBrowsable(Never)]?
Per the non-goals of the better obsoletion spec, it is not expected that we'll mark [EditorBrowsable(Never)] in conjunction with the obsoletion but that they should be independent decisions. I took the approach to not apply the EditorBrowsable attribute in the big obsoletion PR.
I recommend we remove the EditorBrowable attributes from the obsoletions here too.
Activity
terrajobst commentedon Oct 22, 2019
Video
Looks good. We should also mark it as
[EditorBrowsable(Never)].vitek-karas commentedon Oct 27, 2019
Should we also consider obsoleting
AssemblyName.CodeBase? It's not exactly the same thing, but quite related - in fact that property has no functional effect (trying to load assembly viaAssemblyNamewill ignore theCodeBaseproperty anyway: https://github.com/dotnet/coreclr/blob/master/src/System.Private.CoreLib/src/System/Reflection/Assembly.CoreCLR.cs#L63jkotas commentedon Jan 30, 2020
Assembly.EscapedCodeBaseshould be marked as obsolete as well.bitbonk commentedon Jan 30, 2020
Just out of curiosity: Since those APIs are part of .NET Standard, what implications does marking APIs as obsolete have for .NET Standard?
Since in .NET Standard, APIs cannot be removed, only added, does that mean you will only obsolete those APs but never remove them? Or will .NET Standard itself become obsolete due to the unification in .NET 5.
jkotas commentedon Jan 30, 2020
Right, we do not have plans to remove any netstandard APIs.
JoshSchreuder commentedon Jul 14, 2020
I started looking at this, but need a little clarification as I'm unfamiliar with the code structure.
With my change, I'm getting the following errors where
CodeBase/EscapedCodeBaseare used elsewhere (DesigntimeLicenseContext,Helper.Win32Unix,RoAssembly). Can I please get some tips on the best way to resolve these?Additionally, does this need something done per Better Obsoletions? How would I go about getting an
aka.msto put into list-of-obsoletions.md?jkotas commentedon Jul 14, 2020
System.ComponentModel.TypeConvertershould be switched to useAssembly.Location. The rest should use #pragmas to disable the warnings.@jeffhandley is working on the plan for better obsoletions IDs. You can leave the ID as TODO in the PR.
4 remaining items
jkotas commentedon Jul 17, 2020
@terrajobst Is marking it as
[EditorBrowsable(Never)]still valid with the new obsoletion plan? We are marking a lot of other methods obsolete, but we are not marking them as[EditorBrowsable(Never)]. What is special about this method that it deserves to be marked with[EditorBrowsable(Never)]?cc @jeffhandley
jeffhandley commentedon Jul 17, 2020
Per the non-goals of the better obsoletion spec, it is not expected that we'll mark
[EditorBrowsable(Never)]in conjunction with the obsoletion but that they should be independent decisions. I took the approach to not apply theEditorBrowsableattribute in the big obsoletion PR.I recommend we remove the
EditorBrowableattributes from the obsoletions here too.JoshSchreuder commentedon Jul 19, 2020
Updated PR with the new Obsoletion stuff, and removed the
EditorBrowsableattribute, thanks all!Mark Assembly.CodeBase / Assembly.EscapedCodeBase as obsolete (#31127) (
vitek-karas commentedon Jul 30, 2020
Should we also look into
AssemblyName.CodeBaseandAssemblyName.EscapedCodeBase- they are very similar toAssembly.CodeBase:Assembly.Load(AssemblyName)completely ignores these properties on the name.Mark Assembly.CodeBase / Assembly.EscapedCodeBase as obsolete (dotnet…
danmoseley commentedon Aug 18, 2020
Was there an answer to this question?
terrajobst commentedon Aug 18, 2020
Yes, @jkotas mentioned it above:
And the PR marked it.
vitek-karas commentedon Aug 18, 2020
What about the
AssemblyNamevariants - they return basically the exact same thing... and AFAIK are not marked right now.