Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 8, 2025

Investigation revealed build failures, tight coupling to Azure Table Storage, and pervasive magic strings reducing maintainability and testability.

Changes

Fix Build Errors

  • Generated missing Alias.generated.cs, Accelerators.generated.cs, TokenKind.generated.cs via code generators
  • These files are .gitignored and must be generated locally via bootstrap.ps1

Extract Constants

// Before: Magic strings scattered throughout
HelpTableQuery("about_classes")
var client = TableClientFactory.Create("HelpData");

// After: Centralized constants
HelpTableQuery(Constants.AboutTopics.AboutClasses)
var client = TableClientFactory.Create(Constants.TableStorage.HelpDataTableName);

Implement Repository Pattern

public interface IHelpRepository
{
    HelpEntity? GetHelpForCommand(string commandName);
    HelpEntity? GetHelpForCommand(string commandName, string moduleName);
    List<HelpEntity> GetHelpForCommandRange(string commandName);
}

// AstVisitorExplainer now depends on interface, not TableClient
public AstVisitorExplainer(string extentText, IHelpRepository helpRepository, ILogger log, Token[]? tokens)
  • TableStorageHelpRepository: Production implementation for Azure Table Storage
  • InMemoryHelpRepository: Test double for unit tests without Azurite dependency
  • Consolidates duplicate HelpTableQuery methods into repository

Fix Nullable Warnings

  • Initialize errorMessage field to empty string (CS8618)
  • Mark tokens parameter as nullable (Token[]?)
  • Add nullable return types to HelpTableQuery methods
  • Simplify redundant null checks

Impact

  • Build: 24 errors → 0 errors
  • Testability: Can now unit test without Azurite (7 new passing tests)
  • Maintainability: All magic strings centralized, reduced code duplication
  • Security: CodeQL scan shows 0 alerts
Original prompt

Create a branch and start a thorough investigation in this repo for code smells, inconsistencies, warnings, focussing on the c# solution. I'd like to really improve quality and maintainability of the code. Make it more testable, improve code coverage in unit tests.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 5 commits December 8, 2025 08:01
Co-authored-by: Jawz84 <26464885+Jawz84@users.noreply.github.com>
Co-authored-by: Jawz84 <26464885+Jawz84@users.noreply.github.com>
…cerns

Co-authored-by: Jawz84 <26464885+Jawz84@users.noreply.github.com>
Co-authored-by: Jawz84 <26464885+Jawz84@users.noreply.github.com>
Co-authored-by: Jawz84 <26464885+Jawz84@users.noreply.github.com>
Copilot AI changed the title [WIP] Investigate code smells and improve code quality Improve C# code quality: fix build errors, add repository pattern, extract constants Dec 8, 2025
Copilot AI requested a review from Jawz84 December 8, 2025 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants