メインコンテンツまでスキップ

ローカルデバッグガイド — C#

Last updated on April 8, 2026

This guide covers everything specific to debugging an Extend Service Extension app written in C#. For general debugging concepts — environment setup, VS Code debug workflow, log reading, and common issues — see:


Project structure

src/
└── AccelByte.Extend.ServiceExtension.Server/
├── AccelByte.Extend.ServiceExtension.Server.csproj
├── Program.cs # Entry point
├── Classes/
│ ├── AuthorizationInterceptor.cs # IAM token and permission validation
│ └── ...
├── Protos/
│ ├── service.proto # gRPC API definition
│ └── ...
└── Services/
└── MyService.cs # Your business logic
FileWhat it does
Program.csEntry point — wires gRPC server, gRPC-Gateway, metrics, and auth.
Services/MyService.csYour business logic — implements the gRPC service methods.
Classes/AuthorizationInterceptor.csValidates every incoming request's IAM token and permission.
Protos/service.protoDefines the gRPC API — endpoints, request/response shapes, and required permissions.

Port numbers:

PortPurpose
6565gRPC server (internal — used by gRPC-Gateway)
8000gRPC-Gateway HTTP/REST — call this from a browser, Postman, or curl
8080Prometheus metrics endpoint (/metrics)

Running the service locally

From the terminal

# Export all variables from your .env file
export $(grep -v '^#' .env | xargs)

dotnet run --project src/AccelByte.Extend.ServiceExtension.Server

From VS Code

Use Terminal → Run Task → "Run: Service". This task is defined in .vscode/tasks.json and loads the .env file for you automatically.

Confirming the service is up

You should see logs like:

{"time":"...","level":"INFO","msg":"app server started","service":"extend-app-service-extension"}
{"time":"...","level":"INFO","msg":"starting gRPC-Gateway HTTP server","port":8000}
{"time":"...","level":"INFO","msg":"serving prometheus metrics","port":8080,"endpoint":"/metrics"}

Open http://localhost:8000<BASE_PATH>/apidocs/ in your browser to verify Swagger UI is live.


Attaching the debugger

The repository ships with a ready-to-use launch configuration in .vscode/launch.json:

{
"name": "Debug: Service",
"type": "coreclr",
"request": "launch",
"program": "${workspaceFolder}/src/AccelByte.Extend.ServiceExtension.Server/bin/Debug/net8.0/AccelByte.Extend.ServiceExtension.Server.dll",
"envFile": "${workspaceFolder}/.env",
"cwd": "${workspaceFolder}",
"console": "integratedTerminal"
}

Follow the attaching the debugger steps in the generic guide, then select "Debug: Service" from the dropdown.

Other IDEs

Start the app with diagnostics enabled, then attach your IDE using "Attach to process":

export $(grep -v '^#' .env | xargs)
DOTNET_EnableDiagnostics=1 dotnet run --project src/AccelByte.Extend.ServiceExtension.Server

Most IDEs (JetBrains Rider, Visual Studio) support attaching to a running .NET process via Run → Attach to process.


Where to put breakpoints

What you want to investigateFile and location
A specific REST endpoint being calledServices/MyService.cs — top of the relevant method
Auth/token validation failureClasses/AuthorizationInterceptor.cs — the Intercept method
Data not saving or loading correctlyThe storage/repository class used in your service
Service not starting at allProgram.cs — the startup initialization block

For conditional breakpoint syntax, see the C# language guide.


Reading logs

For jq log filtering, see the C# language guide.


Testing endpoints manually

For curl and grpcurl usage, see Testing with grpcurl in the generic guide.

For Swagger UI testing (SE-specific), see Testing endpoints manually in the SE main guide.


C#-specific troubleshooting

Proto changes have no effect

Symptom: You edited Protos/service.proto but nothing changed at runtime.

Cause: The generated gRPC stubs have not been rebuilt.

Fix: Run a clean build:

dotnet build src/AccelByte.Extend.ServiceExtension.Server

The .csproj file includes a <Protobuf> item that triggers code generation automatically on build. If you still see stale behavior, run:

dotnet clean && dotnet build src/AccelByte.Extend.ServiceExtension.Server

DOTNET_ENVIRONMENT and configuration sources

The app may read additional configuration from appsettings.json or environment-specific variants (appsettings.Development.json). Set DOTNET_ENVIRONMENT=Development in your .env to activate development-mode configuration.


Checking for port conflicts

See Checking for port conflicts in the C# language guide.


AI assistance

The app template ships with a Claude agent skill at .claude/skills/debugging-guide/SKILL.md.

For AI prompting tips and MCP server details, see Debugging with AI assistance in the generic guide.


References