Skip to content
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

Adjust remarks for Assembly.Load on .NET Core #9764

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

agocke
Copy link
Member

@agocke agocke commented Mar 26, 2024

Summary

The existing docs are only valid for .NET Framework.

Fixes #9765

@agocke agocke requested a review from a team as a code owner March 26, 2024 04:49
Copy link

Learn Build status updates of commit 38029a8:

⚠️ Validation status: warnings

File Status Preview URL Details
xml/System.Reflection/Assembly.xml ⚠️Warning View Details

xml/System.Reflection/Assembly.xml

  • Line 0, Column 0: [Warning: xref-not-found - See documentation] Cross reference not found: 'System.Reflection.AssemblyLoadContext'.
  • Line 0, Column 0: [Warning: xref-not-found - See documentation] Cross reference not found: 'System.Reflection.AssemblyLoadContext'.
  • Line 0, Column 0: [Warning: xref-not-found - See documentation] Cross reference not found: 'System.Reflection.AssemblyLoadContext'.
  • Line 0, Column 0: [Warning: xref-not-found - See documentation] Cross reference not found: 'System.Reflection.AssemblyLoadContext'.
  • Line 0, Column 0: [Warning: xref-not-found - See documentation] Cross reference not found: 'System.Reflection.AssemblyLoadContext'.

For more details, please refer to the build report.

Note: Your PR may contain errors or warnings or suggestions unrelated to the files you changed. This happens when external dependencies like GitHub alias, Microsoft alias, cross repo links are updated. Please use these instructions to resolve them.

For any questions, please:


This API is present in .NET Core for compatibility, but it is recommended to use <xref:System.Reflection.AssemblyLoadContext> overloads in .NET Core 2.0 and later.

The assembly is loaded into the default AssemblyLoadContext.
Copy link
Member

Choose a reason for hiding this comment

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


## Remarks

This API is present in .NET Core for compatibility, but it is recommended to use <xref:System.Reflection.AssemblyLoadContext> overloads in .NET Core 2.0 and later.
Copy link
Member

@jkotas jkotas Mar 26, 2024

Choose a reason for hiding this comment

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

I am not sure about this recommendation for the Assembly.Load overloads that take AssemblyName or assembly name string. I do not think that these overloads are problematic and it is typically fine to use them even in .NET Core 2.0+.

Copy link
Member

Choose a reason for hiding this comment

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

My assumption is that the typical caller of these Assembly.Load overloads wants to load the assembly into its own context. The explicit replacement of Assembly.Load(assemblyName) is AssemblyLoadContext.GetLoadContext(Assembly.GetExecutingAssembly())!.LoadFromAssemblyName(assemblyName) that is way more complicated.


This API is present in .NET Core for compatibility, but it is recommended to use <xref:System.Reflection.AssemblyLoadContext> overloads in .NET Core 2.0 and later.

The assembly is loaded into the current AssemblyLoadContext.
Copy link
Member

Choose a reason for hiding this comment

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

@@ -4128,7 +4128,17 @@ Note: In <see href="https://go.microsoft.com/fwlink/?LinkID=247912">.NET for Win
<param name="assemblyString">The long or short form of the assembly name.</param>
<summary>Loads an assembly with the specified name.</summary>
<returns>The loaded assembly.</returns>
<remarks>
<remarks FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0">
Copy link
Contributor

Choose a reason for hiding this comment

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

Remarks can't be versioned like this unfortunately. You just have to annotate them in the text itself where they are version specific.

