roslyn-analyzers
Skill này làm gì
Công cụ này giúp nhà phát triển tạo và cải thiện các kiểm tra mã tự động (Roslyn analyzers) và bộ sinh mã. Nó đảm bảo mã tuân theo các quy tắc cụ thể và giúp tìm lỗi.
Khi nào nên dùng
- ✓Khi tạo các kiểm tra mới để tìm lỗi mã phổ biến.
- ✓Khi sửa các vấn đề mà analyzer đã tìm ra.
- ✓Khi tối ưu cách sinh mã tự động.
Liên kết skill
https://github.com/github/awesome-copilot/blob/main/skills/roslyn-analyzers/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Làm thế nào để tạo một analyzer kiểm tra xem tất cả biến có tên mô tả rõ ràng hay không?”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Công cụ hoạt động bằng cách kiểm tra mã khi nó được viết hoặc biên dịch. Nó dùng các quy tắc để hiểu cấu trúc và ký hiệu của mã, rồi xác định những mẫu cần chú ý hoặc sửa.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Roslyn Analyzers and Source Generators
Use this workflow when adding or changing a Roslyn analyzer, code fix, source generator, tests, dependencies, or package layout. First inspect the repository's target frameworks, central package management, test framework, analyzer and generator conventions, diagnostic ID allocation, localization, and packaging. Preserve established conventions unless they conflict with the compatibility rules below.
Non-negotiable design rules
- Prefer
IOperation-based analysis wherever possible. Register the narrowest applicableOperationKindand inspect typed operations such asIInvocationOperation,IAwaitOperation, orIObjectCreationOperation. This usually supports C# and VB with one analyzer and gives direct access to symbols and conversions. - Use syntax analysis only for inherently syntactic rules or syntax not represented adequately by
IOperation. A syntax-node callback already has aSemanticModel; do not callCompilation.GetSemanticModelor fetch another semantic model from it. Repeated semantic-model creation is expensive and often indicates that an operation or symbol action is the better abstraction. - Every analyzer must support C#. VB.NET support is optional until requested or established repository precedent requires it. A language-neutral operation analyzer may declare both languages. If VB support is promised, include equivalent C# and VB snippets in tests; do not infer VB correctness from shared implementation alone.
- Keep analyzer and code-fix providers in distinct assemblies. The analyzer project must never reference Roslyn Workspaces packages. Workspaces dependencies belong only in the code-fix and test projects.
- Analyzer callbacks must be stateless or concurrency-safe. Call
EnableConcurrentExecution(). Make an explicit generated-code choice withConfigureGeneratedCodeAnalysis(...); follow repository policy rather than silently accepting the default. - Respect cancellation where APIs expose a token. Do not retain compilations, operations, syntax trees, symbols, or semantic models in static state.
- Avoid
InternalsVisibleTo. Test analyzers through their publicDiagnosticAnalyzerandCodeFixProviderAPIs and the Roslyn test harness. A small analyzer helper may be public when direct testing is genuinely useful, but most behavior should be tested end to end. - Centralize metadata names and member names instead of propagating magic strings. Use one shared static catalog for fully qualified type names, namespaces, and API member names.
- Never identify a symbol, including an attribute class, by calling
ToDisplayString()and comparing the result with a string literal. Resolve an expected named type from theCompilationonce by metadata name. To resolve a method, property, field, or event, first resolve its containing type, then select the expected member by name and signature. Compare encountered symbols withSymbolEqualityComparer.Default.Equals(actual, expected). When generic substitutions are irrelevant, compare named types, properties, fields, and events byOriginalDefinition; compare methods after replacing a reduced extension method withReducedFrom ?? methodand then takingOriginalDefinition. Normalize both expected and encountered symbols, and inspect type arguments separately when they are part of the match. Display strings are for presentation, not identity, and can vary with formatting, aliases, qualification, nullability, and other context. - Document every diagnostic ID. When the repository uses Docfx, put analyzer documentation under its Docfx tree, typically
docfx/analyzers, and include each page in the relevant table of contents. - Set every analyzer assembly's version precisely enough that each commit produces a unique assembly version. When using Nerdbank.GitVersioning, give each analyzer project its own
version.jsonwithassemblyVersion.precisionset torevisionand ensure that repository-wide MSBuild properties do not prevent that file from being discovered. - Source generators must implement
IIncrementalGenerator, notISourceGenerator. Design the provider graph so unchanged inputs remain cached and do not regenerate output. - Source generators must use a small
SourceWriterabstraction for deterministic newlines, indentation, encoding, and balanced output. Start from SourceWriter.cs and tailor its namespace and target-framework details to the receiving repository.
…
Câu hỏi thường gặp
“Roslyn analyzers” là gì?
Đây là các công cụ phân tích mã C# hoặc VB.NET để tìm các vấn đề tiềm ẩn, gợi ý cải thiện, hoặc thậm chí tự động sửa.
“Code generators” là gì?
Đây là các chương trình tự động tạo mã dựa trên các phần khác của dự án, giúp tiết kiệm thời gian và giảm lỗi thủ công.
Tôi có cần biết nhiều về lập trình để dùng công cụ này không?
Công cụ này dành cho các nhà phát triển đã viết mã. Nó giúp mã của họ tốt hơn và hiệu quả hơn.
Chi tiết
Mô tả gốc của tác giả
Build, review, debug, package, and test Roslyn diagnostic analyzers, code fix providers, and incremental source generators. Use for DiagnosticAnalyzer, CodeFixProvider, IIncrementalGenerator, IOperation analysis, Microsoft.CodeAnalysis dependency pinning, Roslyn test harnesses, C#/VB tests, and analyzer NuGet packaging.
repo: github/awesome-copilot
Độ phổ biến
- Sao GitHub
- 40k
- Vị trí xếp hạng
- #7406
- Giấy phép
- MIT
- Cập nhật
- 15/10/2026
Bình luận
- …
Thêm skill từ kho mã này
acquire-codebase-knowledge
40kGiúp agent của bạn hiểu và ghi tài liệu cho một dự án mã nguồn có sẵn. Hữu ích khi đón thành viên mới hoặc nắm tổng quan về kiến trúc.
acreadiness-assess
40kGiúp agent của bạn đánh giá mức độ sẵn sàng cho AI của dự án và tạo báo cáo. Hữu ích để biết dự án đã sẵn sàng dùng công cụ AI đến đâu.
acreadiness-generate-instructions
40kGiúp agent của bạn tạo hướng dẫn cho công cụ AI dựa trên kết quả đánh giá. Hữu ích để cải thiện cách AI làm việc với mã và khắc phục các khoảng trống.
acreadiness-policy
40kGiúp agent của bạn xác định hoặc áp dụng chính sách đánh giá dự án bằng AI. Hữu ích để chuẩn hóa cách đánh giá dự án và đảm bảo tuân thủ.
Skill tương tự
diffs
394kGiúp agent của bạn tạo một diff có thể chia sẻ về các chỉnh sửa, dưới dạng liên kết xem hoặc file ảnh, thay vì một bản tóm tắt viết tay.
coding-agent
394kGiúp agent của bạn giao một việc lập trình lớn cho Codex, Claude Code hoặc OpenCode chạy nền, rồi theo dõi tiến độ của nó.
gh-issues
394kGiúp agent của bạn tìm issue trên GitHub, chọn những issue cần xử lý và mở pull request với bản sửa, kể cả theo dõi nhận xét đánh giá.