NullGuard 项目使用教程
NullGuardAdds null argument checks to an assembly项目地址:https://gitcode.com/gh_mirrors/nu/NullGuard
1. 项目的目录结构及介绍
NullGuard 项目的目录结构如下:
NullGuard/
├── .github/
│ └── workflows/
├── src/
│ ├── NullGuard.Fody/
│ └── NullGuard.Tests/
├── .gitignore
├── .editorconfig
├── .gitattributes
├── FodyWeavers.xsd
├── FodyWeavers.xml
├── LICENSE
├── README.md
└── NullGuard.sln
目录结构介绍
- .github/workflows/: 包含 GitHub Actions 的工作流配置文件。
- src/: 包含项目的源代码。
- NullGuard.Fody/: NullGuard 插件的主要实现代码。
- NullGuard.Tests/: 测试代码。
- .gitignore: Git 忽略文件配置。
- .editorconfig: 编辑器配置文件。
- .gitattributes: Git 属性配置文件。
- FodyWeavers.xsd: Fody 编织器的 XML 模式文件。
- FodyWeavers.xml: Fody 编织器的配置文件。
- LICENSE: 项目许可证文件。
- README.md: 项目说明文档。
- NullGuard.sln: Visual Studio 解决方案文件。
2. 项目的启动文件介绍
NullGuard 项目的主要启动文件是 NullGuard.sln
,这是一个 Visual Studio 解决方案文件,用于管理和启动整个项目。
启动文件介绍
- NullGuard.sln: 双击此文件可以打开整个项目,进行编译和运行。
3. 项目的配置文件介绍
NullGuard 项目的主要配置文件是 FodyWeavers.xml
,用于配置 NullGuard 的行为。
配置文件介绍
- FodyWeavers.xml: 该文件包含 NullGuard 的配置信息,例如是否包含调试断言、排除特定类等。
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<NullGuard Mode="Implicit" IncludeDebugAssert="false" />
</Weavers>
配置项说明
- Mode: 设置 NullGuard 的操作模式,可以是
Implicit
、Explicit
或NullableReferenceTypes
。 - IncludeDebugAssert: 是否包含调试断言,设置为
false
表示不包含。
通过以上配置,可以灵活地控制 NullGuard 的行为,确保项目在运行时能够正确地进行空值检查。
NullGuardAdds null argument checks to an assembly项目地址:https://gitcode.com/gh_mirrors/nu/NullGuard