Skip to content

Commit 00232ad

Browse files
authored
[copilot] add comprehensive copilot-instructions.md (#1163)
Context: https://github.com/jonathanpeppers/vibe-some-maui-bro After extensively testing copilot (padawan) by assigning issues, I got much better results after I asked it to write its own `copilot-instructions.md`. Everything it added in here makes sense, and should give it a lot more context for future work.
1 parent ff68c01 commit 00232ad

File tree

1 file changed

+199
-0
lines changed

1 file changed

+199
-0
lines changed

.github/copilot-instructions.md

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
# Copilot Instructions for .NET Android Libraries Repository
2+
3+
**Note**: Always update `copilot-instructions.md` with new/relevant information to keep GitHub Copilot suggestions current and accurate.
4+
5+
## Repository Overview
6+
7+
This repository creates and maintains .NET for Android bindings for Google's Java/Kotlin Android libraries, including:
8+
- AndroidX libraries (600+ packages)
9+
- Google Play Services
10+
- Firebase
11+
- ML Kit
12+
- Various third-party dependencies
13+
14+
The repository uses a **config-driven approach** where all bindings are defined in `config.json` and automatically generated using the "binderator" tool.
15+
16+
## Key Architecture Components
17+
18+
### Core Files
19+
- **`config.json`**: Master configuration containing all 600+ Maven artifacts to bind, their versions, and NuGet package information
20+
- **`build.cake`**: Main Cake build script orchestrating the entire build process
21+
- **`BUILDING.md`**: Comprehensive build instructions and prerequisites
22+
23+
24+
### Directory Structure
25+
- **`source/`**: Contains binding customizations organized by Maven groupId (e.g., `androidx.core`, `com.google.android.gms`) and Razor templates (`.cshtml` files)
26+
- **`util/Xamarin.AndroidBinderator/`**: The "binderator" tool that generates binding projects from config
27+
- **`generated/`**: Auto-generated binding projects (created during build, not in source control)
28+
- **`docs/`**: Additional documentation including artifact lists and development tips
29+
30+
## Build System
31+
32+
### Prerequisites
33+
- a recent .NET SDK
34+
- Cake .NET Tool: `dotnet tool install -g cake.tool`
35+
- Microsoft OpenJDK 11 (JDK-17 not supported)
36+
- Android SDK and `$ANDROID_SDK_ROOT` environment variable
37+
- Optional: `api-tools` for API diffs: `dotnet tool install -g api-tools`
38+
39+
### Common Build Commands
40+
```bash
41+
# Full build of all packages
42+
dotnet cake
43+
44+
# Clean build for CI
45+
dotnet cake -t=ci
46+
47+
# Build specific target
48+
dotnet cake --target=libs
49+
dotnet cake --target=nuget
50+
dotnet cake --target=packages
51+
52+
# Update config to latest Maven versions
53+
dotnet cake --target=update-config
54+
55+
# Bump NuGet package versions (4th component)
56+
dotnet cake --target=bump-config
57+
58+
# Generate API differences
59+
dotnet cake nuget-diff.cake
60+
61+
# Run utilities (governance, mappings, etc.)
62+
dotnet cake utilities.cake
63+
```
64+
65+
## Configuration System
66+
67+
### config.json Structure
68+
**Note**: This file is normally updated using Cake build targets (`update-config`, `bump-config`) rather than manual editing.
69+
70+
Each artifact entry contains:
71+
```json
72+
{
73+
"groupId": "androidx.activity",
74+
"artifactId": "activity",
75+
"version": "1.10.1",
76+
"nugetVersion": "1.10.1.2",
77+
"nugetId": "Xamarin.AndroidX.Activity",
78+
"dependencyOnly": false // true for transitive deps only
79+
}
80+
```
81+
82+
### Version Conventions
83+
- **Major.Minor.Patch**: Mirrors the Maven artifact version
84+
- **Revision (4th component)**: Used for NuGet-only updates without Maven changes
85+
- **Pre-release suffixes**: Supported (e.g., "1.0.0.1-alpha05")
86+
87+
## Development Workflow
88+
89+
### Adding New Bindings
90+
1. Add artifact entry to `config.json`
91+
2. Run `dotnet cake --target=binderate` to generate projects
92+
3. Add any necessary customizations in `source/{groupId}/{artifactId}/`
93+
4. Build and test: `dotnet cake --target=libs`
94+
95+
### Updating Existing Bindings
96+
1. Use `dotnet cake --target=update-config` for automatic updates
97+
2. Or manually edit versions in `config.json`
98+
3. Run `dotnet cake --target=binderate-diff` to see changes
99+
4. Build and validate
100+
101+
### Version Bumping
102+
- Use `dotnet cake --target=bump-config` to increment revision numbers
103+
- This updates only non-dependency packages (where `dependencyOnly != true`)
104+
105+
### Release Process
106+
1. Tag commit: `git tag YYYYMMDD-weekly-stable-updates-YYYYMMDD`
107+
2. Push tag: `git push upstream <tag>`
108+
3. Use AndroidX Push NuGet.org pipeline in Azure DevOps
109+
110+
## Binding Customizations
111+
112+
### Per-Artifact Customizations
113+
Located in `source/{groupId}/{artifactId}/`:
114+
- **`Additions/`**: Additional C# code to add to generated bindings
115+
- **`Transforms/`**: XML transforms to modify generated API
116+
- **`Metadata.xml`**: Binding metadata and parameter names
117+
- **`merge.targets`**: Custom MSBuild targets to include
118+
119+
### Common Metadata Patterns
120+
For comprehensive guidance on troubleshooting binding issues, see: https://github.com/dotnet/java-interop/wiki/Troubleshooting-Android-Bindings-Issues
121+
122+
```xml
123+
<!-- Remove problematic APIs -->
124+
<remove-node path="/api/package[@name='com.example']/class[@name='ProblematicClass']" />
125+
126+
<!-- Fix parameter names -->
127+
<attr path="/api/package[@name='com.example']/class[@name='Example']/method[@name='example']/parameter[@name='p0']" name="name">properName</attr>
128+
129+
<!-- Add managed wrapper -->
130+
<add-node path="/api/package[@name='com.example']">
131+
<class abstract="false" deprecated="not deprecated" final="false" name="ManagedWrapper" static="false" visibility="public">
132+
</class>
133+
</add-node>
134+
```
135+
136+
## Target Frameworks
137+
138+
### Current Support
139+
- **Primary**: `net8.0-android` (API 21+)
140+
- **Migration**: `net10.0-android` (API 35+) - migration capability exists but not currently enabled
141+
- **Legacy**: Xamarin.Android support ended May 1, 2024
142+
143+
## Code Organization Patterns
144+
145+
### Generated Projects
146+
- Follow pattern: `{groupId}.{artifactId}.csproj`
147+
- Located in `generated/` directory
148+
- Include auto-generated targets files: `{nugetId}.targets`
149+
150+
### NuGet Package Structure
151+
```
152+
lib/
153+
net8.0-android34.0/
154+
{assembly}.dll
155+
net10.0-android36.0/
156+
{assembly}.dll
157+
build/
158+
net8.0-android34.0/
159+
{package}.targets
160+
net10.0-android36.0/
161+
{package}.targets
162+
```
163+
164+
## Testing and Validation
165+
166+
### Available Test Targets
167+
- **`all-packages-tests`**: Run test suite on built packages
168+
- **`build-run-all-packages-tests`**: Build then test all packages
169+
- **`api-diff`**: Generate API difference reports
170+
- **`binderate-config-verify`**: Validate config.json format
171+
- **`metadata-verify`**: Check binding metadata
172+
173+
### Quality Checks
174+
- **Namespace verification**: `dotnet cake utilities.cake -t=namespace-check`
175+
- **Spell checking**: `dotnet cake utilities.cake -t=spell-check`
176+
- **Target SDK verification**: `dotnet cake utilities.cake -t=target-sdk-version-check`
177+
178+
## Documentation Resources
179+
180+
### Internal Documentation
181+
- **`BUILDING.md`**: Comprehensive build instructions
182+
- **`docs/development-tips.md`**: Workflow tips and release procedures
183+
- **`docs/artifact-list.md`**: Complete Maven-to-NuGet mappings
184+
- **`.github/CONTRIBUTING.md`**: Contribution guidelines
185+
186+
### External Resources
187+
- [.NET for Android Documentation](https://learn.microsoft.com/en-us/dotnet/android/)
188+
- [AndroidX Release Notes](https://developer.android.com/jetpack/androidx/versions/stable-channel)
189+
- [Google Play Services Release Notes](https://developers.google.com/android/guides/releases)
190+
191+
## Best Practices for Contributors
192+
193+
### Before Making Changes
194+
1. Read `BUILDING.md` for full setup instructions
195+
2. Ensure all prerequisites are installed
196+
3. Run `dotnet cake -t=ci` to verify clean build
197+
4. Check existing issues and PRs for related work
198+
199+
This repository represents a critical piece of the .NET ecosystem for Android development, enabling C# developers to use the full range of modern Android libraries through automatically maintained bindings.

0 commit comments

Comments
 (0)