Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 28, 2025

Source generator was placing Async suffix in the middle of async string method names (ReadConfigAsyncAsString) instead of at the end (ReadConfigAsStringAsync), violating .NET naming conventions.

Changes

  • Source Generator: Fixed method name generation to place Async suffix at end for string methods

    • Introduced named variables for method names to improve consistency
    • Byte array async methods were already correct
  • Examples & Documentation: Updated method calls and examples to match new naming pattern

Before/After

// Before (incorrect)
string config = await R.ReadConfigAsyncAsString();

// After (correct)
string config = await R.ReadConfigAsStringAsync();

All generated methods for resource "config":

Task<byte[]> ReadConfigAsync()                      // byte[] async (unchanged)
Task<string> ReadConfigAsStringAsync()              // string async (fixed)
Task<string> ReadConfigAsStringAsync(Encoding enc)  // string async with encoding (fixed)
byte[] ReadConfig()                                 // byte[] sync
string ReadConfigAsString()                         // string sync
Stream GetConfigStream()                            // stream
Original prompt

This section details on the original issue you should resolve

<issue_title>SG 生成的异步方法名称需要优化,确保 Async 在方法名的最后。</issue_title>
<issue_description>假如有资源 Config.txt ,目前生成的读取代码是:R.ReadConfigAsyncAsString() 这种方法命名并不友好,应该改为 R.ReadConfigAsStringAsync()

需要修改SG项目的实现,并更新文档(README 等)。</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI self-assigned this Oct 28, 2025
Copilot AI and others added 2 commits October 28, 2025 09:47
Co-authored-by: Soar360 <15421284+Soar360@users.noreply.github.com>
Co-authored-by: Soar360 <15421284+Soar360@users.noreply.github.com>
Copilot AI changed the title [WIP] Optimize async method naming for SG project Fix async method naming: move Async suffix to end per .NET conventions Oct 28, 2025
Copilot AI requested a review from Soar360 October 28, 2025 09:56
Copilot finished work on behalf of Soar360 October 28, 2025 09:56
@Soar360 Soar360 marked this pull request as ready for review October 28, 2025 09:56
@Soar360 Soar360 merged commit 21788f3 into main Oct 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SG 生成的异步方法名称需要优化,确保 Async 在方法名的最后。

2 participants