Skip to content

Commit fea9198

Browse files
Set up Copilot instructions (#2325)
* Initial plan * Add .github/copilot-instructions.md with repository-specific guidance Co-authored-by: alexeyzimarev <2821205+alexeyzimarev@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: alexeyzimarev <2821205+alexeyzimarev@users.noreply.github.com>
1 parent eb907af commit fea9198

File tree

1 file changed

+113
-0
lines changed

1 file changed

+113
-0
lines changed

.github/copilot-instructions.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# Copilot Instructions for RestSharp
2+
3+
This document provides instructions for GitHub Copilot when working with the RestSharp repository.
4+
5+
## Project Overview
6+
7+
RestSharp is a lightweight HTTP API client library for .NET. It wraps `HttpClient` and provides:
8+
- Default parameters of any kind, not just headers
9+
- Multiple ways to add request parameters (query, URL segment, header, cookie, body)
10+
- Built-in serialization/deserialization for JSON, XML, and CSV
11+
- Rich support for authentication
12+
13+
## Repository Structure
14+
15+
- `src/RestSharp/` - Main library
16+
- `src/RestSharp.Serializers.*/` - Serializer extensions (NewtonsoftJson, Xml, CsvHelper)
17+
- `gen/SourceGenerator/` - Incremental source generators
18+
- `test/RestSharp.Tests/` - Unit tests
19+
- `test/RestSharp.Tests.Integrated/` - Integration tests (WireMock)
20+
- `test/RestSharp.Tests.Serializers.*/` - Serializer-specific tests
21+
- `benchmarks/RestSharp.Benchmarks/` - Performance tests
22+
23+
## Build and Test Commands
24+
25+
```bash
26+
# Build solution
27+
dotnet build RestSharp.sln -c Debug
28+
29+
# Run all tests
30+
dotnet test RestSharp.sln -c Debug
31+
32+
# Run tests for specific TFM
33+
dotnet test test/RestSharp.Tests/RestSharp.Tests.csproj -f net8.0
34+
35+
# Run single test
36+
dotnet test test/RestSharp.Tests/RestSharp.Tests.csproj --filter "FullyQualifiedName=Namespace.Class.Method" -f net8.0
37+
38+
# Pack for release
39+
dotnet pack src/RestSharp/RestSharp.csproj -c Release -o nuget -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg
40+
```
41+
42+
## Multi-Targeting
43+
44+
The library targets multiple frameworks:
45+
- `netstandard2.0`, `net471`, `net48` - Legacy support
46+
- `net8.0`, `net9.0`, `net10.0` - Modern .NET
47+
48+
Tests target: `net48` (Windows only), `net8.0`, `net9.0`, `net10.0`
49+
50+
When adding features:
51+
- Use conditional compilation for TFM-specific APIs: `#if NET` or `#if NET8_0_OR_GREATER`
52+
- Ensure compilation succeeds for all TFMs
53+
- Add polyfills or conditional code for missing APIs on older TFMs
54+
55+
## Code Style and Conventions
56+
57+
- Language version: C# preview (latest features allowed)
58+
- Nullable reference types: Enabled in `/src`, disabled in `/test`
59+
- All `/src` files must include the Apache 2.0 license header
60+
- Test files do not require the license header
61+
- Follow `.editorconfig` for formatting rules
62+
- Use partial classes for large types (link with `<DependentUpon>`)
63+
- Assemblies are strong-named via `RestSharp.snk`
64+
65+
### License Header for Source Files
66+
67+
```csharp
68+
// Copyright (c) .NET Foundation and Contributors
69+
//
70+
// Licensed under the Apache License, Version 2.0 (the "License");
71+
// you may not use this file except in compliance with the License.
72+
// You may obtain a copy of the License at
73+
//
74+
// http://www.apache.org/licenses/LICENSE-2.0
75+
//
76+
// Unless required by applicable law or agreed to in writing, software
77+
// distributed under the License is distributed on an "AS IS" BASIS,
78+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
79+
// See the License for the specific language governing permissions and
80+
// limitations under the License.
81+
```
82+
83+
## Testing Guidelines
84+
85+
- Frameworks: xUnit + FluentAssertions + AutoFixture
86+
- Use WireMockServer for HTTP scenarios (avoid live endpoints)
87+
- Use descriptive assertions: `result.Should().Be(expected)`
88+
- Guard TFM-specific tests with `#if NET8_0_OR_GREATER`
89+
- Avoid flaky tests: don't depend on timing, locale, or network conditions
90+
91+
Test projects have global usings configured for `Xunit`, `FluentAssertions`, and `AutoFixture`.
92+
93+
## Source Generators
94+
95+
Custom generators in `gen/SourceGenerator/`:
96+
- `[GenerateImmutable]` - Creates read-only wrappers
97+
- `[GenerateClone]` - Creates static factory clone methods
98+
- `[Exclude]` - Excludes properties from immutable generation
99+
100+
Generator target: `netstandard2.0` (required for all compiler versions)
101+
102+
## Dependencies
103+
104+
Package versions are centrally managed in `Directory.Packages.props`. Do not pin versions in individual projects unless justified by TFM constraints.
105+
106+
## PR Checklist
107+
108+
Before submitting:
109+
- Builds cleanly across all targeted TFMs
110+
- Tests added/updated and passing
111+
- No new analyzer warnings in `/src`
112+
- License header in new `/src` files
113+
- Public API changes documented and tested

0 commit comments

Comments
 (0)