@dotnet-policy-service dotnet-policy-service bot added the needs-author-action An issue or pull request that requires more info or actions from the author. label Mar 28, 2024
@dotnet-policy-service dotnet-policy-service bot removed the needs-author-action An issue or pull request that requires more info or actions from the author. label Apr 16, 2024
@@ -4041,6 +4041,9 @@ This property is marked obsolete starting in .NET 5, and generates a compile-tim
<format type="text/markdown"><![CDATA[

## Remarks

In .NET Core 2.0 and later, the target assembly will be loaded into the current <xref:System.Runtime.Loader.AssemblyLoadContext>. For more information on assembly loading, see <see cref="https://learn.microsoft.com/en-us/dotnet/core/dependency-loading/loading-managed#algorithm" />.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
In .NET Core 2.0 and later, the target assembly will be loaded into the current <xref:System.Runtime.Loader.AssemblyLoadContext>. For more information on assembly loading, see <see cref="https://learn.microsoft.com/en-us/dotnet/core/dependency-loading/loading-managed#algorithm" />.
In .NET Core/5+, the target assembly will be loaded into the current <xref:System.Runtime.Loader.AssemblyLoadContext>. For more information on assembly loading, see <see cref="https://learn.microsoft.com/en-us/dotnet/core/dependency-loading/loading-managed#algorithm" />.

@@ -4132,6 +4135,9 @@ Note: In <see href="https://go.microsoft.com/fwlink/?LinkID=247912">.NET for Win
<format type="text/markdown"><![CDATA[

## Remarks

In .NET Core 2.0 and later, the target assembly will be loaded into the current <xref:System.Runtime.Loader.AssemblyLoadContext>. For more information on assembly loading, see <see cref="https://learn.microsoft.com/en-us/dotnet/core/dependency-loading/loading-managed#algorithm" />.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
In .NET Core 2.0 and later, the target assembly will be loaded into the current <xref:System.Runtime.Loader.AssemblyLoadContext>. For more information on assembly loading, see <see cref="https://learn.microsoft.com/en-us/dotnet/core/dependency-loading/loading-managed#algorithm" />.
In .NET Core/5+, the target assembly will be loaded into the current <xref:System.Runtime.Loader.AssemblyLoadContext>. For more information on assembly loading, see <see cref="https://learn.microsoft.com/en-us/dotnet/core/dependency-loading/loading-managed#algorithm" />.

@@ -4236,6 +4242,8 @@ To load the correct assembly, it's recommended to call the `Load` method by pass

## Remarks

In .NET Core 2.0 and later, the target assembly will be loaded into the current <xref:System.Runtime.Loader.AssemblyLoadContext>. For more information on assembly loading, see <see cref="https://learn.microsoft.com/en-us/dotnet/core/dependency-loading/loading-managed#algorithm" />.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
In .NET Core 2.0 and later, the target assembly will be loaded into the current <xref:System.Runtime.Loader.AssemblyLoadContext>. For more information on assembly loading, see <see cref="https://learn.microsoft.com/en-us/dotnet/core/dependency-loading/loading-managed#algorithm" />.
In .NET Core/5+, the target assembly will be loaded into the current <xref:System.Runtime.Loader.AssemblyLoadContext>. For more information on assembly loading, see <see cref="https://learn.microsoft.com/en-us/dotnet/core/dependency-loading/loading-managed#algorithm" />.

The `assemblyFile` parameter must refer to a URI without escape characters. This method supplies escape characters for all invalid characters in the URI.

Before .NET 5, the following applied:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Before .NET 5, the following applied:
In .NET Framework, the following applied:

Comment on lines +5069 to +5072
This API is not supported in .NET Core 2.0 or later. It will always throw <xref:System.NotSupportedException>.

The assembly is loaded into the default AssemblyLoadContext.

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
This API is not supported in .NET Core 2.0 or later. It will always throw <xref:System.NotSupportedException>.
The assembly is loaded into the default AssemblyLoadContext.
This API is not supported in .NET Core/5+. It will always throw <xref:System.NotSupportedException>.

Copy link

Learn Build status updates of commit 3610c3e:

⚠️ Validation status: warnings

File Status Preview URL Details
xml/System.Reflection/Assembly.xml ⚠️Warning View Details

xml/System.Reflection/Assembly.xml

  • Line 0, Column 0: [Warning: xref-not-found - See documentation] Cross reference not found: 'System.Reflection.AssemblyLoadContext'.
  • Line 0, Column 0: [Warning: xref-not-found - See documentation] Cross reference not found: 'System.Reflection.AssemblyLoadContext'.
  • Line 0, Column 0: [Warning: disallowed-html-tag - See documentation] HTML tag 'see' isn't allowed. Replace it with approved Markdown or escape the brackets if the content is a placeholder.
  • Line 0, Column 0: [Warning: xref-not-found - See documentation] Cross reference not found: 'System.Reflection.AssemblyLoadContext'.
  • Line 0, Column 0: [Warning: disallowed-html-tag - See documentation] HTML tag 'see' isn't allowed. Replace it with approved Markdown or escape the brackets if the content is a placeholder.
  • Line 0, Column 0: [Warning: xref-not-found - See documentation] Cross reference not found: 'System.Reflection.AssemblyLoadContext'.
  • Line 0, Column 0: [Warning: disallowed-html-tag - See documentation] HTML tag 'see' isn't allowed. Replace it with approved Markdown or escape the brackets if the content is a placeholder.
  • Line 0, Column 0: [Warning: xref-not-found - See documentation] Cross reference not found: 'System.Reflection.AssemblyLoadContext'.
  • Line 0, Column 0: [Warning: disallowed-html-tag - See documentation] HTML tag 'see' isn't allowed. Replace it with approved Markdown or escape the brackets if the content is a placeholder.
  • Line 0, Column 0: [Warning: xref-not-found - See documentation] Cross reference not found: 'System.Reflection.AssemblyLoadContext'.
  • Line 0, Column 0: [Warning: disallowed-html-tag - See documentation] HTML tag 'see' isn't allowed. Replace it with approved Markdown or escape the brackets if the content is a placeholder.

For more details, please refer to the build report.

Note: Your PR may contain errors or warnings or suggestions unrelated to the files you changed. This happens when external dependencies like GitHub alias, Microsoft alias, cross repo links are updated. Please use these instructions to resolve them.

For any questions, please:

Copy link

Learn Build status updates of commit e78a4cc:

⚠️ Validation status: warnings

File Status Preview URL Details
xml/System.Reflection/Assembly.xml ⚠️Warning View Details

xml/System.Reflection/Assembly.xml

  • Line 0, Column 0: [Warning: disallowed-html-tag - See documentation] HTML tag 'see' isn't allowed. Replace it with approved Markdown or escape the brackets if the content is a placeholder.
  • Line 0, Column 0: [Warning: disallowed-html-tag - See documentation] HTML tag 'see' isn't allowed. Replace it with approved Markdown or escape the brackets if the content is a placeholder.
  • Line 0, Column 0: [Warning: disallowed-html-tag - See documentation] HTML tag 'see' isn't allowed. Replace it with approved Markdown or escape the brackets if the content is a placeholder.
  • Line 0, Column 0: [Warning: disallowed-html-tag - See documentation] HTML tag 'see' isn't allowed. Replace it with approved Markdown or escape the brackets if the content is a placeholder.
  • Line 0, Column 0: [Warning: disallowed-html-tag - See documentation] HTML tag 'see' isn't allowed. Replace it with approved Markdown or escape the brackets if the content is a placeholder.

For more details, please refer to the build report.

Note: Your PR may contain errors or warnings or suggestions unrelated to the files you changed. This happens when external dependencies like GitHub alias, Microsoft alias, cross repo links are updated. Please use these instructions to resolve them.

For any questions, please:

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.

Docs for Assembly.Load* are for .NET Framework, not .NET
3 participants