-
Notifications
You must be signed in to change notification settings - Fork 167
feat: support single quote digits separator #639
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
tannergooding
merged 5 commits into
dotnet:main
from
davidelettieri:feat/support-digits-separator
Oct 16, 2025
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
58eadbc
feat: add support for single quote digits separator
davidelettieri 85d84aa
fix: add copyright header to new files
davidelettieri 7c0262c
review: use string.Replace instead of for loop
davidelettieri f83e21e
Revert "review: use string.Replace instead of for loop"
davidelettieri db2c90e
review: use loop/slice
davidelettieri 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
17 changes: 17 additions & 0 deletions
17
tests/ClangSharp.PInvokeGenerator.UnitTests/Base/DigitsSeparatorTest.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 |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| // Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. | ||
|
|
||
| using System.Threading.Tasks; | ||
| using NUnit.Framework; | ||
|
|
||
| namespace ClangSharp.UnitTests; | ||
|
|
||
| public abstract class DigitsSeparatorTest : PInvokeGeneratorTest | ||
| { | ||
| [TestCase("int", "1'024", "1_024")] | ||
| [TestCase("int", "1'000'001", "1_000_001")] | ||
| [TestCase("float", "1'024", "1_024")] | ||
| [TestCase("float", "1'024.0", "1_024.0")] | ||
| public Task StaticConstExprTest(string type, string nativeValue, string expectedValue) => StaticConstExprTestImpl(type, nativeValue, expectedValue); | ||
|
|
||
| protected abstract Task StaticConstExprTestImpl(string type, string nativeValue, string expectedValue); | ||
| } |
35 changes: 35 additions & 0 deletions
35
tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/DigitsSeparatorTest.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 |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. | ||
|
|
||
| using System.Threading.Tasks; | ||
| using NUnit.Framework; | ||
|
|
||
| namespace ClangSharp.UnitTests.CSharpCompatibleUnix; | ||
|
|
||
| [Platform("unix")] | ||
| public sealed class DigitsSeparatorTest : UnitTests.DigitsSeparatorTest | ||
| { | ||
| protected override Task StaticConstExprTestImpl(string type, string nativeValue, string expectedValue) | ||
| { | ||
| var inputContents = $@"class MyClass | ||
| {{ | ||
| private: | ||
|
|
||
| static constexpr {type} x = {nativeValue}; | ||
| }}; | ||
| "; | ||
|
|
||
| var expectedOutputContents = $@"namespace ClangSharp.Test | ||
| {{ | ||
| public partial struct MyClass | ||
| {{ | ||
| [NativeTypeName(""const {type}"")] | ||
| private const {type} x = {expectedValue}; | ||
| }} | ||
| }} | ||
| "; | ||
|
|
||
| return ValidateGeneratedCSharpCompatibleUnixBindingsAsync( | ||
| inputContents, | ||
| expectedOutputContents); | ||
| } | ||
| } |
35 changes: 35 additions & 0 deletions
35
tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/DigitsSeparatorTest.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 |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. | ||
|
|
||
| using System.Threading.Tasks; | ||
| using NUnit.Framework; | ||
|
|
||
| namespace ClangSharp.UnitTests.CSharpCompatibleWindows; | ||
|
|
||
| [Platform("win")] | ||
| public sealed class DigitsSeparatorTest : UnitTests.DigitsSeparatorTest | ||
| { | ||
| protected override Task StaticConstExprTestImpl(string type, string nativeValue, string expectedValue) | ||
| { | ||
| var inputContents = $@"class MyClass | ||
| {{ | ||
| private: | ||
|
|
||
| static constexpr {type} x = {nativeValue}; | ||
| }}; | ||
| "; | ||
|
|
||
| var expectedOutputContents = $@"namespace ClangSharp.Test | ||
| {{ | ||
| public partial struct MyClass | ||
| {{ | ||
| [NativeTypeName(""const {type}"")] | ||
| private const {type} x = {expectedValue}; | ||
| }} | ||
| }} | ||
| "; | ||
|
|
||
| return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync( | ||
| inputContents, | ||
| expectedOutputContents); | ||
| } | ||
| } |
35 changes: 35 additions & 0 deletions
35
tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/DigitsSeparatorTest.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 |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. | ||
|
|
||
| using System.Threading.Tasks; | ||
| using NUnit.Framework; | ||
|
|
||
| namespace ClangSharp.UnitTests.CSharpDefaultUnix; | ||
|
|
||
| [Platform("unix")] | ||
| public sealed class DigitsSeparatorTest : UnitTests.DigitsSeparatorTest | ||
| { | ||
| protected override Task StaticConstExprTestImpl(string type, string nativeValue, string expectedValue) | ||
| { | ||
| var inputContents = $@"class MyClass | ||
| {{ | ||
| private: | ||
|
|
||
| static constexpr {type} x = {nativeValue}; | ||
| }}; | ||
| "; | ||
|
|
||
| var expectedOutputContents = $@"namespace ClangSharp.Test | ||
| {{ | ||
| public partial struct MyClass | ||
| {{ | ||
| [NativeTypeName(""const {type}"")] | ||
| private const {type} x = {expectedValue}; | ||
| }} | ||
| }} | ||
| "; | ||
|
|
||
| return ValidateGeneratedCSharpDefaultUnixBindingsAsync( | ||
| inputContents, | ||
| expectedOutputContents); | ||
| } | ||
| } |
35 changes: 35 additions & 0 deletions
35
tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/DigitsSeparatorTest.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 |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. | ||
|
|
||
| using System.Threading.Tasks; | ||
| using NUnit.Framework; | ||
|
|
||
| namespace ClangSharp.UnitTests.CSharpDefaultWindows; | ||
|
|
||
| [Platform("win")] | ||
| public sealed class DigitsSeparatorTest : UnitTests.DigitsSeparatorTest | ||
| { | ||
| protected override Task StaticConstExprTestImpl(string type, string nativeValue, string expectedValue) | ||
| { | ||
| var inputContents = $@"class MyClass | ||
| {{ | ||
| private: | ||
|
|
||
| static constexpr {type} x = {nativeValue}; | ||
| }}; | ||
| "; | ||
|
|
||
| var expectedOutputContents = $@"namespace ClangSharp.Test | ||
| {{ | ||
| public partial struct MyClass | ||
| {{ | ||
| [NativeTypeName(""const {type}"")] | ||
| private const {type} x = {expectedValue}; | ||
| }} | ||
| }} | ||
| "; | ||
|
|
||
| return ValidateGeneratedCSharpDefaultWindowsBindingsAsync( | ||
| inputContents, | ||
| expectedOutputContents); | ||
| } | ||
| } |
35 changes: 35 additions & 0 deletions
35
tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/DigitsSeparatorTest.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 |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. | ||
|
|
||
| using System.Threading.Tasks; | ||
| using NUnit.Framework; | ||
|
|
||
| namespace ClangSharp.UnitTests.CSharpLatestUnix; | ||
|
|
||
| [Platform("unix")] | ||
| public sealed class DigitsSeparatorTest : UnitTests.DigitsSeparatorTest | ||
| { | ||
| protected override Task StaticConstExprTestImpl(string type, string nativeValue, string expectedValue) | ||
| { | ||
| var inputContents = $@"class MyClass | ||
| {{ | ||
| private: | ||
|
|
||
| static constexpr {type} x = {nativeValue}; | ||
| }}; | ||
| "; | ||
|
|
||
| var expectedOutputContents = $@"namespace ClangSharp.Test | ||
| {{ | ||
| public partial struct MyClass | ||
| {{ | ||
| [NativeTypeName(""const {type}"")] | ||
| private const {type} x = {expectedValue}; | ||
| }} | ||
| }} | ||
| "; | ||
|
|
||
| return ValidateGeneratedCSharpLatestUnixBindingsAsync( | ||
| inputContents, | ||
| expectedOutputContents); | ||
| } | ||
| } |
35 changes: 35 additions & 0 deletions
35
tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/DigitsSeparatorTest.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 |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. | ||
|
|
||
| using System.Threading.Tasks; | ||
| using NUnit.Framework; | ||
|
|
||
| namespace ClangSharp.UnitTests.CSharpLatestWindows; | ||
|
|
||
| [Platform("win")] | ||
| public sealed class DigitsSeparatorTest : UnitTests.DigitsSeparatorTest | ||
| { | ||
| protected override Task StaticConstExprTestImpl(string type, string nativeValue, string expectedValue) | ||
| { | ||
| var inputContents = $@"class MyClass | ||
| {{ | ||
| private: | ||
|
|
||
| static constexpr {type} x = {nativeValue}; | ||
| }}; | ||
| "; | ||
|
|
||
| var expectedOutputContents = $@"namespace ClangSharp.Test | ||
| {{ | ||
| public partial struct MyClass | ||
| {{ | ||
| [NativeTypeName(""const {type}"")] | ||
| private const {type} x = {expectedValue}; | ||
| }} | ||
| }} | ||
| "; | ||
|
|
||
| return ValidateGeneratedCSharpLatestWindowsBindingsAsync( | ||
| inputContents, | ||
| expectedOutputContents); | ||
| } | ||
| } |
35 changes: 35 additions & 0 deletions
35
tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/DigitsSeparatorTest.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 |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. | ||
|
|
||
| using System.Threading.Tasks; | ||
| using NUnit.Framework; | ||
|
|
||
| namespace ClangSharp.UnitTests.CSharpPreviewUnix; | ||
|
|
||
| [Platform("unix")] | ||
| public sealed class DigitsSeparatorTest : UnitTests.DigitsSeparatorTest | ||
| { | ||
| protected override Task StaticConstExprTestImpl(string type, string nativeValue, string expectedValue) | ||
| { | ||
| var inputContents = $@"class MyClass | ||
| {{ | ||
| private: | ||
|
|
||
| static constexpr {type} x = {nativeValue}; | ||
| }}; | ||
| "; | ||
|
|
||
| var expectedOutputContents = $@"namespace ClangSharp.Test | ||
| {{ | ||
| public partial struct MyClass | ||
| {{ | ||
| [NativeTypeName(""const {type}"")] | ||
| private const {type} x = {expectedValue}; | ||
| }} | ||
| }} | ||
| "; | ||
|
|
||
| return ValidateGeneratedCSharpPreviewUnixBindingsAsync( | ||
| inputContents, | ||
| expectedOutputContents); | ||
| } | ||
| } |
35 changes: 35 additions & 0 deletions
35
tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/DigitsSeparatorTest.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 |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. | ||
|
|
||
| using System.Threading.Tasks; | ||
| using NUnit.Framework; | ||
|
|
||
| namespace ClangSharp.UnitTests.CSharpPreviewWindows; | ||
|
|
||
| [Platform("win")] | ||
| public sealed class DigitsSeparatorTest : UnitTests.DigitsSeparatorTest | ||
| { | ||
| protected override Task StaticConstExprTestImpl(string type, string nativeValue, string expectedValue) | ||
| { | ||
| var inputContents = $@"class MyClass | ||
| {{ | ||
| private: | ||
|
|
||
| static constexpr {type} x = {nativeValue}; | ||
| }}; | ||
| "; | ||
|
|
||
| var expectedOutputContents = $@"namespace ClangSharp.Test | ||
| {{ | ||
| public partial struct MyClass | ||
| {{ | ||
| [NativeTypeName(""const {type}"")] | ||
| private const {type} x = {expectedValue}; | ||
| }} | ||
| }} | ||
| "; | ||
|
|
||
| return ValidateGeneratedCSharpPreviewWindowsBindingsAsync( | ||
| inputContents, | ||
| expectedOutputContents); | ||
| } | ||
| } |
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.