Skip to content

Commit 9819404

Browse files
authored
assembly name attribute breaking change (#43764)
1 parent 97a9a13 commit 9819404

File tree

3 files changed

+62
-2
lines changed

3 files changed

+62
-2
lines changed

docs/core/compatibility/7.0.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ If you're migrating an app to .NET 7, the breaking changes listed here might aff
1414
## ASP.NET Core
1515

1616
| Title | Binary compatible | Source compatible |
17-
| - | :-: | :-: |
17+
|-------|:-----------------:|:-----------------:|
1818
| [API controller actions try to infer parameters from DI](aspnet-core/7.0/api-controller-action-parameters-di.md) | ✔️ ||
1919
| [ASPNET-prefixed environment variable precedence](aspnet-core/7.0/environment-variable-precedence.md) | ✔️ | ✔️ |
2020
| [AuthenticateAsync for remote auth providers](aspnet-core/7.0/authenticateasync-anonymous-request.md) | ✔️ ||
@@ -34,9 +34,10 @@ If you're migrating an app to .NET 7, the breaking changes listed here might aff
3434
## Core .NET libraries
3535

3636
| Title | Binary compatible | Source compatible |
37-
| - | :-: | :-: |
37+
|-------|:-----------------:|:-----------------:|
3838
| [API obsoletions with default diagnostic ID](core-libraries/7.0/obsolete-apis-with-default-diagnostic.md) | ✔️ ||
3939
| [API obsoletions with non-default diagnostic IDs](core-libraries/7.0/obsolete-apis-with-custom-diagnostics.md) | ✔️ ||
40+
| [Asterisk no longer accepted for assembly name attributes](core-libraries/7.0/assembly-name-wildcard.md) | ✔️ | ✔️ |
4041
| [BinaryFormatter serialization APIs produce compiler errors](serialization/7.0/binaryformatter-apis-produce-errors.md) | ✔️ ||
4142
| [BrotliStream no longer allows undefined CompressionLevel values](core-libraries/7.0/brotlistream-ctor.md) || ✔️ |
4243
| [C++/CLI projects in Visual Studio](core-libraries/7.0/cpluspluscli-compiler-version.md) | ✔️ ||
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
title: "Breaking change: Asterisk no longer accepted for assembly name attributes"
3+
description: Learn about the breaking change in core .NET libraries in .NET 7 where assembly names no longer accept '*' as a wildcard attribute value.
4+
ms.date: 11/25/2024
5+
ai-usage: ai-assisted
6+
ms.custom: https://github.com/dotnet/docs/issues/42598
7+
---
8+
9+
# Asterisk no longer accepted for assembly name attributes
10+
11+
Prior to .NET 7, assembly names allowed specifying `*` as a wildcard value for an attribute value, which was equivalent to not specifying the value at all. This undocumented feature was removed in .NET 7.
12+
13+
## Version introduced
14+
15+
.NET 7
16+
17+
## Previous behavior
18+
19+
Previously, you could specify `*` as a value for assembly name attributes. For example, the following code succeeded:
20+
21+
```csharp
22+
Assembly.Load("System.Runtime, Version=*, PublicKeyToken=*");
23+
```
24+
25+
The asterisk had identical behavior to not specifying the attribute value at all:
26+
27+
```csharp
28+
Assembly.Load("System.Runtime");
29+
```
30+
31+
## New behavior
32+
33+
Starting in .NET 7, the following code fails with a <xref:System.IO.FileLoadException> with the error message "The given assembly name was invalid".
34+
35+
```csharp
36+
Assembly.Load("System.Runtime, Version=*, PublicKeyToken=*")
37+
```
38+
39+
## Type of breaking change
40+
41+
This change is a [behavioral change](../../categories.md#behavioral-change).
42+
43+
## Reason for change
44+
45+
The previous behavior was an undocumented feature and it wasn't consistent implemented by all .NET assembly name parsers. The undocumented feature was removed to unify the behavior of assembly name parsing throughout .NET.
46+
47+
## Recommended action
48+
49+
Omit assembly name attributes that have a wildcard value. For example, change `System.Runtime, Version=*` to just `System.Runtime`.
50+
51+
## Affected APIs
52+
53+
- <xref:System.Reflection.Assembly.Load(System.String)?displayProperty=fullName>
54+
- <xref:System.Type.GetType(System.String)?displayProperty=fullName>
55+
- <xref:System.Reflection.AssemblyName.%23ctor(System.String)?displayProperty=fullName>

docs/core/compatibility/toc.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,8 @@ items:
394394
href: core-libraries/7.0/obsolete-apis-with-default-diagnostic.md
395395
- name: API obsoletions with non-default diagnostic IDs
396396
href: core-libraries/7.0/obsolete-apis-with-custom-diagnostics.md
397+
- name: Asterisk no longer accepted for assembly name attributes
398+
href: core-libraries/7.0/assembly-name-wildcard.md
397399
- name: BrotliStream no longer allows undefined CompressionLevel values
398400
href: core-libraries/7.0/brotlistream-ctor.md
399401
- name: C++/CLI projects in Visual Studio
@@ -1362,6 +1364,8 @@ items:
13621364
href: core-libraries/7.0/obsolete-apis-with-default-diagnostic.md
13631365
- name: API obsoletions with non-default diagnostic IDs
13641366
href: core-libraries/7.0/obsolete-apis-with-custom-diagnostics.md
1367+
- name: Asterisk no longer accepted for assembly name attributes
1368+
href: core-libraries/7.0/assembly-name-wildcard.md
13651369
- name: BrotliStream no longer allows undefined CompressionLevel values
13661370
href: core-libraries/7.0/brotlistream-ctor.md
13671371
- name: C++/CLI projects in Visual Studio

0 commit comments

Comments
 (0)