Skip to content

Develop#78

Merged
CedaryCat merged 2 commits into
mainfrom
develop
Mar 16, 2026
Merged

Develop#78
CedaryCat merged 2 commits into
mainfrom
develop

Conversation

@CedaryCat

@CedaryCat CedaryCat commented Mar 16, 2026

Copy link
Copy Markdown
Owner

Summary by Sourcery

Update documentation metadata generation to derive the Terraria version from restored OTAPI assets and keep version matrices in sync with the actual dependencies.

Enhancements:

  • Extend the docs metadata sync script to read project restore assets and resolve the OTAPI assembly version used by the project.
  • Improve the docs sync script error messaging when metadata is out of sync.

CI:

  • Adjust the build workflow to restore .NET dependencies before running the docs metadata sync check, ensuring required assets are available.

Documentation:

  • Refresh the English and Chinese README version matrices with the current Terraria and OTAPI USP versions and clarify that Terraria version is sourced from restored OTAPI assets.

@sourcery-ai

sourcery-ai Bot commented Mar 16, 2026

Copy link
Copy Markdown

Reviewer's Guide

This PR enhances the docs metadata sync script to derive the Terraria version dynamically from restored NuGet assets (OTAPI.dll), wires in an explicit restore step in CI before running the sync check, and updates the English/Chinese READMEs and project metadata to reflect the new Terraria/OTAPI USP versions and wording clarifications.

Class diagram for updated sync-doc-metadata PowerShell module

classDiagram
    class SyncDocMetadataScript {
        +GetProjectXml(path)
        +GetPackageVersion(projectXml, packageId)
        +GetRestoreAssets(path, projectPath)
        +ConvertNuGetRelativePath(path)
        +GetRestoredPackageLibrary(assets, packageId)
        +GetRestoredTargetPackageEntry(assets, targetFramework, packageLibraryName)
        +ResolveRestoredPackageAssetPath(assets, targetFramework, packageId, assetFileName, projectPath)
        +GetAssemblyFileVersion(path)
        +GetTerrariaVersionFromRestoreAssets(assets, targetFramework, projectPath)
        +ConvertTargetFrameworkDisplay(targetFramework)
        +BuildEnglishVersionBlock(metadata)
        +BuildChineseVersionBlock(metadata)
        +SyncMarkedBlock(path, newBlock, mode)
    }

    class RestoreAssetsJson {
        +libraries
        +targets
        +packageFolders
    }

    class DotNetRuntimeTypes {
        <<static>> System_IO_Path
        <<static>> System_Diagnostics_FileVersionInfo
        <<static>> regex
    }

    SyncDocMetadataScript --> RestoreAssetsJson : uses
    SyncDocMetadataScript ..> DotNetRuntimeTypes : calls

    SyncDocMetadataScript ..> SyncDocMetadataScript : internal calls
    SyncDocMetadataScript ..> GetRestoreAssets : main script uses
    SyncDocMetadataScript ..> GetTerrariaVersionFromRestoreAssets : main script uses
    SyncDocMetadataScript ..> GetPackageVersion : main script uses

    GetTerrariaVersionFromRestoreAssets --> ResolveRestoredPackageAssetPath
    ResolveRestoredPackageAssetPath --> GetRestoredPackageLibrary
    ResolveRestoredPackageAssetPath --> GetRestoredTargetPackageEntry
    ResolveRestoredPackageAssetPath --> ConvertNuGetRelativePath
    GetAssemblyFileVersion --> DotNetRuntimeTypes

    SyncDocMetadataScript ..> BuildEnglishVersionBlock : uses metadata.TerrariaVersion
    SyncDocMetadataScript ..> BuildChineseVersionBlock : uses metadata.TerrariaVersion
Loading

Flow diagram for CI build job with restored docs metadata sync order

flowchart TD
    A[Checkout repository] --> B[Setup .NET using actions.setup-dotnet]
    B --> C[Restore dependencies with dotnet restore PROJECT_PATH]
    C --> D[Run sync-doc-metadata.ps1 -Mode check]
    D --> E[Install GitVersion]
    E --> F[Determine version via GitVersion]
    F --> G[Build Publisher with dotnet build --no-restore]

    subgraph GitHubActionsBuildJob
        A
        B
        C
        D
        E
        F
        G
    end
Loading

File-Level Changes

Change Details Files
Derive Terraria version from restored NuGet assets instead of hardcoded helper logic.
  • Add helper to load project.assets.json and throw if restore has not been run for the UnifierTSL project.
  • Add utilities to resolve NuGet package library entries and target framework-specific runtime assets from the restore assets graph.
  • Resolve OTAPI.USP’s OTAPI.dll path via project.assets.json and read its file version using FileVersionInfo.
  • Expose TerrariaVersion in the metadata map used by the sync script, and use it when rendering the version matrix blocks.
  • Improve error messages around missing restore assets and out-of-sync metadata, guiding users to run restore or rerun the sync script in apply mode.
tools/sync-doc-metadata.ps1
Adjust CI workflow ordering to restore dependencies before running the docs metadata sync check.
  • Insert an explicit dotnet restore step immediately after setting up .NET in the build workflow.
  • Run the docs metadata sync script after restore so it can read project.assets.json.
  • Remove the previous restore step later in the workflow to avoid redundant restores.
.github/workflows/build.yaml
Update documentation version matrix and wording to match the new dynamic Terraria version source and bumped OTAPI USP version.
  • Update English README version matrix to show Terraria 1.4.5.6 and OTAPI USP 1.1.0-pre-release-upstream.30, and clarify that the Terraria version comes from restored OTAPI.dll resolved via project.assets.json.
  • Update Chinese README version matrix with matching Terraria and OTAPI USP versions and equivalent wording about using restored package assets.
  • Normalize README top-of-file whitespace/newline formatting.
README.md
docs/README.zh-cn.md
Align project metadata with the updated OTAPI USP dependency version.
  • Bump the OTAPI.USP package reference version in the UnifierTSL project file to match the version shown in the docs.
src/UnifierTSL/UnifierTSL.csproj

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@CedaryCat
CedaryCat merged commit f3e7598 into main Mar 16, 2026
13 checks passed

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • In Resolve-RestoredPackageAssetPath, consider explicitly validating that $targetPackage.runtime exists before enumerating its properties to avoid a null-member access if a target has no runtime section.
  • The hardcoded package/asset identifiers ('OTAPI.USP', 'OTAPI.dll', and the restore assets path) are used in multiple places; centralizing them as variables/constants at the top of the script would make future changes less error-prone.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `Resolve-RestoredPackageAssetPath`, consider explicitly validating that `$targetPackage.runtime` exists before enumerating its properties to avoid a null-member access if a target has no `runtime` section.
- The hardcoded package/asset identifiers (`'OTAPI.USP'`, `'OTAPI.dll'`, and the restore assets path) are used in multiple places; centralizing them as variables/constants at the top of the script would make future changes less error-prone.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

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.

1 participant