Skip to content

Commit

Permalink
Rewrite all code references in XML code to a form that can be checked…
Browse files Browse the repository at this point in the history
… by the compiler
  • Loading branch information
gehongyan committed Sep 16, 2024
1 parent c2ed1e1 commit 686515b
Show file tree
Hide file tree
Showing 151 changed files with 852 additions and 852 deletions.
18 changes: 9 additions & 9 deletions src/Kook.Net.CardMarkup/CardMarkupSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static class CardMarkupSerializer
/// </summary>
/// <param name="file"> UTF-8 编码的 XML 文件 </param>
/// <param name="token"> 取消令牌。 </param>
/// <returns> 一个表示异步解析操作的任务。任务的结果包含一个可用于枚举 <see cref="ICard"/> 成员的 <see cref="T:System.Collections.Generic.IEnumerable`1"/>。 </returns>
/// <returns> 一个表示异步解析操作的任务。任务的结果包含一个可用于枚举 <see cref="ICard"/> 成员的 <see cref="System.Collections.Generic.IEnumerable{T}"/>。 </returns>
public static async Task<IEnumerable<ICard>> DeserializeAsync(FileInfo file, CancellationToken token = default)
{
#if NETSTANDARD2_0 || NET462
Expand All @@ -36,7 +36,7 @@ public static async Task<IEnumerable<ICard>> DeserializeAsync(FileInfo file, Can
/// </summary>
/// <param name="xmlText"> UTF-8 编码的 XML 文本。 </param>
/// <param name="token"> 取消令牌。 </param>
/// <returns> 一个表示异步解析操作的任务。任务的结果包含一个可用于枚举 <see cref="ICard"/> 成员的 <see cref="T:System.Collections.Generic.IEnumerable`1"/>。 </returns>
/// <returns> 一个表示异步解析操作的任务。任务的结果包含一个可用于枚举 <see cref="ICard"/> 成员的 <see cref="System.Collections.Generic.IEnumerable{T}"/>。 </returns>
public static async Task<IEnumerable<ICard>> DeserializeAsync(string xmlText, CancellationToken token = default)
{
using MemoryStream xmlStream = new(Encoding.UTF8.GetBytes(xmlText));
Expand All @@ -49,7 +49,7 @@ public static async Task<IEnumerable<ICard>> DeserializeAsync(string xmlText, Ca
/// </summary>
/// <param name="xmlStream"> UTF-8 编码的 XML 流。 </param>
/// <param name="token"> 取消令牌。 </param>
/// <returns> 一个表示异步解析操作的任务。任务的结果包含一个可用于枚举 <see cref="ICard"/> 成员的 <see cref="T:System.Collections.Generic.IEnumerable`1"/>。 </returns>
/// <returns> 一个表示异步解析操作的任务。任务的结果包含一个可用于枚举 <see cref="ICard"/> 成员的 <see cref="System.Collections.Generic.IEnumerable{T}"/>。 </returns>
public static async Task<IEnumerable<ICard>> DeserializeAsync(Stream xmlStream, CancellationToken token = default)
{
using XmlReader xmlReader = XmlReader.Create(xmlStream, new XmlReaderSettings
Expand Down Expand Up @@ -122,7 +122,7 @@ public static async Task<IEnumerable<ICard>> DeserializeAsync(Stream xmlStream,
/// 元素,可以包含多个 <c>card</c> 元素。
/// </summary>
/// <param name="file"> UTF-8 编码的 XML 文件 </param>
/// <returns> 一个可用于枚举 <see cref="ICard"/> 成员的 <see cref="T:System.Collections.Generic.IEnumerable`1"/>。 </returns>
/// <returns> 一个可用于枚举 <see cref="ICard"/> 成员的 <see cref="System.Collections.Generic.IEnumerable{T}"/>。 </returns>
public static IEnumerable<ICard> Deserialize(FileInfo file)
{
using FileStream fs = file.OpenRead();
Expand All @@ -134,7 +134,7 @@ public static IEnumerable<ICard> Deserialize(FileInfo file)
/// 元素,可以包含多个 <c>card</c> 元素。
/// </summary>
/// <param name="xmlText"> UTF-8 编码的 XML 文本。 </param>
/// <returns> 一个可用于枚举 <see cref="ICard"/> 成员的 <see cref="T:System.Collections.Generic.IEnumerable`1"/>。 </returns>
/// <returns> 一个可用于枚举 <see cref="ICard"/> 成员的 <see cref="System.Collections.Generic.IEnumerable{T}"/>。 </returns>
public static IEnumerable<ICard> Deserialize(string xmlText)
{
using MemoryStream xmlStream = new(Encoding.UTF8.GetBytes(xmlText));
Expand All @@ -146,7 +146,7 @@ public static IEnumerable<ICard> Deserialize(string xmlText)
/// 元素,可以包含多个 <c>card</c> 元素。
/// </summary>
/// <param name="xmlStream"> UTF-8 编码的 XML 流。 </param>
/// <returns> 一个可用于枚举 <see cref="ICard"/> 成员的 <see cref="T:System.Collections.Generic.IEnumerable`1"/>。 </returns>
/// <returns> 一个可用于枚举 <see cref="ICard"/> 成员的 <see cref="System.Collections.Generic.IEnumerable{T}"/>。 </returns>
public static IEnumerable<ICard> Deserialize(Stream xmlStream)
{
using XmlReader xmlReader = XmlReader.Create(xmlStream, new XmlReaderSettings
Expand Down Expand Up @@ -219,7 +219,7 @@ public static IEnumerable<ICard> Deserialize(Stream xmlStream)
/// <param name="file"> UTF-8 编码的 XML 文件。 </param>
/// <param name="cards">
/// 如果反序列化操作成功,则为一个可用于枚举 <see cref="ICard"/> 成员的
/// <see cref="T:System.Collections.Generic.IEnumerable`1"/>;否则为 <c>null</c>。
/// <see cref="System.Collections.Generic.IEnumerable{T}"/>;否则为 <c>null</c>。
/// </param>
/// <returns> 如果反序列化操作成功,则为 <c>true</c>;否则为 <c>false</c>。 </returns>
public static bool TryDeserialize(FileInfo file, [NotNullWhen(true)] out IEnumerable<ICard>? cards)
Expand All @@ -242,7 +242,7 @@ public static bool TryDeserialize(FileInfo file, [NotNullWhen(true)] out IEnumer
/// <param name="xmlText"> UTF-8 编码的 XML 文本。 </param>
/// <param name="cards">
/// 如果反序列化操作成功,则为一个可用于枚举 <see cref="ICard"/> 成员的
/// <see cref="T:System.Collections.Generic.IEnumerable`1"/>;否则为 <c>null</c>。
/// <see cref="System.Collections.Generic.IEnumerable{T}"/>;否则为 <c>null</c>。
/// </param>
/// <returns> 如果反序列化操作成功,则为 <c>true</c>;否则为 <c>false</c>。 </returns>
public static bool TryDeserialize(string xmlText, [NotNullWhen(true)] out IEnumerable<ICard>? cards)
Expand All @@ -265,7 +265,7 @@ public static bool TryDeserialize(string xmlText, [NotNullWhen(true)] out IEnume
/// <param name="xmlStream"> UTF-8 编码的 XML 文本流。 </param>
/// <param name="cards">
/// 如果反序列化操作成功,则为一个可用于枚举 <see cref="ICard"/> 成员的
/// <see cref="T:System.Collections.Generic.IEnumerable`1"/>;否则为 <c>null</c>。
/// <see cref="System.Collections.Generic.IEnumerable{T}"/>;否则为 <c>null</c>。
/// </param>
/// <returns> 如果反序列化操作成功,则为 <c>true</c>;否则为 <c>false</c>。 </returns>
public static bool TryDeserialize(Stream xmlStream, [NotNullWhen(true)] out IEnumerable<ICard>? cards)
Expand Down
12 changes: 6 additions & 6 deletions src/Kook.Net.Commands/Attributes/CommandAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,43 @@ public class CommandAttribute : Attribute
/// 获取此命令的基本名称。
/// </summary>
/// <remarks>
/// <see cref="T:Kook.Commands.NameAttribute"/> 特性重写此属性的值。
/// <see cref="Kook.Commands.NameAttribute"/> 特性重写此属性的值。
/// </remarks>
public string? Text { get; }

/// <summary>
/// 获取或设置命令的运行模式。
/// </summary>
/// <seealso cref="P:Kook.Commands.CommandServiceConfig.DefaultRunMode"/>
/// <seealso cref="Kook.Commands.CommandServiceConfig.DefaultRunMode"/>
public RunMode RunMode { get; set; } = RunMode.Default;

/// <summary>
/// 获取或设置是否忽略此命令的额外参数。
/// </summary>
/// <seealso cref="P:Kook.Commands.CommandServiceConfig.IgnoreExtraArgs"/>
/// <seealso cref="Kook.Commands.CommandServiceConfig.IgnoreExtraArgs"/>
public bool? IgnoreExtraArgs { get; }

/// <summary>
/// 获取或设置命令的摘要。
/// </summary>
/// <remarks>
/// <see cref="T:Kook.Commands.SummaryAttribute"/> 特性重写此属性的值。
/// <see cref="Kook.Commands.SummaryAttribute"/> 特性重写此属性的值。
/// </remarks>
public string? Summary { get; set; }

/// <summary>
/// 获取或设置命令的别名。
/// </summary>
/// <remarks>
/// <see cref="T:Kook.Commands.AliasAttribute"/> 特性的值会与此属性的值合并。
/// <see cref="Kook.Commands.AliasAttribute"/> 特性的值会与此属性的值合并。
/// </remarks>
public string?[]? Aliases { get; set; }

/// <summary>
/// 获取或设置命令的备注。
/// </summary>
/// <remarks>
/// <see cref="T:Kook.Commands.RemainderAttribute"/> 特性重写此属性的值。
/// <see cref="Kook.Commands.RemainderAttribute"/> 特性重写此属性的值。
/// </remarks>
public string? Remarks { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion src/Kook.Net.Commands/Attributes/DontAutoLoadAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Kook.Commands;
/// 标记指定的模块不应被自动加载。
/// </summary>
/// <remarks>
/// 此属性告诉 <see cref="T:Kook.Commands.CommandService" /> 在自动加载模块是忽略被此特性标记的模块。
/// 此属性告诉 <see cref="Kook.Commands.CommandService" /> 在自动加载模块是忽略被此特性标记的模块。
/// 需要注意的是,如果尝试手动加载被此特性标记的非公共模块,加载过程也会失败。
/// </remarks>
[AttributeUsage(AttributeTargets.Class)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
namespace Kook.Commands;

/// <summary>
/// 标记指定的参数应有应由指定的 <see cref="T:Kook.Commands.TypeReader"/> 读取并解析。
/// 标记指定的参数应有应由指定的 <see cref="Kook.Commands.TypeReader"/> 读取并解析。
/// </summary>
/// <remarks>
/// 此特性允许在解析命令参数时为指定的参数指定特定的
/// <see cref="T:Kook.Commands.TypeReader"/>,可用于在不影响其他命令的情况下使用特定的命令解析器。
/// <see cref="Kook.Commands.TypeReader"/>,可用于在不影响其他命令的情况下使用特定的命令解析器。
/// <br />
/// <note type="warning">
/// 标记此特性的类型解析器类型必须继承自 <see cref="Kook.Commands.TypeReader"/>,否则将引发
/// <see cref="T:System.InvalidOperationException"/> 异常。
/// <see cref="System.InvalidOperationException"/> 异常。
/// </note>
/// </remarks>
/// <example>
Expand All @@ -37,7 +37,7 @@ public sealed class OverrideTypeReaderAttribute : Attribute
/// 初始化一个 <see cref="OverrideTypeReaderAttribute"/> 类的新实例。
/// </summary>
/// <param name="overridenTypeReader"> 解析此参数所使用的类型解析器的类型。 </param>
/// <exception cref="InvalidOperationException"> 所提供的类型解析器类型不是 <see cref="T:Kook.Commands.TypeReader"/> 的派生类。 </exception>
/// <exception cref="InvalidOperationException"> 所提供的类型解析器类型不是 <see cref="Kook.Commands.TypeReader"/> 的派生类。 </exception>
public OverrideTypeReaderAttribute(Type overridenTypeReader)
{
if (!TypeReaderTypeInfo.IsAssignableFrom(overridenTypeReader.GetTypeInfo()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace Kook.Commands;
/// <summary>
/// 表示一个命令中的参数在其所属命令执行前需要符合的先决条件的基类。
/// </summary>
/// <seealso cref="T:Kook.Commands.PreconditionAttribute"/>
/// <seealso cref="Kook.Commands.PreconditionAttribute"/>
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = true)]
public abstract class ParameterPreconditionAttribute : Attribute
{
Expand Down
2 changes: 1 addition & 1 deletion src/Kook.Net.Commands/Attributes/PreconditionAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace Kook.Commands;
/// <summary>
/// 表示一个模块或类中的命令在执行前需要符合的先决条件的基类。
/// </summary>
/// <seealso cref="T:Kook.Commands.ParameterPreconditionAttribute"/>
/// <seealso cref="Kook.Commands.ParameterPreconditionAttribute"/>
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true)]
public abstract class PreconditionAttribute : Attribute
{
Expand Down
4 changes: 2 additions & 2 deletions src/Kook.Net.Commands/Builders/CommandBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class CommandBuilder
/// <summary>
/// 获取或设置此命令的优先级。
/// </summary>
/// <seealso cref="M:Kook.Commands.PriorityAttribute.#ctor(System.Int32)"/>
/// <seealso cref="Kook.Commands.PriorityAttribute(System.Int32)"/>
public int Priority { get; set; }

/// <summary>
Expand Down Expand Up @@ -162,7 +162,7 @@ public CommandBuilder WithRunMode(RunMode runMode)
/// </summary>
/// <param name="priority"> 此命令的优先级。 </param>
/// <returns> 当前命令构建器。 </returns>
/// <seealso cref="M:Kook.Commands.PriorityAttribute.#ctor(System.Int32)"/>
/// <seealso cref="Kook.Commands.PriorityAttribute(System.Int32)"/>
public CommandBuilder WithPriority(int priority)
{
Priority = priority;
Expand Down
18 changes: 9 additions & 9 deletions src/Kook.Net.Commands/CommandService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ namespace Kook.Commands;
/// </summary>
/// <remarks>
/// 此类用于支持在运行时动态创建命令,或者在编译时静态创建命令。要在编译时创建命令模块,参见
/// <see cref="T:Kook.Commands.ModuleBase"/> 或 <see cref="T:Kook.Commands.Builders.ModuleBuilder"/>。 <br />
/// 此服务还提供了几个事件,用于监视命令的使用情况;例如 <see cref="M:Kook.Commands.CommandService.Log" /> 用于任何与命令相关的日志事件,
/// <see cref="Kook.Commands.ModuleBase"/> 或 <see cref="Kook.Commands.Builders.ModuleBuilder"/>。 <br />
/// 此服务还提供了几个事件,用于监视命令的使用情况;例如 <see cref="Kook.Commands.CommandService.Log" /> 用于任何与命令相关的日志事件,
/// </remarks>
public class CommandService : IDisposable
{
Expand All @@ -24,7 +24,7 @@ public class CommandService : IDisposable
/// <remarks>
/// 事件参数:
/// <list type="number">
/// <item> <see cref="T:Kook.LogMessage"/> 参数是日志消息。 </item>
/// <item> <see cref="Kook.LogMessage"/> 参数是日志消息。 </item>
/// </list>
/// </remarks>
public event Func<LogMessage, Task> Log
Expand All @@ -43,9 +43,9 @@ public event Func<LogMessage, Task> Log
/// <br />
/// 事件参数:
/// <list type="number">
/// <item> <see cref="T:Kook.Commands.CommandInfo"/>? 参数是执行的命令,如果命令在解析或先决条件阶段失败,则可能为 <c>null</c>。 </item>
/// <item> <see cref="T:Kook.Commands.ICommandContext"/> 参数是命令的上下文。 </item>
/// <item> <see cref="T:Kook.Commands.IResult"/> 参数是命令的结果。 </item>
/// <item> <see cref="Kook.Commands.CommandInfo"/>? 参数是执行的命令,如果命令在解析或先决条件阶段失败,则可能为 <c>null</c>。 </item>
/// <item> <see cref="Kook.Commands.ICommandContext"/> 参数是命令的上下文。 </item>
/// <item> <see cref="Kook.Commands.IResult"/> 参数是命令的结果。 </item>
/// </list>
/// </remarks>
public event Func<CommandInfo?, ICommandContext, IResult, Task> CommandExecuted
Expand Down Expand Up @@ -101,7 +101,7 @@ public CommandService() : this(new CommandServiceConfig())
/// 初始化一个 <see cref="CommandService"/> 类的新实例。
/// </summary>
/// <param name="config"> 命令服务的配置。 </param>
/// <exception cref="InvalidOperationException"> 默认运行模式不能设置为 <see cref="F:Kook.Commands.RunMode.Default"/>。 </exception>
/// <exception cref="InvalidOperationException"> 默认运行模式不能设置为 <see cref="Kook.Commands.RunMode.Default"/>。 </exception>
public CommandService(CommandServiceConfig config)
{
_caseSensitive = config.CaseSensitiveCommands;
Expand Down Expand Up @@ -185,7 +185,7 @@ public async Task<ModuleInfo> CreateModuleAsync(string primaryAlias, Action<Modu
/// <param name="services"> 用于依赖注入的服务提供程序;如果不使用依赖注入,则传递 <c>null</c>。 </param>
/// <returns> 一个表示异步添加操作的任务。任务结果包含添加的模块。 </returns>
/// <exception cref="ArgumentException"> 此模块已经添加。 </exception>
/// <exception cref="InvalidOperationException"> 无法构建 <see cref="T:Kook.Commands.ModuleInfo"/>;可能提供了无效的类型。 </exception>
/// <exception cref="InvalidOperationException"> 无法构建 <see cref="Kook.Commands.ModuleInfo"/>;可能提供了无效的类型。 </exception>
/// <example>
/// 以下示例代码将模块 <c>MyModule</c> 注册到 <c>commandService</c> 中。
/// <code language="cs">
Expand All @@ -201,7 +201,7 @@ public async Task<ModuleInfo> CreateModuleAsync(string primaryAlias, Action<Modu
/// <param name="services"> 用于依赖注入的服务提供程序;如果不使用依赖注入,则传递 <c>null</c>。 </param>
/// <returns> 一个表示异步添加操作的任务。任务结果包含添加的模块。 </returns>
/// <exception cref="ArgumentException"> 此模块已经添加。 </exception>
/// <exception cref="InvalidOperationException"> 无法构建 <see cref="T:Kook.Commands.ModuleInfo"/>;可能提供了无效的类型。 </exception>
/// <exception cref="InvalidOperationException"> 无法构建 <see cref="Kook.Commands.ModuleInfo"/>;可能提供了无效的类型。 </exception>
public async Task<ModuleInfo> AddModuleAsync(Type type, IServiceProvider? services)
{
services ??= EmptyServiceProvider.Instance;
Expand Down
12 changes: 6 additions & 6 deletions src/Kook.Net.Commands/CommandServiceConfig.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
namespace Kook.Commands;

/// <summary>
/// 表示一个用于 <see cref="T:Kook.Commands.CommandService"/> 的配置类。
/// 表示一个用于 <see cref="Kook.Commands.CommandService"/> 的配置类。
/// </summary>
public class CommandServiceConfig
{
/// <summary>
/// 获取或设置命令的默认运行模式,如果在命令属性或构建器上未指定运行模式,则使用此值。
/// </summary>
/// <remarks>
/// 如需在命令上重写默认行为,请使用 <see cref="P:Kook.Commands.CommandAttribute.RunMode"/> 属性。
/// 如需在命令上重写默认行为,请使用 <see cref="Kook.Commands.CommandAttribute.RunMode"/> 属性。
/// </remarks>
public RunMode DefaultRunMode { get; set; } = RunMode.Sync;

Expand All @@ -24,15 +24,15 @@ public class CommandServiceConfig
public bool CaseSensitiveCommands { get; set; } = false;

/// <summary>
/// 获取或设置将引发 <see cref="E:Kook.Commands.CommandService.Log"/> 事件的最低日志级别严重性。
/// 获取或设置将引发 <see cref="Kook.Commands.CommandService.Log"/> 事件的最低日志级别严重性。
/// </summary>
public LogSeverity LogLevel { get; set; } = LogSeverity.Info;

/// <summary>
/// 获取或设置同步执行的命令是否应将异常传递给调用者。
/// </summary>
/// <remarks>
/// 同步命令指的是其运行模式为 <see cref="F:Kook.Commands.RunMode.Sync"/> 的命令。
/// 同步命令指的是其运行模式为 <see cref="Kook.Commands.RunMode.Sync"/> 的命令。
/// </remarks>
public bool ThrowOnError { get; set; } = true;

Expand Down Expand Up @@ -61,8 +61,8 @@ public class CommandServiceConfig
/// </summary>
/// <remarks>
/// 如果设置为 <see langword="true"/>,则默认情况下命令将忽略额外的参数。否则,将引发
/// <see cref="F:Kook.Commands.CommandError.BadArgCount"/>
/// 错误。如需在命令上重写默认行为,请使用 <see cref="P:Kook.Commands.CommandAttribute.IgnoreExtraArgs"/> 属性。
/// <see cref="Kook.Commands.CommandError.BadArgCount"/>
/// 错误。如需在命令上重写默认行为,请使用 <see cref="Kook.Commands.CommandAttribute.IgnoreExtraArgs"/> 属性。
/// </remarks>
public bool IgnoreExtraArgs { get; set; } = false;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace Kook.Commands;

/// <summary>
/// 提供用于 <see cref="T:Kook.Commands.CommandService"/> 的扩展方法。
/// 提供用于 <see cref="Kook.Commands.CommandService"/> 的扩展方法。
/// </summary>
public static class CommandServiceExtensions
{
Expand Down
Loading

0 comments on commit 686515b

Please sign in to comment.