You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/copilot-instructions.md
+151-5Lines changed: 151 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,32 @@
1
-
## File encoding
1
+
# Copilot Instructions
2
+
3
+
## File encoding
2
4
3
5
All source files in this repository use **UTF-8 with BOM** (`EF BB BF`).
4
6
5
7
When creating or editing files, always save them as UTF-8 with BOM. This applies to `.cs`, `.csproj`, `.yml`, `.md`, `.json`, and all other text files.
6
8
7
-
Do **not** save files as UTF-8 without BOM, ANSI, or Shift-JIS — doing so will corrupt Japanese content and break Visual Studio / MSBuild tooling.
9
+
**Exception — Linux tooling files: use UTF-8 without BOM.**
10
+
The following file types are processed by Linux tools (Docker, bash, VS Code Dev Containers) that do not tolerate a BOM and must be saved **without** BOM:
11
+
-`Dockerfile` and any file named `*.Dockerfile`
12
+
- Shell scripts (`.sh`)
13
+
-`devcontainer.json` and all files under `.devcontainer/`
14
+
15
+
Do **not** save files as UTF-8 without BOM, ANSI, or Shift-JIS — doing so will corrupt Japanese content and break Visual Studio / MSBuild tooling (for the files above that require BOM).
16
+
17
+
### Editing workflow requirement
18
+
19
+
Maintain correct encoding **during each edit/create step** — do not correct it in a follow-up step.
20
+
21
+
Do not rely on a final "bulk conversion/check" step at the end of the task.
22
+
23
+
**Important:** The `create_file` tool does **not** interpret `\uFEFF` in the content string as BOM bytes — it writes the literal six characters `\uFEFF`. Never place `\uFEFF` (or any Unicode escape for U+FEFF) directly in the `content` parameter. Instead, create the file first (BOM-free), then immediately apply the PowerShell conversion command below for files that require BOM.
8
24
9
25
### Verification
10
26
11
-
```powershell
27
+
Do not run the verification/conversion commands on every edit by default.
28
+
Prevent encoding issues through edit/create operations that preserve UTF-8 BOM.
29
+
Run the commands below only when preservation cannot be guaranteed or when troubleshooting is required.
When editing the root `README.md`, also update the NuGet-specific README files accordingly.
@@ -38,3 +54,133 @@ The NuGet READMEs are a subset of the top-level README and consist of the follow
38
54
- Links (GitHub, Samples, API Docs, Issue Tracker)
39
55
40
56
Do **not** include CI badges, Docker instructions, build instructions, or donation links in the NuGet READMEs.
57
+
58
+
## Agent mode — terminal commands
59
+
60
+
In agent mode, do **not** use display commands that require user input (e.g., `more`, `less` without options). Use non-interactive alternatives instead:
- Git: pass `-P` or `--no-pager`, or pipe to `Out-String`; e.g. `git --no-pager diff`
63
+
- Use `cat` for displaying file contents.
64
+
65
+
## Adding a new OpenCV class wrapper
66
+
67
+
> **Scope**: This checklist covers `cv::SomeClass : cv::Algorithm` subclasses. OpenCV also has classes that do **not** inherit from `Algorithm` — those may follow different ownership and lifetime patterns (see existing non-Algorithm wrappers such as `BackgroundSubtractor` or classes in `core/` for reference).
68
+
69
+
Follow this checklist when wrapping a new `cv::SomeClass : cv::Algorithm` class:
// C# side — [MarshalAs(UnmanagedType.Bool)] makes bool marshal as 4-byte BOOL matching int in C
163
+
[StructLayout(LayoutKind.Sequential)]
164
+
public struct SomeClassParams {
165
+
[MarshalAs(UnmanagedType.Bool)] public bool SomeBool;
166
+
// other fields...
167
+
}
168
+
// P/Invoke: out SomeClassParams / ref SomeClassParams
169
+
```
170
+
171
+
### Namespace access note
172
+
173
+
From `namespace OpenCvSharp.Internal`, types in `namespace OpenCvSharp` are directly visible (outer scope rule). Types in a sub-namespace such as `namespace OpenCvSharp.XImgProc` are NOT — add an explicit `using` directive in the NativeMethods file when referencing structs defined there.
-`std::vector<Vec6d>` → `VectorOfVec6d` (added in EdgeDrawing PR)
181
+
- New vector types: add `#pragma region` in `std_vector.h`, `#region` in `NativeMethods_stdvector.cs`, and create `VectorOfXxx.cs`
182
+
183
+
### EdgeDrawing as reference implementation
184
+
185
+
See `src/OpenCvSharpExtern/ximgproc_EdgeDrawing.h`, `src/OpenCvSharp/Modules/ximgproc/EdgeDrawing.cs` for a complete example covering: factory, OutputArray methods, std::vector methods, nested Params struct with bool fields, and VectorOfVec6d.
0 commit comments