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
Copy file name to clipboardExpand all lines: docs/core/compatibility/reflection/10.0/ireflect-damt-annotations.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,19 +7,19 @@ ai-usage: ai-generated
7
7
8
8
# Replace DAMT.All with more restricted annotation on InvokeMember/FindMembers/DeclaredMembers
9
9
10
-
Starting in .NET 10, the <xref:System.Reflection> APIs <xref:System.Reflection.IReflect.InvokeMember%2A>, <xref:System.Reflection.IReflect.GetMembers%2A>, and <xref:System.Reflection.TypeInfo.DeclaredMembers?displayProperty=nameWithType> have been updated to use more restricted annotations instead of <xref:System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All?displayProperty=nameWithType>. This change affects scenarios where developers implement the <xref:System.Reflection.IReflect> interface or derive from <xref:System.Reflection.TypeInfo>. The previous use of `DAMT.All` was overly permissive and could lead to unintended behavior, such as capturing interface methods implemented by a class or generating warnings due to unsafe reflection calls.
10
+
Starting in .NET 10, the <xref:System.Reflection> APIs <xref:System.Reflection.IReflect.InvokeMember%2A>, <xref:System.Type.FindMembers%2A?displayProperty=nameWithType>, and <xref:System.Reflection.TypeInfo.DeclaredMembers?displayProperty=nameWithType> have been updated to use more restricted annotations instead of <xref:System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All?displayProperty=nameWithType>. This change affects scenarios where developers implement the <xref:System.Reflection.IReflect> interface or derive from <xref:System.Reflection.TypeInfo>. The previous use of `DAMT.All` was overly permissive and could lead to unintended behavior, such as capturing interface methods implemented by a class or generating warnings due to unsafe reflection calls.
11
11
12
12
## Version introduced
13
13
14
14
.NET 10 Preview 1
15
15
16
16
## Previous behavior
17
17
18
-
The <xref:System.Reflection.IReflect.InvokeMember%2A>, <xref:System.Reflection.IReflect.GetMembers%2A>, and <xref:System.Reflection.TypeInfo.DeclaredMembers?displayProperty=nameWithType> APIs used the <xref:System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All?displayProperty=nameWithType> annotation, which was overly permissive. This could result in capturing additional members, such as interface methods implemented by a class, and potentially cause runtime warnings or unsafe reflection calls.
18
+
The <xref:System.Reflection.IReflect.InvokeMember%2A>, <xref:System.Type.FindMembers%2A?displayProperty=nameWithType>, and <xref:System.Reflection.TypeInfo.DeclaredMembers?displayProperty=nameWithType> APIs used the <xref:System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All?displayProperty=nameWithType> annotation, which was overly permissive. This could result in capturing additional members, such as interface methods implemented by a class, and potentially cause runtime warnings or unsafe reflection calls.
19
19
20
20
## New behavior
21
21
22
-
The <xref:System.Reflection.IReflect.InvokeMember%2A>, <xref:System.Reflection.IReflect.GetMembers%2A>, and <xref:System.Reflection.TypeInfo.DeclaredMembers?displayProperty=nameWithType> APIs now use more restricted annotations, which provide better control over the members captured during reflection. Developers implementing <xref:System.Reflection.IReflect> or deriving from <xref:System.Reflection.TypeInfo> must update their annotations to match the new behavior.
22
+
The <xref:System.Reflection.IReflect.InvokeMember%2A>, <xref:System.Type.FindMembers%2A?displayProperty=nameWithType>, and <xref:System.Reflection.TypeInfo.DeclaredMembers?displayProperty=nameWithType> APIs now use more restricted annotations, which provide better control over the members captured during reflection. Developers implementing <xref:System.Reflection.IReflect> or deriving from <xref:System.Reflection.TypeInfo> must update their annotations to match the new behavior.
23
23
24
24
The following code snippet shows an example of the required annotation for implementing <xref:System.Reflection.IReflect.InvokeMember%2A>:
25
25
@@ -47,5 +47,5 @@ For more information on `DynamicallyAccessedMembers` annotations and their usage
0 commit comments