Skip to content

Testing#22

Merged
keyz182 merged 20 commits intomainfrom
testing
Mar 21, 2026
Merged

Testing#22
keyz182 merged 20 commits intomainfrom
testing

Conversation

@keyz182
Copy link
Copy Markdown
Owner

@keyz182 keyz182 commented Mar 21, 2026

Testing some cleanup and refactoring

keyz182 added 18 commits March 21, 2026 10:34
base.ShouldSkip returning true (pawn ineligible) was short-circuiting
only when the RHS was also true. Using && meant ineligible pawns could
still receive haul-urgently jobs when the feature was enabled and
designations existed. The correct predicate is skip if base says skip
OR if there is nothing to do.
The searchPool rotation was fully computed (TakeRandom, RemoveAll) but
the return statement ignored it and re-queried all designations, making
the rotation dead code. Also materialized thingsOut to a HashSet so
RemoveAll is O(n) instead of O(n*m) via lazy IEnumerable re-evaluation.
RemoveAllDesignationsOfDef(Haul) removed every haul designation on the
entire map. Replace with TryRemoveDesignationOn(__instance, ...) which
removes only the designation on the clicked thing and is a safe no-op
if none exists.
defs.Contains() inside a Where predicate re-enumerated the entire
deferred IEnumerable chain on every element probe. Materializing to a
HashSet (or reusing it if the caller already passed an IReadOnlySet)
reduces each lookup to O(1).
All four Designate* methods were passing a deferred Select().Distinct()
chain to OfDefs, which would be re-evaluated for every element in the
list. Materializing to ToHashSet() at the call site makes intent
explicit and ensures the set is computed exactly once per call.
!IsFullyGrown caused the tool to accept immature plants, directly
contradicting the CutGrown name and label. Removing the negation makes
the designator correctly accept only fully-grown plants.
…pat)

IReadOnlySet<T> is .NET 5+ only and does not exist in .NET Framework 4.8.
HashSet<Def> preserves the same cast-or-materialise optimisation.
…stale tests

3-1 FilterUtils.MakeFilter: replace Aggregate nested closures with ToList()+Any(),
    eliminating O(n)-deep stack growth on large selections.

3-2 JobDriver_StripFinishOff.DoExecution: move BodiesStripped increment to after
    base.DoExecution so the record reflects an actual body, not a living pawn.

3-3 Designator_SelectSimilar: rename `filter` field to `filterIgnoreStuff` to match
    the semantics of the stuff-ignoring cache slot (declaration, ref assignment, reset).

3-4 FilterUtilsTest: add missing KeyzAllowUtilities.Tests.csproj and rewrite both
    NotFogged tests to call the real extension-method API — the old static
    (IntVec3, Map) signature never existed, preventing the project from compiling.
…s, null guards, private readonly

- 4-1: Replace static seenThings HashSet with local var in RenderHighlight
        (Designator_HaulUrgently, Designator_FinishOff) — eliminates leak on exception
- 4-2: Delete 3 unused const fields from JobDriver_StripFinishOff and JobDriver_FinishOff
- 4-3: Delete 2 dead Lazy<FieldInfo/MethodInfo> fields from DesignationCategoryDef_Patch
- 4-4: Delete self-referential dead Lazy<FieldInfo> property from Designator_HarvestGrown
- 4-5: Replace magic strings in WorkGiver_FinishOff.JobOnThing with .Translate() calls;
        add KAU_NotAPawn and KAU_NotFriendlyOrDowned to English keyed XML
- 4-6: Standardise null guards in Toils_Haul_Patch.PlaceHauledThingInCell and
        PlaceCarriedThingInCellFacing to match DepositHauledThingInContainer baseline
- 4-7: FilterUtils._GetMapRect → private static readonly _getMapRect; GetMapRect → private
DesignateAnyOnScreen and DesignateAnyOnMap were called without
checkIfHarvestable=false in the non-tree Harvest All action. The
default (true) caused the HarvestableNow guard to filter out every
immature crop, making the gizmo designate nothing. Pass false
explicitly, matching the tree Harvest All Wood variant.
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
3.5% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 21, 2026

Qodana for .NET

50 new problems were found

Inspection name Severity Problems
Redundant using directive 🔶 Warning 7
The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. 🔶 Warning 1
RoslynAnalyzers Non-constant fields should not be visible ◽️ Notice 19
Invert 'if' statement to reduce nesting ◽️ Notice 7
Remove redundant parentheses ◽️ Notice 4
RoslynAnalyzers Mark members as static ◽️ Notice 2
'if-return' statement can be rewritten as 'return' statement ◽️ Notice 2
Append to collection expression ◽️ Notice 1
Use preferred namespace body style ◽️ Notice 1
Duplicated sequential 'if' branches ◽️ Notice 1
Extract common code ◽️ Notice 1
Inline temporary variable ◽️ Notice 1
Convert static method invocation into extension member call (convert qualified static method invocation into extension member call) ◽️ Notice 1
Struct can be made readonly ◽️ Notice 1
Use collection expression syntax ◽️ Notice 1

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Detected 4 dependencies

Third-party software list

This page lists the third-party software dependencies used in KeyzAllowUtilities

Dependency Version Licenses
Lib.Harmony 2.4.2 MIT
Microsoft.NETFramework.ReferenceAssemblies.net48 1.0.3 MIT
Microsoft.NETFramework.ReferenceAssemblies 1.0.3 MIT
System.Data.DataSetExtensions 4.5.0 MIT
Contact Qodana team

Contact us at qodana-support@jetbrains.com

keyz182 added 2 commits March 21, 2026 13:42
The test project (and main library) previously targeted net48 only.
On macOS, dotnet test hangs indefinitely trying to execute the resulting
Windows PE32 binary — net48 requires Mono or Windows to run.

Fix by adding net8.0 as a second target framework:
- KeyzAllowUtilities.csproj: net48;net8.0, game DLL refs gated to net48,
  net8.0 uses macOS game DLLs (Private=False), net8.0 output redirected
  to bin/$(Configuration)/net8.0/ so Assemblies/ stays net48-only
- KeyzAllowUtilities.Tests.csproj: net48;net8.0, game DLL refs gated to
  net48, net8.0 copies macOS game DLLs to test output (Private=True)

Run tests: dotnet test 1.6/Source/KeyzAllowUtilities.Tests/KeyzAllowUtilities.Tests.csproj --framework net8.0
@keyz182 keyz182 marked this pull request as ready for review March 21, 2026 13:52
@keyz182 keyz182 merged commit 1d408b6 into main Mar 21, 2026
1 check passed
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