

Also from Kynth Studios


Also from Kynth Studios


Also from Kynth Studios
1234567# Debugging and Testing Patterns89## Logging1011### LogManager Usage12Use LogManager for structured logging:1314```csharp15using UGTLive;1617// Info log18LogManager.Instance.LogInfo("Processing started");1920// Error log21LogManager.Instance.LogError("Failed to process", exception);2223// Debug log24LogManager.Instance.LogDebug("Debug information");25```2627### Console Output28Use Console.WriteLine for debug output:2930```csharp31Console.WriteLine($"Processing {count} items");32Console.WriteLine($"Config value: {key} = {value}");33```3435### Masking Sensitive Data36Never log API keys or sensitive information:3738```csharp39// BAD40Console.WriteLine($"API Key: {apiKey}");4142// GOOD43Console.WriteLine($"API Key: {(string.IsNullOrEmpty(apiKey) ? "not set" : "***")}");44```4546## Error File Writing4748### Service Error Files49Some services write error details to files for debugging:5051```csharp52try53{54 // API call55}56catch (Exception ex)57{58 string errorFile = "gemini_last_error.txt";59 File.WriteAllText(errorFile,60 $"Error: {ex.Message}\n\nStack trace: {ex.StackTrace}");6162 Console.WriteLine($"Error written to {errorFile}");63}64```6566## Debug Configuration Files6768### Debug Output Files69The app writes debug files for troubleshooting:7071- `last_llm_request_sent.txt` - Last LLM request72- `last_llm_reply_received.txt` - Last LLM response73- `last_ocr_response.json` - Last OCR result74- `gemini_last_error.txt` - Last Gemini error75- `openai_audio_log.txt` - OpenAI audio debug log7677### Writing Debug Files78```csharp79public void WriteDebugFile(string filename, string content)80{81 try82 {83 string debugPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, filename);84 File.WriteAllText(debugPath, content);85 Console.WriteLine($"Debug file written: {debugPath}");86 }87 catch (Exception ex)88 {89 Console.WriteLine($"Failed to write debug file: {ex.Message}");90 }91}92```9394## Exception Handling9596### Unhandled Exception Handler97App.xaml.cs handles unhandled exceptions:9899```csharp100private void App_DispatcherUnhandledException(object sender,101 DispatcherUnhandledExceptionEventArgs e)102{103 Console.WriteLine($"Unhandled exception: {e.Exception.Message}");104 Console.WriteLine($"Stack trace: {e.Exception.StackTrace}");105106 // Mark as handled to prevent crash107 e.Handled = true;108}109```110111### Service Exception Handling112Services should catch and log exceptions:113114```csharp115public async Task<Result?> ProcessAsync()116{117 try118 {119 return await DoWorkAsync();120 }121 catch (HttpRequestException ex)122 {123 Console.WriteLine($"HTTP error: {ex.Message}");124 LogManager.Instance.LogError("HTTP request failed", ex);125 return null;126 }127 catch (Exception ex)128 {129 Console.WriteLine($"Unexpected error: {ex.Message}");130 LogManager.Instance.LogError("Unexpected error", ex);131 return null;132 }133}134```135136## Debug Builds137138### Debug vs Release139Debug builds use different assembly names:140141```xml142<PropertyGroup Condition="'$(Configuration)'=='Debug'">143 <AssemblyName>ugtlive_debug</AssemblyName>144</PropertyGroup>145```146147### Conditional Compilation148```csharp149#if DEBUG150 Console.WriteLine("Debug mode - extra logging enabled");151#endif152```153154## Testing Translation Services155156### Manual Testing Pattern1571. Set API key in settings1582. Select service and model1593. Use Monitor window to capture text1604. Check ChatBox for results1615. Review logs for errors162163### Service Connection Test164```csharp165public async Task<bool> TestConnectionAsync()166{167 try168 {169 var result = await TranslateAsync("test", "en", "");170 return result != null;171 }172 catch (Exception ex)173 {174 Console.WriteLine($"Connection test failed: {ex.Message}");175 return false;176 }177}178```179180## OCR Testing181182### Testing OCR Output183```csharp184// Write OCR results to file for inspection185var ocrResults = await ProcessOCRAsync(bitmap);186var json = JsonSerializer.Serialize(ocrResults, new JsonSerializerOptions187{188 WriteIndented = true189});190File.WriteAllText("last_ocr_response.json", json);191```192193### Visual OCR Feedback194Monitor window shows OCR results visually:195196```csharp197private void DrawOCRResults(Graphics g, List<TextObject> textObjects)198{199 foreach (var textObj in textObjects)200 {201 // Draw bounding box202 g.DrawRectangle(Pens.Red, textObj.BoundingBox);203204 // Draw text205 g.DrawString(textObj.Text, font, Brushes.White, textObj.BoundingBox);206 }207}208```209210## Performance Debugging211212### Timing Operations213```csharp214var stopwatch = System.Diagnostics.Stopwatch.StartNew();215await ProcessAsync();216stopwatch.Stop();217Console.WriteLine($"Processing took {stopwatch.ElapsedMilliseconds}ms");218```219220### Memory Usage221```csharp222using System.Diagnostics;223224var process = Process.GetCurrentProcess();225Console.WriteLine($"Memory usage: {process.WorkingSet64 / 1024 / 1024} MB");226```227228## Network Debugging229230### HTTP Request Logging231```csharp232// Log request details233Console.WriteLine($"Request URL: {url}");234Console.WriteLine($"Request Method: POST");235Console.WriteLine($"Request Body: {requestBody}");236237var response = await httpClient.PostAsync(url, content);238239Console.WriteLine($"Response Status: {response.StatusCode}");240var responseBody = await response.Content.ReadAsStringAsync();241Console.WriteLine($"Response Body: {responseBody}");242```243244### WebSocket Debugging245```csharp246private void LogWebSocketMessage(string direction, string message)247{248 Console.WriteLine($"[WebSocket {direction}] {message}");249250 // Write to log file251 File.AppendAllText("websocket_log.txt",252 $"[{DateTime.Now}] {direction}: {message}\n");253}254```255256## Configuration Debugging257258### Dump Configuration259```csharp260public void DumpConfig()261{262 Console.WriteLine("=== Configuration Dump ===");263 foreach (var kvp in _configValues)264 {265 string value = kvp.Key.Contains("api_key") ? "***" : kvp.Value;266 Console.WriteLine($"{kvp.Key} = {value}");267 }268 Console.WriteLine("=========================");269}270```271272## Breakpoint Strategy273274### Strategic Breakpoints275- Entry points of service methods276- Error handling blocks277- Configuration loading/saving278- UI event handlers279- Async method completions280281### Conditional Breakpoints282```csharp283// Set breakpoint with condition: text.Length > 100284if (text.Length > 100)285{286 // Breakpoint here287}288```289290## Unit Testing Considerations291292### Testable Code Structure293- Separate business logic from UI294- Use dependency injection where possible295- Make methods static when they don't need instance state296- Extract complex logic into testable methods297298### Example Testable Method299```csharp300// Testable static method301public static string ProcessText(string input)302{303 if (string.IsNullOrWhiteSpace(input))304 {305 return "";306 }307308 return input.Trim().ToLower();309}310```311312## Integration Testing313314### Testing Service Integration315```csharp316// Test translation service317var service = TranslationServiceFactory.CreateService("Gemini");318var result = await service.TranslateAsync("test", "en", "");319Assert.IsNotNull(result);320```321322### Testing OCR Integration323```csharp324// Test OCR processing325var bitmap = LoadTestImage();326var results = await ocrManager.ProcessImageAsync(bitmap);327Assert.IsTrue(results.Count > 0);328```329330## Common Debugging Scenarios331332### Translation Not Working3331. Check API key is set3342. Verify service is running (for Ollama)3353. Check network connection3364. Review error logs3375. Test with simple text338339### OCR Not Detecting Text3401. Verify capture region is correct3412. Check OCR method is set correctly3423. Verify Python server is running (for EasyOCR)3434. Check language settings3445. Review OCR confidence thresholds345346### UI Not Updating3471. Verify Dispatcher.Invoke is used3482. Check if window is visible3493. Verify data binding is correct3504. Check for exceptions in logs351
One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| SethRobinson/UGTLive.cursor/rules/translation-workflow.mdc · 107 | Cursor rules | testlint-formatarchapi+3 | 66/100 | 14 days ago | |
| SethRobinson/UGTLive.cursor/rules/architecture-patterns.mdc · 107 | Cursor rules | buildtestlint-formatstyle+6 | 77/100 | 14 days ago | |
| SethRobinson/UGTLive.cursor/rules/async-threading-patterns.mdc · 107 | Cursor rules | styleuido-not | 65/100 | 14 days ago | |
| SethRobinson/UGTLive.cursor/rules/code-style-conventions.mdc · 107 | Cursor rules | stylearchtypesdocs | 62/100 | 14 days ago | |
| SethRobinson/UGTLive.cursor/rules/configuration-management.mdc · 107 | Cursor rules | archsecuritydatabaseapi+1 | 65/100 | 14 days ago | |
| SethRobinson/UGTLive.cursor/rules/locale-invariant-formatting.mdc · 107 | Cursor rules | lint-formatuido-not | 61/100 | 14 days ago | |
| SethRobinson/UGTLive.cursor/rules/service-integration-patterns.mdc · 107 | Cursor rules | buildteststylearch | 69/100 | 14 days ago | |
| SethRobinson/UGTLive.cursor/rules/ugtlive-project-guide.mdc · 107 | Cursor rules | stylearchuideployment+1 | 69/100 | 14 days ago | |
| SethRobinson/UGTLive.cursor/rules/ui-ux-patterns.mdc · 107 | Cursor rules | stylearchtypesui+1 | 62/100 | 14 days ago | |
| SethRobinson/UGTLive.cursor/rules/versioning-workflow.mdc · 107 | Cursor rules | stylegitdeploymentagent-behaviour+1 | 62/100 | 14 days ago | |
| SethRobinson/UGTLive.cursor/rules/wpf-ui-patterns.mdc · 107 | Cursor rules | setuplint-formatstylearch+1 | 66/100 | 14 days ago | |
| SethRobinson/UGTLiveAGENTS.md · 107 | AGENTS.md | testgitsecurityperformance+1 | 74/100 | 14 days ago |
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| ThanhTrunggDEV/DontBeLazy.cursor/rules/rust-testing.mdc · 6 | Cursor rules | teststyletesting-strategy | 90/100 | 14 days ago | |
| ThanhTrunggDEV/DontBeLazy.cursor/rules/dart-testing.mdc · 6 | Cursor rules | teststyletypestesting-strategy | 85/100 | 14 days ago | |
| ThanhTrunggDEV/DontBeLazy.cursor/rules/dart-coding-style.mdc · 6 | Cursor rules | lint-formatstyletypesdo-not | 84/100 | 14 days ago | |
| ThanhTrunggDEV/DontBeLazy.cursor/rules/rust-security.mdc · 6 | Cursor rules | stylesecuritydatabasedo-not | 80/100 | 14 days ago | |
| imazen/imageflow.cursor/rules/ci.mdc · 4.4k | Cursor rules | setupbuildtestarch+3 | 79/100 | 14 days ago | |
| ThanhTrunggDEV/DontBeLazy.cursor/rules/dart-hooks.mdc · 6 | Cursor rules | lint-formatarchtesting-strategygit+1 | 78/100 | 14 days ago | |
| ThanhTrunggDEV/DontBeLazy.cursor/rules/rust-coding-style.mdc · 6 | Cursor rules | lint-formatstyle | 78/100 | 14 days ago | |
| SethRobinson/UGTLive.cursor/rules/architecture-patterns.mdc · 107 | Cursor rules | buildtestlint-formatstyle+6 | 77/100 | 14 days ago |
A badge carrying the measured quality of the strongest agent config file in this repository, out of 100. It reads from this index every time somebody loads your page, so it changes when the measurement changes and there is nothing to keep up to date. Free, no account, and the value is not something you or we can set by hand.
[](https://rulestack.kynth.studio/configs/sethrobinson-ugtlive-cursor-rules-debugging-testing)Would rather not hotlink us? Every badge is also served in shields.io’s endpoint schema, so shields renders the image and your readers never talk to our domain:
Published by Toolproof, the masthead over this index and eight others. The method behind the number is at toolproof.kynth.studio/methodology, and the whole thing is readable as JSON with no key at /api.