refactor: unify range-indexer style across netstandard2.0 surface - #88
Conversation
Link Index/Range polyfills into AotReflection (mirror IsExternalInit pattern) and convert all remaining Substring(start, length) call sites to range-indexer syntax — twelve sites across StringExtensions, SyntaxExtensions, SemconvVersion, ShortId, BearerHeader, GenerationHelpers, and MarkdownText. Both netstandard2.0 projects in the repo now resolve System.Index / System.Range, so range-indexer is uniformly available and ReSharper suggests it consistently. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (8)
📜 Recent review details⏰ Context from checks skipped due to timeout of 120000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
🧰 Additional context used📓 Path-based instructions (1)src/**/*.cs⚙️ CodeRabbit configuration file
Files:
🔇 Additional comments (8)
Summary by CodeRabbitRelease Notes
WalkthroughThe PR systematically replaces ChangesString Slicing Modernization
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes 🚥 Pre-merge checks | ✅ 8✅ Passed checks (8 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Review rate limit: 4/5 reviews remaining, refill in 12 minutes. Comment |
There was a problem hiding this comment.
Pull request overview
Refactors string-slicing code to consistently use C# range/index syntax across the netstandard2.0-targeting surfaces, and ensures the AOT reflection analyzer project has the same Index/Range polyfill substrate to keep analyzer/style behavior consistent across projects.
Changes:
- Link
System.Index/System.Rangepolyfill sources intoANcpLua.Analyzers.AotReflection.csproj(matching the existing linked-polyfill pattern). - Replace remaining
Substring(start, length)usages with range slicing ([..],[..^1],[start..i], etc.) across utilities and AOT reflection generation helpers.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/ANcpLua.Roslyn.Utilities/Text/MarkdownText.cs | Uses range slicing for markdown cell truncation instead of Substring. |
| src/ANcpLua.Roslyn.Utilities/SyntaxExtensions.cs | Uses range slicing for generic-argument parsing and extraction. |
| src/ANcpLua.Roslyn.Utilities/StringExtensions.cs | Uses range slicing for nullable unwrap and hash truncation paths. |
| src/ANcpLua.Roslyn.Utilities/OTel/SemconvVersion.cs | Uses range slicing when stripping the semconv- prefix prior to splitting. |
| src/ANcpLua.Roslyn.Utilities/Ids/ShortId.cs | Uses range slicing when truncating generated hex strings. |
| src/ANcpLua.Roslyn.Utilities/Http/BearerHeader.cs | Uses range slicing when stripping the Bearer scheme prefix. |
| src/ANcpLua.AotReflection/Generation/GenerationHelpers.cs | Uses range slicing to split namespace/type name and strip global::. |
| src/ANcpLua.AotReflection/ANcpLua.Analyzers.AotReflection.csproj | Links Index/Range polyfill sources so range/index syntax is uniformly supported in this netstandard2.0 project. |
Summary
Index.cs/Range.cspolyfills intoANcpLua.Analyzers.AotReflection.csproj, mirroring the existingIsExternalInit.cslink pattern.Substring(start, length)sites to range-indexer syntax (text[..n],text[n..^1],text[start..i], etc.) acrossStringExtensions,SyntaxExtensions,SemconvVersion,ShortId,BearerHeader,GenerationHelpers, andMarkdownText.Why
Both netstandard2.0 projects in the repo (
ANcpLua.Roslyn.UtilitiesandANcpLua.AotReflection) now resolveSystem.Index/System.Rangefrom the same internal polyfill substrate. ReSharper's "Use range indexer" suggestion now fires uniformly across both projects — the prior asymmetry (MarkdownTextmodernized,GenerationHelpersnot) was caused solely byAotReflection.csprojnot linking the IndexRange polyfills, not by any analyzer being disabled. Pattern matches the polyfill-per-project convention used by Microsoft.Bcl.* and PolySharp.Test plan
dotnet build -c Release— 0 warnings, 0 errors🤖 Generated with Claude Code