-
Notifications
You must be signed in to change notification settings - Fork 338
Bump C# emitter dependencies to TypeSpec 1.9.0 #9675
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
JoshLove-msft
merged 12 commits into
main
from
copilot/bump-csharp-emitter-dependencies
Feb 14, 2026
+59,111
−3,201
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d5f9e6d
Initial plan
Copilot d12ddc8
Bump C# emitter dependencies to TypeSpec 1.9.0
Copilot 7d75552
Fix enum array encoding issue for TypeSpec 1.9.0 compatibility
Copilot ac66f06
Bump TCGC to 0.65.1 and regenerate test projects
Copilot b9915cb
Merge branch 'main' into copilot/bump-csharp-emitter-dependencies
Copilot db0d1e3
Convert DateTimeKnownEncoding and DurationKnownEncoding to extensible…
Copilot 88ce1b4
Make encoding comparison case-insensitive and regenerate test libraries
Copilot 65ab7a5
Use InvariantCultureIgnoreCase for extensible enum comparison
Copilot dfa05eb
skip file
JoshLove-msft ec349b1
Merge branch 'main' of https://github.com/microsoft/typespec into cop…
JoshLove-msft 780b92f
regen
JoshLove-msft 8de9466
fix enum array
JoshLove-msft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 0 additions & 24 deletions
24
...ator/Microsoft.TypeSpec.Generator.Input/src/Extensions/DurationKnownEncodingExtensions.cs
This file was deleted.
Oops, something went wrong.
64 changes: 62 additions & 2 deletions
64
...harp/generator/Microsoft.TypeSpec.Generator.Input/src/InputTypes/DateTimeKnownEncoding.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,70 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System; | ||
| using System.ComponentModel; | ||
|
|
||
| namespace Microsoft.TypeSpec.Generator.Input | ||
| { | ||
| public enum DateTimeKnownEncoding | ||
| /// <summary> | ||
| /// Represents a DateTime encoding format. | ||
| /// </summary> | ||
| public readonly struct DateTimeKnownEncoding : IEquatable<DateTimeKnownEncoding> | ||
| { | ||
| Rfc3339, Rfc7231, UnixTimestamp | ||
| private readonly string _value; | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of <see cref="DateTimeKnownEncoding"/>. | ||
| /// </summary> | ||
| /// <param name="value">The string value of the encoding.</param> | ||
| /// <exception cref="ArgumentNullException"><paramref name="value"/> is null.</exception> | ||
| public DateTimeKnownEncoding(string value) | ||
| { | ||
| _value = value ?? throw new ArgumentNullException(nameof(value)); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// RFC 3339 date-time format (ISO 8601). | ||
| /// </summary> | ||
| public static DateTimeKnownEncoding Rfc3339 { get; } = new DateTimeKnownEncoding("Rfc3339"); | ||
|
|
||
| /// <summary> | ||
| /// RFC 7231 HTTP date format. | ||
| /// </summary> | ||
| public static DateTimeKnownEncoding Rfc7231 { get; } = new DateTimeKnownEncoding("Rfc7231"); | ||
|
|
||
| /// <summary> | ||
| /// Unix timestamp (seconds since epoch). | ||
| /// </summary> | ||
| public static DateTimeKnownEncoding UnixTimestamp { get; } = new DateTimeKnownEncoding("UnixTimestamp"); | ||
|
|
||
| /// <summary> | ||
| /// Determines if two <see cref="DateTimeKnownEncoding"/> values are the same. | ||
| /// </summary> | ||
| public static bool operator ==(DateTimeKnownEncoding left, DateTimeKnownEncoding right) => left.Equals(right); | ||
|
|
||
| /// <summary> | ||
| /// Determines if two <see cref="DateTimeKnownEncoding"/> values are not the same. | ||
| /// </summary> | ||
| public static bool operator !=(DateTimeKnownEncoding left, DateTimeKnownEncoding right) => !left.Equals(right); | ||
|
|
||
| /// <summary> | ||
| /// Converts a string to a <see cref="DateTimeKnownEncoding"/>. | ||
| /// </summary> | ||
| public static implicit operator DateTimeKnownEncoding(string value) => new DateTimeKnownEncoding(value); | ||
|
|
||
| /// <inheritdoc/> | ||
| [EditorBrowsable(EditorBrowsableState.Never)] | ||
| public override bool Equals(object? obj) => obj is DateTimeKnownEncoding other && Equals(other); | ||
|
|
||
| /// <inheritdoc/> | ||
| public bool Equals(DateTimeKnownEncoding other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); | ||
|
|
||
| /// <inheritdoc/> | ||
| [EditorBrowsable(EditorBrowsableState.Never)] | ||
| public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; | ||
|
|
||
| /// <inheritdoc/> | ||
| public override string ToString() => _value; | ||
| } | ||
| } |
69 changes: 67 additions & 2 deletions
69
...harp/generator/Microsoft.TypeSpec.Generator.Input/src/InputTypes/DurationKnownEncoding.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,75 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System; | ||
| using System.ComponentModel; | ||
|
|
||
| namespace Microsoft.TypeSpec.Generator.Input | ||
| { | ||
| public enum DurationKnownEncoding | ||
| /// <summary> | ||
| /// Represents a Duration encoding format. | ||
| /// </summary> | ||
| public readonly struct DurationKnownEncoding : IEquatable<DurationKnownEncoding> | ||
| { | ||
| Iso8601, Seconds, Constant, Milliseconds | ||
| private readonly string _value; | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of <see cref="DurationKnownEncoding"/>. | ||
| /// </summary> | ||
| /// <param name="value">The string value of the encoding.</param> | ||
| /// <exception cref="ArgumentNullException"><paramref name="value"/> is null.</exception> | ||
| public DurationKnownEncoding(string value) | ||
| { | ||
| _value = value ?? throw new ArgumentNullException(nameof(value)); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// ISO 8601 duration format. | ||
| /// </summary> | ||
| public static DurationKnownEncoding Iso8601 { get; } = new DurationKnownEncoding("Iso8601"); | ||
|
|
||
| /// <summary> | ||
| /// Duration as seconds. | ||
| /// </summary> | ||
| public static DurationKnownEncoding Seconds { get; } = new DurationKnownEncoding("Seconds"); | ||
|
|
||
| /// <summary> | ||
| /// Constant duration value. | ||
| /// </summary> | ||
| public static DurationKnownEncoding Constant { get; } = new DurationKnownEncoding("Constant"); | ||
|
|
||
| /// <summary> | ||
| /// Duration as milliseconds. | ||
| /// </summary> | ||
| public static DurationKnownEncoding Milliseconds { get; } = new DurationKnownEncoding("Milliseconds"); | ||
|
|
||
| /// <summary> | ||
| /// Determines if two <see cref="DurationKnownEncoding"/> values are the same. | ||
| /// </summary> | ||
| public static bool operator ==(DurationKnownEncoding left, DurationKnownEncoding right) => left.Equals(right); | ||
|
|
||
| /// <summary> | ||
| /// Determines if two <see cref="DurationKnownEncoding"/> values are not the same. | ||
| /// </summary> | ||
| public static bool operator !=(DurationKnownEncoding left, DurationKnownEncoding right) => !left.Equals(right); | ||
|
|
||
| /// <summary> | ||
| /// Converts a string to a <see cref="DurationKnownEncoding"/>. | ||
| /// </summary> | ||
| public static implicit operator DurationKnownEncoding(string value) => new DurationKnownEncoding(value); | ||
|
|
||
| /// <inheritdoc/> | ||
| [EditorBrowsable(EditorBrowsableState.Never)] | ||
| public override bool Equals(object? obj) => obj is DurationKnownEncoding other && Equals(other); | ||
|
|
||
| /// <inheritdoc/> | ||
| public bool Equals(DurationKnownEncoding other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); | ||
|
|
||
| /// <inheritdoc/> | ||
| [EditorBrowsable(EditorBrowsableState.Never)] | ||
| public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; | ||
|
|
||
| /// <inheritdoc/> | ||
| public override string ToString() => _value; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 24 additions & 13 deletions
37
...nt-csharp/generator/Microsoft.TypeSpec.Generator.Input/test/DurationKnownEncodingTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,41 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using Microsoft.TypeSpec.Generator.Input.Extensions; | ||
| using NUnit.Framework; | ||
|
|
||
| namespace Microsoft.TypeSpec.Generator.Input.Tests | ||
| { | ||
| public class DurationKnownEncodingTests | ||
| { | ||
| [TestCase("duration-constant", DurationKnownEncoding.Constant)] | ||
| [TestCase("iso8601", DurationKnownEncoding.Iso8601)] | ||
| [TestCase("seconds", DurationKnownEncoding.Seconds)] | ||
| [TestCase("milliseconds", DurationKnownEncoding.Milliseconds)] | ||
| public void TryParseEachEncoding(string encoding, DurationKnownEncoding expectedEncoding) | ||
| [TestCase("duration-constant")] | ||
| [TestCase("Constant")] | ||
| [TestCase("iso8601")] | ||
| [TestCase("Iso8601")] | ||
| [TestCase("seconds")] | ||
| [TestCase("Seconds")] | ||
| [TestCase("milliseconds")] | ||
| [TestCase("Milliseconds")] | ||
| public void CanCreateFromString(string encoding) | ||
| { | ||
| var result = DurationKnownEncodingExtensions.TryParse(encoding, out var parsedEncoding); | ||
| Assert.IsTrue(result); | ||
| Assert.AreEqual(expectedEncoding, parsedEncoding); | ||
| var parsedEncoding = new DurationKnownEncoding(encoding); | ||
| Assert.IsNotNull(parsedEncoding); | ||
| Assert.AreEqual(encoding, parsedEncoding.ToString()); | ||
| } | ||
|
|
||
| [Test] | ||
| public void TryParseInvalidEncoding() | ||
| public void KnownEncodingsAreEqual() | ||
| { | ||
| var result = DurationKnownEncodingExtensions.TryParse("invalid-encoding", out var parsedEncoding); | ||
| Assert.IsFalse(result); | ||
| Assert.IsNull(parsedEncoding); | ||
| Assert.AreEqual(DurationKnownEncoding.Iso8601, new DurationKnownEncoding("Iso8601")); | ||
| Assert.AreEqual(DurationKnownEncoding.Seconds, new DurationKnownEncoding("Seconds")); | ||
| Assert.AreEqual(DurationKnownEncoding.Constant, new DurationKnownEncoding("Constant")); | ||
| Assert.AreEqual(DurationKnownEncoding.Milliseconds, new DurationKnownEncoding("Milliseconds")); | ||
| } | ||
|
|
||
| [Test] | ||
| public void CustomEncodingWorks() | ||
| { | ||
| var customEncoding = new DurationKnownEncoding("custom-format"); | ||
| Assert.AreEqual("custom-format", customEncoding.ToString()); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.