From 91f2d3d451026a16e8c78bcd541003681f5a814d Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Wed, 10 Sep 2025 11:12:08 +0100 Subject: [PATCH 1/5] add base files and folder for copilot agent setup --- src/.copilot/csharp-standards.instructions.md | 0 src/.copilot/generate-country.prompt.md | 0 src/.copilot/worldnet-standards.instructions.md | 0 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/.copilot/csharp-standards.instructions.md create mode 100644 src/.copilot/generate-country.prompt.md create mode 100644 src/.copilot/worldnet-standards.instructions.md diff --git a/src/.copilot/csharp-standards.instructions.md b/src/.copilot/csharp-standards.instructions.md new file mode 100644 index 0000000..e69de29 diff --git a/src/.copilot/generate-country.prompt.md b/src/.copilot/generate-country.prompt.md new file mode 100644 index 0000000..e69de29 diff --git a/src/.copilot/worldnet-standards.instructions.md b/src/.copilot/worldnet-standards.instructions.md new file mode 100644 index 0000000..e69de29 From 25daf02a464a53a63dfa7e98e98a21a01b2a3a95 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Wed, 10 Sep 2025 11:44:52 +0100 Subject: [PATCH 2/5] add copilot instructions --- .../copilot-country-creation.setup.md | 97 +++++++++++++++++++ src/.copilot/csharp-standards.instructions.md | 15 +++ src/.copilot/generate-country.prompt.md | 0 .../worldnet-standards.instructions.md | 57 +++++++++++ 4 files changed, 169 insertions(+) create mode 100644 src/.copilot/copilot-country-creation.setup.md delete mode 100644 src/.copilot/generate-country.prompt.md diff --git a/src/.copilot/copilot-country-creation.setup.md b/src/.copilot/copilot-country-creation.setup.md new file mode 100644 index 0000000..408938e --- /dev/null +++ b/src/.copilot/copilot-country-creation.setup.md @@ -0,0 +1,97 @@ +--- +mode: 'agent' +tools: ['codebase'] +description: 'Generate a new Country class and Unit Test for World.Net by only providing the country name. If no country name is provided, ask for it and wait for user input.' +--- + +# Copilot Country Creation Prompt for World.Net + +## Instructions +When you are asked to "create a country": + +1. **Check for Country Name** + - If the user provides a country name (e.g., "Create a country: Kenya"), use it directly. + - If the user does not provide a country name (e.g., just "Create a country"), ask: "What is the name of the country you would like to create? Please provide the official country name (e.g., 'Nigeria')." Then wait for the user to reply with the country name before proceeding. + +2. **Read C# and World.Net Standards** + - Read and apply the standards from `src/.copilot/csharp-standards.instructions.md` and `src/.copilot/worldnet-standards.instructions.md`. + - Ensure all generated code follows these conventions (naming, formatting, documentation, etc.). + +3. **Create the Country Class** + - Place in `src/World.Net/Countries/`. + - Class name must match the country (e.g., `Nigeria.cs` ? `public sealed class Nigeria : ICountry`). + - Implement all `ICountry` properties: `Id`, `Name`, `OfficialName`, `NativeName`, `Capital`, `NumericCode`, `ISO2Code`, `ISO3Code`, `CallingCode`, `States`. + - Use immutable properties (fixed values, no setters). + - Use the correct `CountryIdentifier.` for `Id`. + - All data must be ISO/UN recognized and complete. + +4. **Register in CountryInitializer** + - Add the new country to `CountryInitializer.Initialize()` in `src/World.Net/Helpers/CountryInitializer.cs`. + - Use: `{ CountryIdentifier., new () },` + - Keep entries alphabetically ordered by enum key. + - Do not duplicate entries. + +5. **Add to CountryIdentifier Enum** + - Add a new entry to `CountryIdentifier` in `src/World.Net/Helpers/CountryIdentifier.cs` if not present. + - Enum name must match the class name exactly. + - Keep enum entries alphabetically ordered. + +6. **Create Unit Tests** + - Place in `src/World.Net.UnitTests/Countries/`. + - File name: `Test.cs`. + - Class name: `Test`. + - Use constants for all expected values. + - Test must retrieve the country via `CountryProvider.GetCountry(CountryIdentifier.)` and assert all properties. + - Example: + ```csharp + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForNigeria() + { + var country = CountryProvider.GetCountry(CountryIdentifier.Nigeria); + Assert.Equal(CountryIdentifier.Nigeria, country.Id); + Assert.Equal("Nigeria", country.Name); + Assert.Equal("Federal Republic of Nigeria", country.OfficialName); + Assert.Equal("Nigeria", country.NativeName); + Assert.Equal("Abuja", country.Capital); + Assert.Equal(566, country.NumericCode); + Assert.Equal("NG", country.ISO2Code); + Assert.Equal("NGA", country.ISO3Code); + Assert.Equal(new[] { "+234" }, country.CallingCode); + } + ``` + - Validate all states/regions for count and type if applicable. + +7. **General Rules** + - All country classes must be immutable. + - No country logic outside the Countries folder. + - No incomplete or placeholder data. + - Always run unit tests after adding a country. + +## Copilot Workflow +When asked to "create a country": +1. Ask for the country name. +2. Read and apply the C# standards from `src/.copilot/csharp-standards.instructions.md`. +3. Search for the country in `CountryIdentifier` and add if missing. +4. Create the country class in `src/World.Net/Countries/`. +5. Register it in `CountryInitializer`. +6. Create a unit test in `src/World.Net.UnitTests/Countries/`. +7. Run a build and all tests to verify correctness. + +## Example Directory Structure +``` +src/World.Net/Countries/Nigeria.cs +src/World.Net/Helpers/CountryInitializer.cs +src/World.Net/Helpers/CountryIdentifier.cs +src/World.Net.UnitTests/Countries/NigeriaTest.cs +``` + +## Additional Guidance +- Use `text_search` to discover related code and avoid duplication. +- Always check for existing enum/class/test before creating new ones. +- Follow the naming and ordering conventions strictly. +- Use only ISO/UN official data for all country properties. +- If a country has subdivisions (states, provinces, etc.), list them in the `States` property using the correct type and ISO codes. +- If you are unsure about a country's data, do not create a placeholder—skip or request clarification. + +--- +This file is for Copilot agent prompt use. Do not edit unless updating the automation workflow or standards. diff --git a/src/.copilot/csharp-standards.instructions.md b/src/.copilot/csharp-standards.instructions.md index e69de29..ad14d75 100644 --- a/src/.copilot/csharp-standards.instructions.md +++ b/src/.copilot/csharp-standards.instructions.md @@ -0,0 +1,15 @@ +--- +applyTo: "**/*.cs" +--- + +# C# Coding Standards for World.Net + +- Use PascalCase for classes, enums, and public members. +- Use camelCase for local variables and parameters. +- Prefix private fields with underscore (`_`). +- Async methods must end with `Async`. +- One class per file. +- Keep methods focused and under ~30 lines. +- Always use `var` for local variables unless the type is unclear. +- Include XML docs for public members. +- Write unit tests using `xUnit`. diff --git a/src/.copilot/generate-country.prompt.md b/src/.copilot/generate-country.prompt.md deleted file mode 100644 index e69de29..0000000 diff --git a/src/.copilot/worldnet-standards.instructions.md b/src/.copilot/worldnet-standards.instructions.md index e69de29..821b578 100644 --- a/src/.copilot/worldnet-standards.instructions.md +++ b/src/.copilot/worldnet-standards.instructions.md @@ -0,0 +1,57 @@ +--- +applyTo: "**/*.cs" +--- + +# World.Net Standards + +## Country Classes +- All countries live under `World.Net/Countries/`. +- Each country must implement the `ICountry` interface. +- Class name must match the country name (e.g., `Nigeria.cs` ? `public sealed class Nigeria : ICountry`). +- `ICountry` must expose: Id, Name, OfficialName, NativeName, Capital, NumericCode, ISO2Code, ISO3Code, CallingCode. +- Use `CountryIdentifier.` enum for the `Id` property. + +## CountryInitializer +- All countries must be added to `CountryInitializer`: + ```csharp + _countries.Add(CountryIdentifier.Nigeria, new Nigeria()); +- Do not duplicate entries. +- Keep entries alphabetically ordered by enum key where possible. + +## CountryIdentifier Enum + +- Every country must have a unique enum entry in CountryIdentifier. +- Enum names must match the class names exactly (e.g., Nigeria ? CountryIdentifier.Nigeria). +- Enum entries should be alphabetically ordered. + +## Unit Tests + +- Each country must have a dedicated test class in World.Net.UnitTests/. +- Test class name format: Test. +- Each test must: +- Retrieve the country instance via CountryProvider.GetCountry(CountryIdentifier.). +- Validate all properties (Name, OfficialName, NativeName, Capital, NumericCode, ISO2Code, ISO3Code, CallingCode) against constants defined in the test. + +Example: +[Fact] +public void GetCountry_ReturnsCorrectInformation_ForNigeria() +{ + var country = CountryProvider.GetCountry(CountryIdentifier.Nigeria); + + Assert.Equal(CountryIdentifier.Nigeria, country.Id); + Assert.Equal("Nigeria", country.Name); + Assert.Equal("Federal Republic of Nigeria", country.OfficialName); + Assert.Equal("Nigeria", country.NativeName); + Assert.Equal("Abuja", country.Capital); + Assert.Equal(566, country.NumericCode); + Assert.Equal("NG", country.ISO2Code); + Assert.Equal("NGA", country.ISO3Code); + Assert.Equal(new[] { "+234" }, country.CallingCode); +} + +## General Rules + +- All countries must be immutable objects (properties return fixed values). +- Do not hardcode country logic outside of the Countries folder. +- Do not expose incomplete or placeholder data; all country classes must include valid ISO and UN-recognized information. +- Always run unit tests after adding a new country to ensure correctness. From 57e84614035f4c06c876d15374170fea3f70c7c6 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Wed, 10 Sep 2025 11:46:16 +0100 Subject: [PATCH 3/5] update state --- .vs/VSWorkspaceState.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json index 9e1100e..5afa4d9 100644 --- a/.vs/VSWorkspaceState.json +++ b/.vs/VSWorkspaceState.json @@ -1,7 +1,9 @@ { "ExpandedNodes": [ - "" + "", + "\\src", + "\\src\\.copilot" ], - "SelectedNode": "\\C:\\Users\\anyan\\Source\\Repos\\world.net", + "SelectedNode": "\\src\\.copilot\\copilot-country-creation.setup.md", "PreviewInSolutionExplorer": false } \ No newline at end of file From 62b49f6168770587633b283fe9c6c6e83ff3b2bb Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Wed, 10 Sep 2025 11:47:19 +0100 Subject: [PATCH 4/5] . --- .vs/VSWorkspaceState.json | 1 - 1 file changed, 1 deletion(-) diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json index 5afa4d9..03a456e 100644 --- a/.vs/VSWorkspaceState.json +++ b/.vs/VSWorkspaceState.json @@ -4,6 +4,5 @@ "\\src", "\\src\\.copilot" ], - "SelectedNode": "\\src\\.copilot\\copilot-country-creation.setup.md", "PreviewInSolutionExplorer": false } \ No newline at end of file From 1be34aa88a531799d1391ab9c6321a295a67d691 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Wed, 10 Sep 2025 18:13:29 +0100 Subject: [PATCH 5/5] add generate prompt --- ...y-creation.setup.md => generate-country.prompt.md} | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) rename src/.copilot/{copilot-country-creation.setup.md => generate-country.prompt.md} (87%) diff --git a/src/.copilot/copilot-country-creation.setup.md b/src/.copilot/generate-country.prompt.md similarity index 87% rename from src/.copilot/copilot-country-creation.setup.md rename to src/.copilot/generate-country.prompt.md index 408938e..99b4b14 100644 --- a/src/.copilot/copilot-country-creation.setup.md +++ b/src/.copilot/generate-country.prompt.md @@ -9,9 +9,14 @@ description: 'Generate a new Country class and Unit Test for World.Net by only p ## Instructions When you are asked to "create a country": -1. **Check for Country Name** - - If the user provides a country name (e.g., "Create a country: Kenya"), use it directly. - - If the user does not provide a country name (e.g., just "Create a country"), ask: "What is the name of the country you would like to create? Please provide the official country name (e.g., 'Nigeria')." Then wait for the user to reply with the country name before proceeding. +1. **Prompt for Country Name** + - Always check if the user included the country name. + - If the name **is provided** (e.g., "Create a country: Kenya"), use it directly. + - If the name **is not provided** (e.g., "Create a country"), immediately ask: + > "What is the name of the country you would like to create? Please provide the official country name (e.g., 'Nigeria')." + - After the user provides the country name, **continue automatically** with the workflow. + - Do not ask for any additional information such as ISO codes, capitals, or calling codes. Use official ISO/UN data automatically. + 2. **Read C# and World.Net Standards** - Read and apply the standards from `src/.copilot/csharp-standards.instructions.md` and `src/.copilot/worldnet-standards.instructions.md`.