Add comprehensive tests for nextLink properties with string types #7853
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR addresses the issue where nextLink properties can be strings rather than just URLs by adding comprehensive tests to verify the existing behavior works correctly.
Investigation Summary
During investigation of issue #6778, I discovered that the TypeSpec C# generator already correctly handles nextLink properties that are defined as strings:
InputPrimitiveType.String
→public string NextCat { get; }
InputPrimitiveType.Url
→public global::System.Uri NextCat { get; }
Changes Made
Added Tests
NextLinkWithStringType
: Verifies that nextLink properties defined asInputPrimitiveType.String
generate correct string propertiesNextLinkStringVsUrlComparison
: Compares behavior between URL and String nextLink properties side-by-sideTest Results
Both tests demonstrate that the type system correctly:
InputPrimitiveType.String
tostring
propertiesInputPrimitiveType.Url
toUri
propertiesAll existing NextLink tests continue to pass (12/12).
Example Generated Code
String nextLink property:
URL nextLink property:
Conclusion
The existing codebase already correctly handles the requirement that "nextLink properties can be strings." No code changes to the generator were needed - only additional test coverage to verify and document this capability.
Fixes #6778.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
aka.ms
curl -I -sSL --retry 5 --retry-delay 2 --connect-timeout 15 REDACTED
(dns block)esm.ubuntu.com
/usr/lib/apt/methods/https
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.