Skip to content

Commit 48f1308

Browse files
committed
refactor(extensions): 标记 ReflectionExtensions 为过时
在现代 .NET(.NET 5+)中,Type 类已直接包含这些功能: - type.GetTypeInfo() -> 直接使用 type - type.GetGenericArguments() -> 使用实例方法 - type.IsGenericType() -> 使用 IsGenericType 属性 - type.GetProperties() -> 使用实例方法 - 等等 添加详细的迁移指南文档说明替代方案
1 parent b3bcbd8 commit 48f1308

1 file changed

Lines changed: 27 additions & 4 deletions

File tree

GameFrameX.Foundation.Extensions/ReflectionExtensions.cs

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
// GameFrameX organization and its derivative projects' copyrights, trademarks, patents, and related rights
44
// 均受中华人民共和国及相关国际法律法规保护。
55
// are protected by the laws of the People's Republic of China and relevant international regulations.
6-
//
6+
//
77
// 使用本项目须严格遵守相应法律法规及开源许可证之规定。
88
// Usage of this project must strictly comply with applicable laws, regulations, and open-source licenses.
9-
//
9+
//
1010
// 本项目采用 MIT 许可证与 Apache License 2.0 双许可证分发,
1111
// This project is dual-licensed under the MIT License and Apache License 2.0,
1212
// 完整许可证文本请参见源代码根目录下的 LICENSE 文件。
1313
// please refer to the LICENSE file in the root directory of the source code for the full license text.
14-
//
14+
//
1515
// 禁止利用本项目实施任何危害国家安全、破坏社会秩序、
1616
// It is prohibited to use this project to engage in any activities that endanger national security, disrupt social order,
1717
// 侵犯他人合法权益等法律法规所禁止的行为!
@@ -20,7 +20,7 @@
2020
// Any legal disputes and liabilities arising from secondary development based on this project
2121
// 本项目组织与贡献者概不承担。
2222
// shall be borne solely by the developer; the project organization and contributors assume no responsibility.
23-
//
23+
//
2424
// GitHub 仓库:https://github.com/GameFrameX
2525
// GitHub Repository: https://github.com/GameFrameX
2626
// Gitee 仓库:https://gitee.com/GameFrameX
@@ -33,6 +33,29 @@
3333

3434
namespace GameFrameX.Foundation.Extensions;
3535

36+
/// <summary>
37+
/// 反射扩展类,/// </summary>
38+
/// <remarks>
39+
/// 此类中的所有扩展方法已过时。在现代 .NET(.NET 5+)中,Type 类已直接包含这些功能,
40+
/// 无需通过扩展方法调用。请直接使用 Type 类的实例方法/属性。
41+
///
42+
/// 迁移指南:
43+
/// <list type="bullet">
44+
/// <item><description>type.GetTypeInfo() -&gt; 直接使用 type(无需调用)</description></item>
45+
/// <item><description>type.GetGenericArguments() -&gt; type.GetGenericArguments()(使用实例方法)</description></item>
46+
/// <item><description>type.IsGenericType() -&gt; type.IsGenericType(使用属性)</description></item>
47+
/// <item><description>type.GetProperties() -&gt; type.GetProperties()(使用实例方法)</description></item>
48+
/// <item><description>type.GetProperty(name) -&gt; type.GetProperty(name)(使用实例方法)</description></item>
49+
/// <item><description>type.GetField(name) -&gt; type.GetField(name)(使用实例方法)</description></item>
50+
/// <item><description>type.IsEnum() -&gt; type.IsEnum(使用属性)</description></item>
51+
/// <item><description>type.GetMethod(...) -&gt; type.GetMethod(...)(使用实例方法)</description></item>
52+
/// <item><description>type.GetConstructor(types) -&gt; type.GetConstructor(types)(使用实例方法)</description></item>
53+
/// <item><description>type.IsValueType() -&gt; type.IsValueType(使用属性)</description></item>
54+
/// <item><description>type.IsEntity() -&gt; type.IsClass(使用属性)</description></item>
55+
/// </list>
56+
/// </remarks>
57+
[Obsolete("此扩展类中的所有方法在现代 .NET 中已不再需要,请直接使用 Type 类的实例方法/属性。")]
58+
3659
/// <summary>
3760
/// 反射扩展类,提供了一系列用于反射操作的扩展方法
3861
/// </summary>

0 commit comments

Comments
 (0)