ConfigureAwait 开源项目教程

随笔3周前发布 张勤铭
57 0 0

ConfigureAwait 开源项目教程

ConfigureAwaitConfigure async code’s ConfigureAwait at a global level项目地址:https://gitcode.com/gh_mirrors/co/ConfigureAwait

1. 项目的目录结构及介绍

ConfigureAwait 项目的目录结构如下:

  1. /ConfigureAwait

  2. ├── .github

  3. │ └── workflows

  4. │ └── main.yml

  5. ├── src

  6. │ ├── Fody

  7. │ │ ├── ConfigureAwait

  8. │ │ │ ├── Properties

  9. │ │ │ │ └── AssemblyInfo.cs

  10. │ │ │ ├── ConfigureAwait.cs

  11. │ │ │ ├── ConfigureAwait.Fody.csproj

  12. │ │ │ └── ModuleWeaver.cs

  13. │ │ └── FodyHelpers

  14. │ │ ├── AssemblyVersion.cs

  15. │ │ ├── FodyHelpers.csproj

  16. │ │ └── ModuleWeaver.cs

  17. │ └── Sample

  18. │ ├── Sample.csproj

  19. │ └── Program.cs

  20. ├── tests

  21. │ ├── AssemblyToProcess

  22. │ │ ├── AssemblyToProcess.csproj

  23. │ │ └── Class1.cs

  24. │ ├── Fody.ConfigureAwait.Tests

  25. │ │ ├── Fody.ConfigureAwait.Tests.csproj

  26. │ │ └── Tests.cs

  27. │ └── IntegrationTests

  28. │ ├── IntegrationTests.csproj

  29. │ └── Tests.cs

  30. ├── .gitignore

  31. ├── .editorconfig

  32. ├── .gitattributes

  33. ├── FodyWeavers.xml

  34. ├── LICENSE

  35. ├── README.md

  36. └── global.json

目录结构介绍

  • .github/workflows: 包含 GitHub Actions 的工作流配置文件。
  • src: 源代码目录。
    • Fody/ConfigureAwait: ConfigureAwait 插件的主要代码。
      • Properties: 包含程序集信息文件。
      • ConfigureAwait.cs: 主要逻辑文件。
      • ConfigureAwait.Fody.csproj: 项目文件。
      • ModuleWeaver.cs: 模块编织器文件。
    • Fody/FodyHelpers: Fody 辅助工具代码。
    • Sample: 示例项目。
  • tests: 测试代码目录。
    • AssemblyToProcess: 待处理的程序集测试。
    • Fody.ConfigureAwait.Tests: 单元测试。
    • IntegrationTests: 集成测试。
  • .gitignore: Git 忽略文件配置。
  • .editorconfig: 编辑器配置文件。
  • .gitattributes: Git 属性配置文件。
  • FodyWeavers.xml: Fody 编织器配置文件。
  • LICENSE: 许可证文件。
  • README.md: 项目说明文档。
  • global.json: 全局配置文件。

2. 项目的启动文件介绍

在 ConfigureAwait 项目中,启动文件位于 src/Sample/Program.cs。这个文件是示例项目的入口点,展示了如何使用 ConfigureAwait 插件。

  1. using System;

  2. using System.Threading.Tasks;

  3. namespace Sample

  4. {

  5. class Program

  6. {

  7. static async Task Main(string[] args)

  8. {

  9. await Task.Delay(100);

  10. Console.WriteLine("Hello World!");

  11. }

  12. }

  13. }

启动文件介绍

  • Program.cs: 包含 Main 方法,是应用程序的入口点。
  • Task.Delay(100): 示例代码中使用了 await 关键字,展示了如何异步等待任务完成。

3. 项目的配置文件介绍

在 ConfigureAwait 项目中,主要的配置文件是 FodyWeavers.xml。这个文件用于配置 Fody 插件。

  1. <Weavers>

  2. <ConfigureAwait/>

  3. </Weavers>

配置文件介绍

  • FodyWeavers.xml: 配置 Fody 插件的文件。

    • : 启用 ConfigureAwait 插件。

通过这个配置文件,可以指定项目中需要使用的 Fody 插件,以及它们的配置选项。

ConfigureAwaitConfigure async code’s ConfigureAwait at a global level项目地址:https://gitcode.com/gh_mirrors/co/ConfigureAwait

© 版权声明

相关文章

暂无评论

您必须登录才能参与评论!
立即登录
暂无评论...