{"kind":"AgentDefinition","metadata":{"namespace":"community","name":"dotnet-framework","version":"0.1.0"},"spec":{"agents_md":"---\ndescription: 'Guidance for working with .NET Framework projects. Includes project structure, C# language version, NuGet management, and best practices.'\napplyTo: '**/*.csproj, **/*.cs'\n---\n\n# .NET Framework Development\n\n## Build and Compilation Requirements\n- Always use `msbuild /t:rebuild` to build the solution or projects instead of `dotnet build`\n\n## Project File Management\n\n### Non-SDK Style Project Structure\n.NET Framework projects use the legacy project format, which differs significantly from modern SDK-style projects:\n\n- **Explicit File Inclusion**: All new source files **MUST** be explicitly added to the project file (`.csproj`) using a `\u003cCompile\u003e` element\n  - .NET Framework projects do not automatically include files in the directory like SDK-style projects\n  - Example: `\u003cCompile Include=\"Path\\To\\NewFile.cs\" /\u003e`\n\n- **No Implicit Imports**: Unlike SDK-style projects, .NET Framework projects do not automatically import common namespaces or assemblies\n \n- **Build Configuration**: Contains explicit `\u003cPropertyGroup\u003e` sections for Debug/Release configurations\n\n- **Output Paths**: Explicit `\u003cOutputPath\u003e` and `\u003cIntermediateOutputPath\u003e` definitions\n\n- **Target Framework**: Uses `\u003cTargetFrameworkVersion\u003e` instead of `\u003cTargetFramework\u003e`\n  - Example: `\u003cTargetFrameworkVersion\u003ev4.7.2\u003c/TargetFrameworkVersion\u003e`\n\n## NuGet Package Management\n- Installing and updating NuGet packages in .NET Framework projects is a complex task requiring coordinated changes to multiple files. Therefore, **do not attempt to install or update NuGet packages** in this project.\n- Instead, if changes to NuGet references are required, ask the user to install or update NuGet packages using the Visual Studio NuGet Package Manager or Visual Studio package manager console.\n- When recommending NuGet packages, ensure they are compatible with .NET Framework or .NET Standard 2.0 (not only .NET Core or .NET 5+).\n\n## C# Language Version is 7.3\n- This project is limited to C# 7.3 features only. Please avoid using:\n\n### C# 8.0+ Features (NOT SUPPORTED):\n  - Using declarations (`using var stream = ...`)\n  - Await using statements (`await using var resource = ...`)\n  - Switch expressions (`variable switch { ... }`)\n  - Null-coalescing assignment (`??=`)\n  - Range and index operators (`array[1..^1]`, `array[^1]`)\n  - Default interface methods\n  - Readonly members in structs\n  - Static local functions\n  - Nullable reference types (`string?`, `#nullable enable`)\n\n### C# 9.0+ Features (NOT SUPPORTED):\n  - Records (`public record Person(string Name)`)\n  - Init-only properties (`{ get; init; }`)\n  - Top-level programs (program without Main method)\n  - Pattern matching enhancements\n  - Target-typed new expressions (`List\u003cstring\u003e list = new()`)\n\n### C# 10+ Features (NOT SUPPORTED):\n  - Global using statements\n  - File-scoped namespaces\n  - Record structs\n  - Required members\n\n### Use Instead (C# 7.3 Compatible):\n  - Traditional using statements with braces\n  - Switch statements instead of switch expressions\n  - Explicit null checks instead of null-coalescing assignment\n  - Array slicing with manual indexing\n  - Abstract classes or interfaces instead of default interface methods\n\n## Environment Considerations (Windows environment)\n- Use Windows-style paths with backslashes (e.g., `C:\\path\\to\\file.cs`)\n- Use Windows-appropriate commands when suggesting terminal operations\n- Consider Windows-specific behaviors when working with file system operations\n\n## Common .NET Framework Pitfalls and Best Practices\n\n### Async/Await Patterns\n- **ConfigureAwait(false)**: Always use `ConfigureAwait(false)` in library code to avoid deadlocks:\n  ```csharp\n  var result = await SomeAsyncMethod().ConfigureAwait(false);\n  ```\n- **Avoid sync-over-async**: Don't use `.Result` or `.Wait()` or `.GetAwaiter().GetResult()`. These sync-over-async patterns can lead to deadlocks and poor performance. Always use `await` for asynchronous calls.\n\n### DateTime Handling\n- **Use DateTimeOffset for timestamps**: Prefer `DateTimeOffset` over `DateTime` for absolute time points\n- **Specify DateTimeKind**: When using `DateTime`, always specify `DateTimeKind.Utc` or `DateTimeKind.Local`\n- **Culture-aware formatting**: Use `CultureInfo.InvariantCulture` for serialization/parsing\n\n### String Operations\n- **StringBuilder for concatenation**: Use `StringBuilder` for multiple string concatenations\n- **StringComparison**: Always specify `StringComparison` for string operations:\n  ```csharp\n  string.Equals(other, StringComparison.OrdinalIgnoreCase)\n  ```\n\n### Memory Management\n- **Dispose pattern**: Implement `IDisposable` properly for unmanaged resources\n- **Using statements**: Always wrap `IDisposable` objects in using statements\n- **Avoid large object heap**: Keep objects under 85KB to avoid LOH allocation\n\n### Configuration\n- **Use ConfigurationManager**: Access app settings through `ConfigurationManager.AppSettings`\n- **Connection strings**: Store in `\u003cconnectionStrings\u003e` section, not `\u003cappSettings\u003e`\n- **Transformations**: Use web.config/app.config transformations for environment-specific settings\n\n### Exception Handling\n- **Specific exceptions**: Catch specific exception types, not generic `Exception`\n- **Don't swallow exceptions**: Always log or re-throw exceptions appropriately\n- **Use using for disposable resources**: Ensures proper cleanup even when exceptions occur\n\n### Performance Considerations\n- **Avoid boxing**: Be aware of boxing/unboxing with value types and generics\n- **String interning**: Use `string.Intern()` judiciously for frequently used strings\n- **Lazy initialization**: Use `Lazy\u003cT\u003e` for expensive object creation\n- **Avoid reflection in hot paths**: Cache `MethodInfo`, `PropertyInfo` objects when possible\n","description":"Guidance for working with .NET Framework projects. Includes project structure, C# language version, NuGet management, and best practices.","import":{"commit_sha":"541b7819d8c3545c6df122491af4fa1eae415779","imported_at":"2026-05-18T20:05:35Z","license_text":"MIT License\n\nCopyright GitHub, Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.","owner":"github","repo":"github/awesome-copilot","source_url":"https://github.com/github/awesome-copilot/blob/541b7819d8c3545c6df122491af4fa1eae415779/instructions/dotnet-framework.instructions.md"},"manifest":{}},"content_hash":[198,231,154,195,218,37,101,208,186,183,42,41,4,47,56,195,147,139,85,122,245,58,135,191,46,147,152,170,42,145,104,158],"trust_level":"unsigned","yanked":false}
