Skip to content

Commit 799ce60

Browse files
Add AGENTS.md for VB.NET samples repository guidelines
- Define project structure, coding conventions, and testing process. - Include setup, development, and sample execution instructions. - Provide commit and PR guidelines, along with security best practices. - Specify tone and audience for customer-facing samples, with a standardized header template for examples.
1 parent 92c9524 commit 799ce60

1 file changed

Lines changed: 112 additions & 0 deletions

File tree

VB.NET/AGENTS.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# Repository Guidelines
2+
3+
## Project Structure & Module Organization
4+
- `VBNetSamples.vbproj`: Single root console project compiling all VB samples.
5+
- `Program.vb`: Dispatcher routing `dotnet run -- <command>` to a specific sample.
6+
- `Endpoint Examples/JSON Payload/`: Two-step samples (upload then operate), e.g., `markdown.vb`.
7+
- `Endpoint Examples/Multipart Payload/`: Single multipart request samples, e.g., `rasterized-pdf.vb`.
8+
- `Complex Flow Examples/`: Multi-step workflows chaining several endpoints.
9+
- `.env.example` → copy to `.env` and set `PDFREST_API_KEY` (loaded by DotNetEnv at startup).
10+
- `README.md`: High-level setup and usage for VB.NET samples.
11+
12+
## Build, Test, and Development Commands
13+
- Install .NET SDK (8.0+): verify with `dotnet --version`.
14+
- Restore/build: `dotnet restore VBNetSamples.vbproj && dotnet build VBNetSamples.vbproj`.
15+
- Run a sample via dispatcher: `dotnet run --project VBNetSamples.vbproj -- <command> [args]`.
16+
- Example: `dotnet run --project VBNetSamples.vbproj -- markdown /path/to/input.pdf`.
17+
- Dependencies:
18+
- `.env` loading is included via `DotNetEnv`.
19+
- Optional JSON helper: `dotnet add VBNetSamples.vbproj package Newtonsoft.Json` (only if a sample uses it).
20+
- File-focused testing: keep each sample self-contained (accept input path as first arg; minimal edits).
21+
22+
## Coding Style & Naming Conventions
23+
- VB style: 4-space indentation, `PascalCase` for types/methods, `camelCase` for locals/parameters.
24+
- File naming: match pdfRest endpoint with hyphenated lowercase, e.g., `markdown.vb`, `rasterized-pdf.vb`.
25+
- Sample structure: each sample exposes `Public Async Function Execute(args() As String) As Task` and lives under a namespace mirroring its folder. Use underscores for folder segments that contain spaces:
26+
- JSON two-step: `Namespace VBNetSamples.Endpoint_Examples.JSON_Payload`
27+
- Multipart: `Namespace VBNetSamples.Endpoint_Examples.Multipart_Payload`
28+
- Complex flows: `Namespace VBNetSamples.Complex_Flow_Examples`
29+
- Note: This satisfies IDE checks like “Namespace does not correspond to file location”.
30+
- Dispatcher: `Program.vb` contains `Sub Main` and routes commands to `...Execute(args)`; do not add additional `Main` methods in samples.
31+
- Env config: read `PDFREST_API_KEY` and optional `PDFREST_URL`; `.env` is auto-loaded by `DotNetEnv`.
32+
- HTTP: use `HttpClient` with explicit `Accept`/`Content-Type`; set `Api-Key` per request; use `MultipartFormDataContent`; default base URL `https://api.pdfrest.com` with `PDFREST_URL` override.
33+
- Errors: check `response.IsSuccessStatusCode`; on failure, write a concise error to `Console.Error` and exit non-zero.
34+
35+
## Testing Guidelines
36+
- No formal test suite required. Validate by running samples against known inputs.
37+
- Success criteria: exit non-zero on failures; print API JSON response to stdout on success.
38+
- New samples: accept input path as first argument when practical; document optional params inline near usage.
39+
40+
## Commit & Pull Request Guidelines
41+
- Commits: imperative mood and focused scope (e.g., "Add multipart markdown VB sample").
42+
- Describe what changed and why; reference endpoint and path.
43+
- PRs: include clear description, run commands used for verification, expected response snippet, and any notes on options.
44+
- Link related issues; avoid unrelated changes in the same PR.
45+
46+
## Security & Configuration Tips
47+
- Keep secrets out of VCS: do not commit `.env`; include a `.env.example` with placeholder keys if the folder uses `.env`.
48+
- Support proxies via standard env vars (e.g., `HTTPS_PROXY`) when applicable.
49+
- Never log API keys; print response bodies and minimal diagnostics only (send diagnostics to `Console.Error`).
50+
- API base override: set `PDFREST_URL` to change regions. For EU GDPR compliance and improved performance in Europe, you may use `https://eu-api.pdfrest.com/`. More info: https://pdfrest.com/pricing#how-do-eu-gdpr-api-calls-work
51+
52+
---
53+
54+
## Audience And Tone (Internal)
55+
56+
These samples are customer-facing and intended to help potential customers evaluate pdfRest quickly. Keep all code, comments, and documentation clear, minimal, and task-focused. Avoid internal jargon and advanced implementation details in customer-visible files. Do not surface internal process notes in `README.md` or the samples.
57+
58+
Key points:
59+
- Clarity: explain what the sample does in 1–2 bullets.
60+
- Guidance: show how to set the API key and how to run.
61+
- Region: mention optional `PDFREST_URL` with the EU endpoint for GDPR and proximity.
62+
- Safety: never log secrets; print only response bodies and minimal diagnostics to stderr.
63+
- Errors: exit non‑zero on non‑2xx with a concise message.
64+
65+
## Sample Header Convention (Internal)
66+
67+
Add this standardized header comment at the top of every VB.NET sample. This header is customer-visible but the convention itself is for us to remember here (do not duplicate these instructions in README).
68+
69+
Template:
70+
71+
'''
72+
' What this sample does:
73+
' - <One–two bullets describing purpose and request style>
74+
'
75+
' Setup (environment):
76+
' - Copy .env.example to .env
77+
' - Set PDFREST_API_KEY=your_api_key_here
78+
' - Optional: set PDFREST_URL to override the API region. For EU/GDPR compliance and proximity, use:
79+
' PDFREST_URL=https://eu-api.pdfrest.com
80+
' For more information visit https://pdfrest.com/pricing#how-do-eu-gdpr-api-calls-work
81+
'
82+
' Usage (via dispatcher):
83+
' dotnet run --project VBNetSamples.vbproj -- <command-name> /path/to/input.pdf
84+
'
85+
' Output:
86+
' - Prints the API JSON response to stdout. Non-2xx responses write a concise message to stderr and exit non-zero.
87+
' - Tip: pipe output to a file: dotnet run --project VBNetSamples.vbproj -- <command-name> ... > response.json
88+
'''
89+
90+
Notes:
91+
- Match the endpoint name and request style (JSON two‑step vs multipart single request) in the bullets.
92+
- Keep the header concise; avoid adding options unless essential.
93+
- If a sample accepts optional parameters, mention them inline in code near where they are used.
94+
95+
## README Scope (Internal)
96+
97+
Keep `README.md` focused on user setup, running samples, and high‑level background. Avoid internal conventions or meta‑process content that could confuse customers. Place internal notes and templates in `AGENTS.md` (this file).
98+
99+
---
100+
101+
## VB.NET Implementation Notes (Internal)
102+
- Dispatcher entry point: `Program.vb` exposes `Sub Main` (wrapping an async method) and selects a sample based on the first CLI argument. Only one entry point exists.
103+
- Add a new sample:
104+
- Create a `.vb` file under the appropriate folder.
105+
- Namespace as noted above; expose `Public Async Function Execute(args() As String) As Task`.
106+
- Update `Program.vb` `Select Case` to map a command (e.g., `png`) to the new module’s `Execute`.
107+
- JSON parsing: prefer `System.Text.Json`; if using `Newtonsoft.Json`, add the NuGet package and import `Newtonsoft.Json.Linq` for simple extraction.
108+
- Multipart uploads: `New MultipartFormDataContent()` with `ByteArrayContent` or `StreamContent`. Set `Content-Type` and filename as needed.
109+
- Headers: set `Api-Key` per request; always send `Accept: application/json`.
110+
- Base URL: default `https://api.pdfrest.com`; support `PDFREST_URL` override.
111+
- Env loader: `.env` is loaded automatically via `DotNetEnv` at startup.
112+
- Errors: prefer `If Not response.IsSuccessStatusCode Then ... Environment.Exit(1)`.

0 commit comments

Comments
 (0)