From 245d3b0f23e364ee1095238d15af40abf1f6889d Mon Sep 17 00:00:00 2001 From: axunonb Date: Mon, 29 Jan 2024 19:31:59 +0100 Subject: [PATCH] Change all public types in namespace Cysharp.Text to internal (#372) * Change all public types in namespace Cysharp.Text to internal * Regression caused by https://github.com/axuno/SmartFormat/pull/368 * Stop namespace collision with Cysharp.Text nuget package * Affects: class, struct, interface, delegate, enum * using https://github.com/zzzprojects/findandreplace on command line, so we can automate this step: "fnr.exe" --cl --dir "SmartFormat.ZString\repo\src\ZString" --fileMask "*.cs,*.tt" --includeSubDirectories --caseSensitive --useRegEx --find "public (?=.*(class |struct |enum |interface |delegate ))" --replace "internal " * Add a unit test to get an alert when Cysharp.Text objects are public * Bump version to v3.3.2 --- .github/workflows/SonarCloud.yml | 4 +- appveyor.yml | 2 +- src/Directory.Build.props | 4 +- src/SmartFormat.ZString.Tests/CysharpText.cs | 34 ++++++++++ .../SmartFormat.ZString.Tests.csproj | 47 ++++++++++++++ .../SmartFormat.ZString.csproj | 6 ++ src/SmartFormat.ZString/ZStringWriter.cs | 6 +- .../repo/src/ZString/FormatParser.cs | 2 +- .../src/ZString/IResettableBufferWriter.cs | 2 +- .../repo/src/ZString/Number/BitOperations.cs | 2 +- .../repo/src/ZString/Number/HexConverter.cs | 2 +- .../Number.NumberToFloatingPointBits.cs | 2 +- .../repo/src/ZString/PreparedFormat.cs | 64 +++++++++---------- .../repo/src/ZString/PreparedFormat.tt | 2 +- .../src/ZString/StringBuilder.AppendJoin.cs | 4 +- .../src/ZString/StringBuilder.AppendJoin.tt | 2 +- .../ZString/Unity/TextMeshProExtensions.cs | 2 +- .../ZString/Unity/TextMeshProExtensions.tt | 2 +- .../Utf16ValueStringBuilder.AppendFormat.cs | 2 +- .../Utf16ValueStringBuilder.AppendFormat.tt | 2 +- ...Utf16ValueStringBuilder.CreateFormatter.cs | 2 +- ...Utf16ValueStringBuilder.CreateFormatter.tt | 2 +- ...alueStringBuilder.SpanFormattableAppend.cs | 2 +- ...alueStringBuilder.SpanFormattableAppend.tt | 2 +- .../src/ZString/Utf16ValueStringBuilder.cs | 6 +- .../Utf8ValueStringBuilder.AppendFormat.cs | 2 +- .../Utf8ValueStringBuilder.AppendFormat.tt | 2 +- .../Utf8ValueStringBuilder.CreateFormatter.cs | 2 +- .../Utf8ValueStringBuilder.CreateFormatter.tt | 2 +- ...alueStringBuilder.SpanFormattableAppend.cs | 2 +- ...alueStringBuilder.SpanFormattableAppend.tt | 2 +- .../src/ZString/Utf8ValueStringBuilder.cs | 6 +- .../repo/src/ZString/ZString.Concat.cs | 2 +- .../repo/src/ZString/ZString.Concat.tt | 2 +- .../repo/src/ZString/ZString.Format.cs | 2 +- .../repo/src/ZString/ZString.Format.tt | 2 +- .../repo/src/ZString/ZString.Prepare.cs | 2 +- .../repo/src/ZString/ZString.Prepare.tt | 2 +- .../repo/src/ZString/ZString.Utf8Format.cs | 2 +- .../repo/src/ZString/ZString.Utf8Format.tt | 2 +- .../repo/src/ZString/ZString.cs | 2 +- .../repo/src/ZString/ZStringWriter.cs | 2 +- src/SmartFormat.sln | 10 +++ 43 files changed, 176 insertions(+), 79 deletions(-) create mode 100644 src/SmartFormat.ZString.Tests/CysharpText.cs create mode 100644 src/SmartFormat.ZString.Tests/SmartFormat.ZString.Tests.csproj diff --git a/.github/workflows/SonarCloud.yml b/.github/workflows/SonarCloud.yml index 79ac4883..b2c692eb 100644 --- a/.github/workflows/SonarCloud.yml +++ b/.github/workflows/SonarCloud.yml @@ -13,8 +13,8 @@ jobs: # (PRs from forks can't access secrets other than secrets.GITHUB_TOKEN for security reasons) if: ${{ !github.event.pull_request.head.repo.fork }} env: - version: '3.3.1' - versionFile: '3.3.1' + version: '3.3.2' + versionFile: '3.3.2' steps: - name: Set up JDK 17 uses: actions/setup-java@v3 diff --git a/appveyor.yml b/appveyor.yml index 0130f7f3..6270b1d3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -23,7 +23,7 @@ for: - ps: dotnet restore SmartFormat.sln --verbosity quiet - ps: dotnet add .\SmartFormat.Tests\SmartFormat.Tests.csproj package AltCover - ps: | - $version = "3.3.1" + $version = "3.3.2" $versionFile = $version + "." + ${env:APPVEYOR_BUILD_NUMBER} if ($env:APPVEYOR_PULL_REQUEST_NUMBER) { diff --git a/src/Directory.Build.props b/src/Directory.Build.props index fbde0f24..c34a4727 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -8,8 +8,8 @@ Copyright 2011-$(CurrentYear) SmartFormat Project https://github.com/axuno/SmartFormat.git true - 3.3.1 - 3.3.1 + 3.3.2 + 3.3.2 3.0.0 latest true diff --git a/src/SmartFormat.ZString.Tests/CysharpText.cs b/src/SmartFormat.ZString.Tests/CysharpText.cs new file mode 100644 index 00000000..68c568b8 --- /dev/null +++ b/src/SmartFormat.ZString.Tests/CysharpText.cs @@ -0,0 +1,34 @@ +// +// Copyright SmartFormat Project maintainers and contributors. +// Licensed under the MIT license. +// + +using NUnit.Framework; + +namespace SmartFormat.ZString.Tests; + +[TestFixture] +public class CysharpText +{ + /// + /// To stop namespace collision with Cysharp.Text nuget package, + /// change all public types in namespace Cysharp.Text to internal. + /// This can easily happen when Cysharp.Text is updated in the SmartFormat.ZString project. + /// Using https://github.com/zzzprojects/findandreplace on command line, so we can automate this step: + /// "fnr.exe" --cl --dir "SmartFormat.ZString\repo\src\ZString" --fileMask "*.cs,*.tt" --includeSubDirectories --caseSensitive --useRegEx --find "public (?=.*(class |struct |enum |interface |delegate ))" --replace "internal " + /// + [Test] + public void Classes_Of_Cysharp_Text_Namespace_Should_Be_Internal() + { + // If this tests fails, you need to run the above command line + // to change all public types in namespace Cysharp.Text to internal + Assert.Multiple(() => + { + Assert.That(typeof(Cysharp.Text.Utf16ValueStringBuilder).IsPublic, Is.False); + Assert.That(typeof(Cysharp.Text.Utf8ValueStringBuilder).IsPublic, Is.False); + Assert.That(typeof(Cysharp.Text.ZString).IsPublic, Is.False); + Assert.That(typeof(Cysharp.Text.FormatParser).IsPublic, Is.False); + Assert.That(typeof(System.HexConverter).IsPublic, Is.False); + }); + } +} diff --git a/src/SmartFormat.ZString.Tests/SmartFormat.ZString.Tests.csproj b/src/SmartFormat.ZString.Tests/SmartFormat.ZString.Tests.csproj new file mode 100644 index 00000000..c42d8362 --- /dev/null +++ b/src/SmartFormat.ZString.Tests/SmartFormat.ZString.Tests.csproj @@ -0,0 +1,47 @@ + + + + Unit tests for SmartFormat.ZString + SmartFormat.ZString.Tests + axuno gGmbH, Scott Rippey, Bernhard Millauer and other contributors. + net462;net6.0 + TRACE;DEBUG;RELEASE + false + SmartFormat.ZString.Tests + ../SmartFormat/SmartFormat.snk + false + true + false + enable + en + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + $(NoWarn);CA1861 + 4 + DEBUG;TRACE + + + + $(NoWarn);CA1861 + 4 + RELEASE + + + + + + + \ No newline at end of file diff --git a/src/SmartFormat.ZString/SmartFormat.ZString.csproj b/src/SmartFormat.ZString/SmartFormat.ZString.csproj index ab3841f1..7738b720 100644 --- a/src/SmartFormat.ZString/SmartFormat.ZString.csproj +++ b/src/SmartFormat.ZString/SmartFormat.ZString.csproj @@ -79,4 +79,10 @@ + + + <_Parameter1>SmartFormat.ZString.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a1cdb8ba81e1a00f0f9509a8f0c896e0de0da6875652fffd44fb867e6b78fd78c31c6fdb07544b2ae53ed4b56daa90333d32ac14387f7f68d39165da8f99b8c294c1cee1bcc4bbcbe2dd73879824b53708837f425e2bf5c7d2cf868de9548c44871888bf9db5cb425064dda4b17134f8e3b52e1f686315a1832043c7b58fb0ac + + + diff --git a/src/SmartFormat.ZString/ZStringWriter.cs b/src/SmartFormat.ZString/ZStringWriter.cs index e6716ef2..c5d83022 100644 --- a/src/SmartFormat.ZString/ZStringWriter.cs +++ b/src/SmartFormat.ZString/ZStringWriter.cs @@ -27,13 +27,15 @@ public sealed class ZStringWriter : TextWriter { private Utf16ValueStringBuilder sb; private bool isOpen; - private UnicodeEncoding encoding; + private UnicodeEncoding encoding = null!; /// /// Creates a new instance using as format provider. /// public ZStringWriter() : this(CultureInfo.CurrentCulture) { + sb = Cysharp.Text.ZString.CreateStringBuilder(); + isOpen = true; } /// @@ -41,8 +43,6 @@ public ZStringWriter() : this(CultureInfo.CurrentCulture) /// public ZStringWriter(IFormatProvider formatProvider) : base(formatProvider) { - sb = Cysharp.Text.ZString.CreateStringBuilder(); - isOpen = true; } /// diff --git a/src/SmartFormat.ZString/repo/src/ZString/FormatParser.cs b/src/SmartFormat.ZString/repo/src/ZString/FormatParser.cs index 8cd185be..bdbb162d 100644 --- a/src/SmartFormat.ZString/repo/src/ZString/FormatParser.cs +++ b/src/SmartFormat.ZString/repo/src/ZString/FormatParser.cs @@ -7,7 +7,7 @@ internal static class FormatParser { // {index[,alignment][:formatString]} - public readonly ref struct ParseResult + internal readonly ref struct ParseResult { public readonly int Index; public readonly ReadOnlySpan FormatString; diff --git a/src/SmartFormat.ZString/repo/src/ZString/IResettableBufferWriter.cs b/src/SmartFormat.ZString/repo/src/ZString/IResettableBufferWriter.cs index bcdb1524..30dccd1e 100644 --- a/src/SmartFormat.ZString/repo/src/ZString/IResettableBufferWriter.cs +++ b/src/SmartFormat.ZString/repo/src/ZString/IResettableBufferWriter.cs @@ -5,7 +5,7 @@ namespace Cysharp.Text { - public interface IResettableBufferWriter : IBufferWriter + internal interface IResettableBufferWriter : IBufferWriter { void Reset(); } diff --git a/src/SmartFormat.ZString/repo/src/ZString/Number/BitOperations.cs b/src/SmartFormat.ZString/repo/src/ZString/Number/BitOperations.cs index 978a99cb..6660badd 100644 --- a/src/SmartFormat.ZString/repo/src/ZString/Number/BitOperations.cs +++ b/src/SmartFormat.ZString/repo/src/ZString/Number/BitOperations.cs @@ -15,7 +15,7 @@ namespace System.Numerics /// The methods use hardware intrinsics when available on the underlying platform, /// otherwise they use optimized software fallbacks. /// - public static class BitOperations + internal static class BitOperations { // C# no-alloc optimization that directly wraps the data section of the dll (similar to string constants) // https://github.com/dotnet/roslyn/pull/24621 diff --git a/src/SmartFormat.ZString/repo/src/ZString/Number/HexConverter.cs b/src/SmartFormat.ZString/repo/src/ZString/Number/HexConverter.cs index 4e4e3a72..c5373e3b 100644 --- a/src/SmartFormat.ZString/repo/src/ZString/Number/HexConverter.cs +++ b/src/SmartFormat.ZString/repo/src/ZString/Number/HexConverter.cs @@ -8,7 +8,7 @@ namespace System { internal static class HexConverter { - public enum Casing : uint + internal enum Casing : uint { // Output [ '0' .. '9' ] and [ 'A' .. 'F' ]. Upper = 0, diff --git a/src/SmartFormat.ZString/repo/src/ZString/Number/Number.NumberToFloatingPointBits.cs b/src/SmartFormat.ZString/repo/src/ZString/Number/Number.NumberToFloatingPointBits.cs index d0bf894c..66607328 100644 --- a/src/SmartFormat.ZString/repo/src/ZString/Number/Number.NumberToFloatingPointBits.cs +++ b/src/SmartFormat.ZString/repo/src/ZString/Number/Number.NumberToFloatingPointBits.cs @@ -15,7 +15,7 @@ static unsafe int SingleToInt32Bits(float value) return *((int*)&value); } - public readonly struct FloatingPointInfo + internal readonly struct FloatingPointInfo { public static readonly FloatingPointInfo Double = new FloatingPointInfo( denormalMantissaBits: 52, diff --git a/src/SmartFormat.ZString/repo/src/ZString/PreparedFormat.cs b/src/SmartFormat.ZString/repo/src/ZString/PreparedFormat.cs index 955c5ca6..de95c3d6 100644 --- a/src/SmartFormat.ZString/repo/src/ZString/PreparedFormat.cs +++ b/src/SmartFormat.ZString/repo/src/ZString/PreparedFormat.cs @@ -4,7 +4,7 @@ namespace Cysharp.Text { - public sealed partial class Utf16PreparedFormat + internal sealed partial class Utf16PreparedFormat { public string FormatString { get; } public int MinSize { get; } @@ -69,7 +69,7 @@ public void FormatTo(ref TBufferWriter sb, T1 arg1) } } } - public sealed partial class Utf16PreparedFormat + internal sealed partial class Utf16PreparedFormat { public string FormatString { get; } public int MinSize { get; } @@ -139,7 +139,7 @@ public void FormatTo(ref TBufferWriter sb, T1 arg1, T2 arg2) } } } - public sealed partial class Utf16PreparedFormat + internal sealed partial class Utf16PreparedFormat { public string FormatString { get; } public int MinSize { get; } @@ -214,7 +214,7 @@ public void FormatTo(ref TBufferWriter sb, T1 arg1, T2 arg2, T3 a } } } - public sealed partial class Utf16PreparedFormat + internal sealed partial class Utf16PreparedFormat { public string FormatString { get; } public int MinSize { get; } @@ -294,7 +294,7 @@ public void FormatTo(ref TBufferWriter sb, T1 arg1, T2 arg2, T3 a } } } - public sealed partial class Utf16PreparedFormat + internal sealed partial class Utf16PreparedFormat { public string FormatString { get; } public int MinSize { get; } @@ -379,7 +379,7 @@ public void FormatTo(ref TBufferWriter sb, T1 arg1, T2 arg2, T3 a } } } - public sealed partial class Utf16PreparedFormat + internal sealed partial class Utf16PreparedFormat { public string FormatString { get; } public int MinSize { get; } @@ -469,7 +469,7 @@ public void FormatTo(ref TBufferWriter sb, T1 arg1, T2 arg2, T3 a } } } - public sealed partial class Utf16PreparedFormat + internal sealed partial class Utf16PreparedFormat { public string FormatString { get; } public int MinSize { get; } @@ -564,7 +564,7 @@ public void FormatTo(ref TBufferWriter sb, T1 arg1, T2 arg2, T3 a } } } - public sealed partial class Utf16PreparedFormat + internal sealed partial class Utf16PreparedFormat { public string FormatString { get; } public int MinSize { get; } @@ -664,7 +664,7 @@ public void FormatTo(ref TBufferWriter sb, T1 arg1, T2 arg2, T3 a } } } - public sealed partial class Utf16PreparedFormat + internal sealed partial class Utf16PreparedFormat { public string FormatString { get; } public int MinSize { get; } @@ -769,7 +769,7 @@ public void FormatTo(ref TBufferWriter sb, T1 arg1, T2 arg2, T3 a } } } - public sealed partial class Utf16PreparedFormat + internal sealed partial class Utf16PreparedFormat { public string FormatString { get; } public int MinSize { get; } @@ -879,7 +879,7 @@ public void FormatTo(ref TBufferWriter sb, T1 arg1, T2 arg2, T3 a } } } - public sealed partial class Utf16PreparedFormat + internal sealed partial class Utf16PreparedFormat { public string FormatString { get; } public int MinSize { get; } @@ -994,7 +994,7 @@ public void FormatTo(ref TBufferWriter sb, T1 arg1, T2 arg2, T3 a } } } - public sealed partial class Utf16PreparedFormat + internal sealed partial class Utf16PreparedFormat { public string FormatString { get; } public int MinSize { get; } @@ -1114,7 +1114,7 @@ public void FormatTo(ref TBufferWriter sb, T1 arg1, T2 arg2, T3 a } } } - public sealed partial class Utf16PreparedFormat + internal sealed partial class Utf16PreparedFormat { public string FormatString { get; } public int MinSize { get; } @@ -1239,7 +1239,7 @@ public void FormatTo(ref TBufferWriter sb, T1 arg1, T2 arg2, T3 a } } } - public sealed partial class Utf16PreparedFormat + internal sealed partial class Utf16PreparedFormat { public string FormatString { get; } public int MinSize { get; } @@ -1369,7 +1369,7 @@ public void FormatTo(ref TBufferWriter sb, T1 arg1, T2 arg2, T3 a } } } - public sealed partial class Utf16PreparedFormat + internal sealed partial class Utf16PreparedFormat { public string FormatString { get; } public int MinSize { get; } @@ -1504,7 +1504,7 @@ public void FormatTo(ref TBufferWriter sb, T1 arg1, T2 arg2, T3 a } } } - public sealed partial class Utf16PreparedFormat + internal sealed partial class Utf16PreparedFormat { public string FormatString { get; } public int MinSize { get; } @@ -1644,7 +1644,7 @@ public void FormatTo(ref TBufferWriter sb, T1 arg1, T2 arg2, T3 a } } } - public sealed partial class Utf8PreparedFormat + internal sealed partial class Utf8PreparedFormat { public string FormatString { get; } public int MinSize { get; } @@ -1710,7 +1710,7 @@ public void FormatTo(ref TBufferWriter sb, T1 arg1) } } } - public sealed partial class Utf8PreparedFormat + internal sealed partial class Utf8PreparedFormat { public string FormatString { get; } public int MinSize { get; } @@ -1781,7 +1781,7 @@ public void FormatTo(ref TBufferWriter sb, T1 arg1, T2 arg2) } } } - public sealed partial class Utf8PreparedFormat + internal sealed partial class Utf8PreparedFormat { public string FormatString { get; } public int MinSize { get; } @@ -1857,7 +1857,7 @@ public void FormatTo(ref TBufferWriter sb, T1 arg1, T2 arg2, T3 a } } } - public sealed partial class Utf8PreparedFormat + internal sealed partial class Utf8PreparedFormat { public string FormatString { get; } public int MinSize { get; } @@ -1938,7 +1938,7 @@ public void FormatTo(ref TBufferWriter sb, T1 arg1, T2 arg2, T3 a } } } - public sealed partial class Utf8PreparedFormat + internal sealed partial class Utf8PreparedFormat { public string FormatString { get; } public int MinSize { get; } @@ -2024,7 +2024,7 @@ public void FormatTo(ref TBufferWriter sb, T1 arg1, T2 arg2, T3 a } } } - public sealed partial class Utf8PreparedFormat + internal sealed partial class Utf8PreparedFormat { public string FormatString { get; } public int MinSize { get; } @@ -2115,7 +2115,7 @@ public void FormatTo(ref TBufferWriter sb, T1 arg1, T2 arg2, T3 a } } } - public sealed partial class Utf8PreparedFormat + internal sealed partial class Utf8PreparedFormat { public string FormatString { get; } public int MinSize { get; } @@ -2211,7 +2211,7 @@ public void FormatTo(ref TBufferWriter sb, T1 arg1, T2 arg2, T3 a } } } - public sealed partial class Utf8PreparedFormat + internal sealed partial class Utf8PreparedFormat { public string FormatString { get; } public int MinSize { get; } @@ -2312,7 +2312,7 @@ public void FormatTo(ref TBufferWriter sb, T1 arg1, T2 arg2, T3 a } } } - public sealed partial class Utf8PreparedFormat + internal sealed partial class Utf8PreparedFormat { public string FormatString { get; } public int MinSize { get; } @@ -2418,7 +2418,7 @@ public void FormatTo(ref TBufferWriter sb, T1 arg1, T2 arg2, T3 a } } } - public sealed partial class Utf8PreparedFormat + internal sealed partial class Utf8PreparedFormat { public string FormatString { get; } public int MinSize { get; } @@ -2529,7 +2529,7 @@ public void FormatTo(ref TBufferWriter sb, T1 arg1, T2 arg2, T3 a } } } - public sealed partial class Utf8PreparedFormat + internal sealed partial class Utf8PreparedFormat { public string FormatString { get; } public int MinSize { get; } @@ -2645,7 +2645,7 @@ public void FormatTo(ref TBufferWriter sb, T1 arg1, T2 arg2, T3 a } } } - public sealed partial class Utf8PreparedFormat + internal sealed partial class Utf8PreparedFormat { public string FormatString { get; } public int MinSize { get; } @@ -2766,7 +2766,7 @@ public void FormatTo(ref TBufferWriter sb, T1 arg1, T2 arg2, T3 a } } } - public sealed partial class Utf8PreparedFormat + internal sealed partial class Utf8PreparedFormat { public string FormatString { get; } public int MinSize { get; } @@ -2892,7 +2892,7 @@ public void FormatTo(ref TBufferWriter sb, T1 arg1, T2 arg2, T3 a } } } - public sealed partial class Utf8PreparedFormat + internal sealed partial class Utf8PreparedFormat { public string FormatString { get; } public int MinSize { get; } @@ -3023,7 +3023,7 @@ public void FormatTo(ref TBufferWriter sb, T1 arg1, T2 arg2, T3 a } } } - public sealed partial class Utf8PreparedFormat + internal sealed partial class Utf8PreparedFormat { public string FormatString { get; } public int MinSize { get; } @@ -3159,7 +3159,7 @@ public void FormatTo(ref TBufferWriter sb, T1 arg1, T2 arg2, T3 a } } } - public sealed partial class Utf8PreparedFormat + internal sealed partial class Utf8PreparedFormat { public string FormatString { get; } public int MinSize { get; } diff --git a/src/SmartFormat.ZString/repo/src/ZString/PreparedFormat.tt b/src/SmartFormat.ZString/repo/src/ZString/PreparedFormat.tt index 19f724aa..29f32620 100644 --- a/src/SmartFormat.ZString/repo/src/ZString/PreparedFormat.tt +++ b/src/SmartFormat.ZString/repo/src/ZString/PreparedFormat.tt @@ -13,7 +13,7 @@ namespace Cysharp.Text { <# foreach(var utf in utfTypes) { var isUtf16 = (utf == "Utf16"); #> <# for(var i = 1; i <= TypeParamMax; i++) { #> - public sealed partial class <#= utf #>PreparedFormat<<#= CreateTypeArgument(i) #>> + internal sealed partial class <#= utf #>PreparedFormat<<#= CreateTypeArgument(i) #>> { public string FormatString { get; } public int MinSize { get; } diff --git a/src/SmartFormat.ZString/repo/src/ZString/StringBuilder.AppendJoin.cs b/src/SmartFormat.ZString/repo/src/ZString/StringBuilder.AppendJoin.cs index 19f5e3e1..f2ed6d23 100644 --- a/src/SmartFormat.ZString/repo/src/ZString/StringBuilder.AppendJoin.cs +++ b/src/SmartFormat.ZString/repo/src/ZString/StringBuilder.AppendJoin.cs @@ -7,7 +7,7 @@ namespace Cysharp.Text { - public partial struct Utf16ValueStringBuilder + internal partial struct Utf16ValueStringBuilder { /// /// Concatenates the string representations of the elements in the provided array of objects, using the specified char separator between each member, then appends the result to the current instance of the string builder. @@ -209,7 +209,7 @@ internal void AppendJoinInternal(ReadOnlySpan separator, IEnumerable } } } - public partial struct Utf8ValueStringBuilder + internal partial struct Utf8ValueStringBuilder { /// /// Concatenates the string representations of the elements in the provided array of objects, using the specified char separator between each member, then appends the result to the current instance of the string builder. diff --git a/src/SmartFormat.ZString/repo/src/ZString/StringBuilder.AppendJoin.tt b/src/SmartFormat.ZString/repo/src/ZString/StringBuilder.AppendJoin.tt index 0b58fb74..35c066b5 100644 --- a/src/SmartFormat.ZString/repo/src/ZString/StringBuilder.AppendJoin.tt +++ b/src/SmartFormat.ZString/repo/src/ZString/StringBuilder.AppendJoin.tt @@ -15,7 +15,7 @@ using System.Runtime.CompilerServices; namespace Cysharp.Text { <# foreach(var utf in utfTypes) { #> - public partial struct <#= utf #>ValueStringBuilder + internal partial struct <#= utf #>ValueStringBuilder { /// /// Concatenates the string representations of the elements in the provided array of objects, using the specified char separator between each member, then appends the result to the current instance of the string builder. diff --git a/src/SmartFormat.ZString/repo/src/ZString/Unity/TextMeshProExtensions.cs b/src/SmartFormat.ZString/repo/src/ZString/Unity/TextMeshProExtensions.cs index ce384fb6..f6f53a01 100644 --- a/src/SmartFormat.ZString/repo/src/ZString/Unity/TextMeshProExtensions.cs +++ b/src/SmartFormat.ZString/repo/src/ZString/Unity/TextMeshProExtensions.cs @@ -4,7 +4,7 @@ namespace Cysharp.Text { - public static partial class TextMeshProExtensions + internal static partial class TextMeshProExtensions { public static void SetText(this TMP_Text text, T arg0) { diff --git a/src/SmartFormat.ZString/repo/src/ZString/Unity/TextMeshProExtensions.tt b/src/SmartFormat.ZString/repo/src/ZString/Unity/TextMeshProExtensions.tt index 3fc1ec42..6ad6034a 100644 --- a/src/SmartFormat.ZString/repo/src/ZString/Unity/TextMeshProExtensions.tt +++ b/src/SmartFormat.ZString/repo/src/ZString/Unity/TextMeshProExtensions.tt @@ -27,7 +27,7 @@ using TMPro; namespace Cysharp.Text { - public static partial class TextMeshProExtensions + internal static partial class TextMeshProExtensions { public static void SetText(this TMP_Text text, T arg0) { diff --git a/src/SmartFormat.ZString/repo/src/ZString/Utf16/Utf16ValueStringBuilder.AppendFormat.cs b/src/SmartFormat.ZString/repo/src/ZString/Utf16/Utf16ValueStringBuilder.AppendFormat.cs index e0b4fb4a..17859027 100644 --- a/src/SmartFormat.ZString/repo/src/ZString/Utf16/Utf16ValueStringBuilder.AppendFormat.cs +++ b/src/SmartFormat.ZString/repo/src/ZString/Utf16/Utf16ValueStringBuilder.AppendFormat.cs @@ -2,7 +2,7 @@ namespace Cysharp.Text { - public partial struct Utf16ValueStringBuilder + internal partial struct Utf16ValueStringBuilder { /// Appends the string returned by processing a composite format string, each format item is replaced by the string representation of arguments. public void AppendFormat(string format, T1 arg1) diff --git a/src/SmartFormat.ZString/repo/src/ZString/Utf16/Utf16ValueStringBuilder.AppendFormat.tt b/src/SmartFormat.ZString/repo/src/ZString/Utf16/Utf16ValueStringBuilder.AppendFormat.tt index 2f866786..d372bb69 100644 --- a/src/SmartFormat.ZString/repo/src/ZString/Utf16/Utf16ValueStringBuilder.AppendFormat.tt +++ b/src/SmartFormat.ZString/repo/src/ZString/Utf16/Utf16ValueStringBuilder.AppendFormat.tt @@ -9,7 +9,7 @@ using System; namespace Cysharp.Text { - public partial struct Utf16ValueStringBuilder + internal partial struct Utf16ValueStringBuilder { <# for(var i = 1; i <= TypeParamMax; i++) { #> /// Appends the string returned by processing a composite format string, each format item is replaced by the string representation of arguments. diff --git a/src/SmartFormat.ZString/repo/src/ZString/Utf16/Utf16ValueStringBuilder.CreateFormatter.cs b/src/SmartFormat.ZString/repo/src/ZString/Utf16/Utf16ValueStringBuilder.CreateFormatter.cs index e94323f8..fd064122 100644 --- a/src/SmartFormat.ZString/repo/src/ZString/Utf16/Utf16ValueStringBuilder.CreateFormatter.cs +++ b/src/SmartFormat.ZString/repo/src/ZString/Utf16/Utf16ValueStringBuilder.CreateFormatter.cs @@ -2,7 +2,7 @@ namespace Cysharp.Text { - public partial struct Utf16ValueStringBuilder + internal partial struct Utf16ValueStringBuilder { static object? CreateFormatter(Type type) { diff --git a/src/SmartFormat.ZString/repo/src/ZString/Utf16/Utf16ValueStringBuilder.CreateFormatter.tt b/src/SmartFormat.ZString/repo/src/ZString/Utf16/Utf16ValueStringBuilder.CreateFormatter.tt index df93adab..c99f1e37 100644 --- a/src/SmartFormat.ZString/repo/src/ZString/Utf16/Utf16ValueStringBuilder.CreateFormatter.tt +++ b/src/SmartFormat.ZString/repo/src/ZString/Utf16/Utf16ValueStringBuilder.CreateFormatter.tt @@ -35,7 +35,7 @@ using System; namespace Cysharp.Text { - public partial struct Utf16ValueStringBuilder + internal partial struct Utf16ValueStringBuilder { static object CreateFormatter(Type type) { diff --git a/src/SmartFormat.ZString/repo/src/ZString/Utf16/Utf16ValueStringBuilder.SpanFormattableAppend.cs b/src/SmartFormat.ZString/repo/src/ZString/Utf16/Utf16ValueStringBuilder.SpanFormattableAppend.cs index 39009e31..222a6e80 100644 --- a/src/SmartFormat.ZString/repo/src/ZString/Utf16/Utf16ValueStringBuilder.SpanFormattableAppend.cs +++ b/src/SmartFormat.ZString/repo/src/ZString/Utf16/Utf16ValueStringBuilder.SpanFormattableAppend.cs @@ -3,7 +3,7 @@ namespace Cysharp.Text { - public partial struct Utf16ValueStringBuilder + internal partial struct Utf16ValueStringBuilder { /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/SmartFormat.ZString/repo/src/ZString/Utf16/Utf16ValueStringBuilder.SpanFormattableAppend.tt b/src/SmartFormat.ZString/repo/src/ZString/Utf16/Utf16ValueStringBuilder.SpanFormattableAppend.tt index 9464f38e..0b602cce 100644 --- a/src/SmartFormat.ZString/repo/src/ZString/Utf16/Utf16ValueStringBuilder.SpanFormattableAppend.tt +++ b/src/SmartFormat.ZString/repo/src/ZString/Utf16/Utf16ValueStringBuilder.SpanFormattableAppend.tt @@ -10,7 +10,7 @@ using System.Runtime.CompilerServices; namespace Cysharp.Text { - public partial struct Utf16ValueStringBuilder + internal partial struct Utf16ValueStringBuilder { <# foreach(var t in spanFormattables) { #> /// Appends the string representation of a specified value to this instance. diff --git a/src/SmartFormat.ZString/repo/src/ZString/Utf16ValueStringBuilder.cs b/src/SmartFormat.ZString/repo/src/ZString/Utf16ValueStringBuilder.cs index df6ec3b7..b0d2e398 100644 --- a/src/SmartFormat.ZString/repo/src/ZString/Utf16ValueStringBuilder.cs +++ b/src/SmartFormat.ZString/repo/src/ZString/Utf16ValueStringBuilder.cs @@ -5,9 +5,9 @@ namespace Cysharp.Text { - public partial struct Utf16ValueStringBuilder : IDisposable, IBufferWriter, IResettableBufferWriter + internal partial struct Utf16ValueStringBuilder : IDisposable, IBufferWriter, IResettableBufferWriter { - public delegate bool TryFormat(T value, Span destination, out int charsWritten, ReadOnlySpan format); + internal delegate bool TryFormat(T value, Span destination, out int charsWritten, ReadOnlySpan format); const int ThreadStaticBufferSize = 31111; const int DefaultBufferSize = 32768; // use 32K default buffer. @@ -709,7 +709,7 @@ public static void EnableNullableFormat() where T : struct RegisterTryFormat(CreateNullableFormatter()); } - public static class FormatterCache + internal static class FormatterCache { public static TryFormat TryFormatDelegate; static FormatterCache() diff --git a/src/SmartFormat.ZString/repo/src/ZString/Utf8/Utf8ValueStringBuilder.AppendFormat.cs b/src/SmartFormat.ZString/repo/src/ZString/Utf8/Utf8ValueStringBuilder.AppendFormat.cs index b237a288..6d466941 100644 --- a/src/SmartFormat.ZString/repo/src/ZString/Utf8/Utf8ValueStringBuilder.AppendFormat.cs +++ b/src/SmartFormat.ZString/repo/src/ZString/Utf8/Utf8ValueStringBuilder.AppendFormat.cs @@ -3,7 +3,7 @@ namespace Cysharp.Text { - public partial struct Utf8ValueStringBuilder + internal partial struct Utf8ValueStringBuilder { /// Appends the string returned by processing a composite format string, each format item is replaced by the string representation of arguments. public void AppendFormat(string format, T1 arg1) diff --git a/src/SmartFormat.ZString/repo/src/ZString/Utf8/Utf8ValueStringBuilder.AppendFormat.tt b/src/SmartFormat.ZString/repo/src/ZString/Utf8/Utf8ValueStringBuilder.AppendFormat.tt index 79faa3ae..ea552bd3 100644 --- a/src/SmartFormat.ZString/repo/src/ZString/Utf8/Utf8ValueStringBuilder.AppendFormat.tt +++ b/src/SmartFormat.ZString/repo/src/ZString/Utf8/Utf8ValueStringBuilder.AppendFormat.tt @@ -10,7 +10,7 @@ using System.Buffers; namespace Cysharp.Text { - public partial struct Utf8ValueStringBuilder + internal partial struct Utf8ValueStringBuilder { <# for(var i = 1; i <= TypeParamMax; i++) { #> /// Appends the string returned by processing a composite format string, each format item is replaced by the string representation of arguments. diff --git a/src/SmartFormat.ZString/repo/src/ZString/Utf8/Utf8ValueStringBuilder.CreateFormatter.cs b/src/SmartFormat.ZString/repo/src/ZString/Utf8/Utf8ValueStringBuilder.CreateFormatter.cs index 2a326055..5d211a0e 100644 --- a/src/SmartFormat.ZString/repo/src/ZString/Utf8/Utf8ValueStringBuilder.CreateFormatter.cs +++ b/src/SmartFormat.ZString/repo/src/ZString/Utf8/Utf8ValueStringBuilder.CreateFormatter.cs @@ -4,7 +4,7 @@ namespace Cysharp.Text { - public partial struct Utf8ValueStringBuilder + internal partial struct Utf8ValueStringBuilder { static object? CreateFormatter(Type type) { diff --git a/src/SmartFormat.ZString/repo/src/ZString/Utf8/Utf8ValueStringBuilder.CreateFormatter.tt b/src/SmartFormat.ZString/repo/src/ZString/Utf8/Utf8ValueStringBuilder.CreateFormatter.tt index 8d597d06..13b61af4 100644 --- a/src/SmartFormat.ZString/repo/src/ZString/Utf8/Utf8ValueStringBuilder.CreateFormatter.tt +++ b/src/SmartFormat.ZString/repo/src/ZString/Utf8/Utf8ValueStringBuilder.CreateFormatter.tt @@ -11,7 +11,7 @@ using System.Buffers.Text; namespace Cysharp.Text { - public partial struct Utf8ValueStringBuilder + internal partial struct Utf8ValueStringBuilder { static object CreateFormatter(Type type) { diff --git a/src/SmartFormat.ZString/repo/src/ZString/Utf8/Utf8ValueStringBuilder.SpanFormattableAppend.cs b/src/SmartFormat.ZString/repo/src/ZString/Utf8/Utf8ValueStringBuilder.SpanFormattableAppend.cs index 5321ecbf..9fad88e7 100644 --- a/src/SmartFormat.ZString/repo/src/ZString/Utf8/Utf8ValueStringBuilder.SpanFormattableAppend.cs +++ b/src/SmartFormat.ZString/repo/src/ZString/Utf8/Utf8ValueStringBuilder.SpanFormattableAppend.cs @@ -5,7 +5,7 @@ namespace Cysharp.Text { - public partial struct Utf8ValueStringBuilder + internal partial struct Utf8ValueStringBuilder { /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/SmartFormat.ZString/repo/src/ZString/Utf8/Utf8ValueStringBuilder.SpanFormattableAppend.tt b/src/SmartFormat.ZString/repo/src/ZString/Utf8/Utf8ValueStringBuilder.SpanFormattableAppend.tt index 85962641..f5475e5a 100644 --- a/src/SmartFormat.ZString/repo/src/ZString/Utf8/Utf8ValueStringBuilder.SpanFormattableAppend.tt +++ b/src/SmartFormat.ZString/repo/src/ZString/Utf8/Utf8ValueStringBuilder.SpanFormattableAppend.tt @@ -12,7 +12,7 @@ using System.Runtime.CompilerServices; namespace Cysharp.Text { - public partial struct Utf8ValueStringBuilder + internal partial struct Utf8ValueStringBuilder { <# foreach(var t in utf8spanFormattables) { #> /// Appends the string representation of a specified value to this instance. diff --git a/src/SmartFormat.ZString/repo/src/ZString/Utf8ValueStringBuilder.cs b/src/SmartFormat.ZString/repo/src/ZString/Utf8ValueStringBuilder.cs index 9f5fa12f..1229b8b7 100644 --- a/src/SmartFormat.ZString/repo/src/ZString/Utf8ValueStringBuilder.cs +++ b/src/SmartFormat.ZString/repo/src/ZString/Utf8ValueStringBuilder.cs @@ -8,9 +8,9 @@ namespace Cysharp.Text { - public partial struct Utf8ValueStringBuilder : IDisposable, IBufferWriter, IResettableBufferWriter + internal partial struct Utf8ValueStringBuilder : IDisposable, IBufferWriter, IResettableBufferWriter { - public delegate bool TryFormat(T value, Span destination, out int written, StandardFormat format); + internal delegate bool TryFormat(T value, Span destination, out int written, StandardFormat format); const int ThreadStaticBufferSize = 64444; const int DefaultBufferSize = 65536; // use 64K default buffer. @@ -495,7 +495,7 @@ public static void EnableNullableFormat() where T : struct RegisterTryFormat(CreateNullableFormatter()); } - public static class FormatterCache + internal static class FormatterCache { public static TryFormat TryFormatDelegate; static FormatterCache() diff --git a/src/SmartFormat.ZString/repo/src/ZString/ZString.Concat.cs b/src/SmartFormat.ZString/repo/src/ZString/ZString.Concat.cs index b97088b8..9f683014 100644 --- a/src/SmartFormat.ZString/repo/src/ZString/ZString.Concat.cs +++ b/src/SmartFormat.ZString/repo/src/ZString/ZString.Concat.cs @@ -2,7 +2,7 @@ namespace Cysharp.Text { - public static partial class ZString + internal static partial class ZString { /// Concatenates the string representation of some specified objects. public static string Concat(T1 arg1) diff --git a/src/SmartFormat.ZString/repo/src/ZString/ZString.Concat.tt b/src/SmartFormat.ZString/repo/src/ZString/ZString.Concat.tt index 7c9f854e..1a6b5aa3 100644 --- a/src/SmartFormat.ZString/repo/src/ZString/ZString.Concat.tt +++ b/src/SmartFormat.ZString/repo/src/ZString/ZString.Concat.tt @@ -9,7 +9,7 @@ using System.Runtime.CompilerServices; namespace Cysharp.Text { - public static partial class ZString + internal static partial class ZString { <# for(var i = 1; i <= TypeParamMax; i++) { #> /// Concatenates the string representation of some specified objects. diff --git a/src/SmartFormat.ZString/repo/src/ZString/ZString.Format.cs b/src/SmartFormat.ZString/repo/src/ZString/ZString.Format.cs index 5924b65a..3829a4b3 100644 --- a/src/SmartFormat.ZString/repo/src/ZString/ZString.Format.cs +++ b/src/SmartFormat.ZString/repo/src/ZString/ZString.Format.cs @@ -3,7 +3,7 @@ namespace Cysharp.Text { - public static partial class ZString + internal static partial class ZString { /// Replaces one or more format items in a string with the string representation of some specified objects. [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/SmartFormat.ZString/repo/src/ZString/ZString.Format.tt b/src/SmartFormat.ZString/repo/src/ZString/ZString.Format.tt index acaea63b..bdf4a063 100644 --- a/src/SmartFormat.ZString/repo/src/ZString/ZString.Format.tt +++ b/src/SmartFormat.ZString/repo/src/ZString/ZString.Format.tt @@ -10,7 +10,7 @@ using System; namespace Cysharp.Text { - public static partial class ZString + internal static partial class ZString { <# for(var i = 1; i <= TypeParamMax; i++) { #> /// Replaces one or more format items in a string with the string representation of some specified objects. diff --git a/src/SmartFormat.ZString/repo/src/ZString/ZString.Prepare.cs b/src/SmartFormat.ZString/repo/src/ZString/ZString.Prepare.cs index 90a309aa..1b1b13af 100644 --- a/src/SmartFormat.ZString/repo/src/ZString/ZString.Prepare.cs +++ b/src/SmartFormat.ZString/repo/src/ZString/ZString.Prepare.cs @@ -2,7 +2,7 @@ namespace Cysharp.Text { - public static partial class ZString + internal static partial class ZString { /// Prepare string format to avoid parse template in each operation. public static Utf16PreparedFormat PrepareUtf16(string format) diff --git a/src/SmartFormat.ZString/repo/src/ZString/ZString.Prepare.tt b/src/SmartFormat.ZString/repo/src/ZString/ZString.Prepare.tt index ac962cb3..b8caa1b2 100644 --- a/src/SmartFormat.ZString/repo/src/ZString/ZString.Prepare.tt +++ b/src/SmartFormat.ZString/repo/src/ZString/ZString.Prepare.tt @@ -9,7 +9,7 @@ using System.Runtime.CompilerServices; namespace Cysharp.Text { - public static partial class ZString + internal static partial class ZString { <# for(var i = 1; i <= TypeParamMax; i++) { #> /// Prepare string format to avoid parse template in each operation. diff --git a/src/SmartFormat.ZString/repo/src/ZString/ZString.Utf8Format.cs b/src/SmartFormat.ZString/repo/src/ZString/ZString.Utf8Format.cs index ce267b90..c8f4879f 100644 --- a/src/SmartFormat.ZString/repo/src/ZString/ZString.Utf8Format.cs +++ b/src/SmartFormat.ZString/repo/src/ZString/ZString.Utf8Format.cs @@ -6,7 +6,7 @@ namespace Cysharp.Text { - public static partial class ZString + internal static partial class ZString { /// Replaces one or more format items in a string with the string representation of some specified values. public static void Utf8Format(IBufferWriter bufferWriter, string format, T1 arg1) diff --git a/src/SmartFormat.ZString/repo/src/ZString/ZString.Utf8Format.tt b/src/SmartFormat.ZString/repo/src/ZString/ZString.Utf8Format.tt index 4382e5c8..7db1b653 100644 --- a/src/SmartFormat.ZString/repo/src/ZString/ZString.Utf8Format.tt +++ b/src/SmartFormat.ZString/repo/src/ZString/ZString.Utf8Format.tt @@ -13,7 +13,7 @@ using static Cysharp.Text.Utf8ValueStringBuilder; namespace Cysharp.Text { - public static partial class ZString + internal static partial class ZString { <# for(var i = 1; i <= TypeParamMax; i++) { #> /// Replaces one or more format items in a string with the string representation of some specified values. diff --git a/src/SmartFormat.ZString/repo/src/ZString/ZString.cs b/src/SmartFormat.ZString/repo/src/ZString/ZString.cs index c0db0a7d..be884cda 100644 --- a/src/SmartFormat.ZString/repo/src/ZString/ZString.cs +++ b/src/SmartFormat.ZString/repo/src/ZString/ZString.cs @@ -7,7 +7,7 @@ namespace Cysharp.Text { - public static partial class ZString + internal static partial class ZString { static Encoding UTF8NoBom = new UTF8Encoding(false); diff --git a/src/SmartFormat.ZString/repo/src/ZString/ZStringWriter.cs b/src/SmartFormat.ZString/repo/src/ZString/ZStringWriter.cs index c89b89e2..b8619918 100644 --- a/src/SmartFormat.ZString/repo/src/ZString/ZStringWriter.cs +++ b/src/SmartFormat.ZString/repo/src/ZString/ZStringWriter.cs @@ -13,7 +13,7 @@ namespace Cysharp.Text /// /// It's important to make sure the writer is always properly disposed. /// - public sealed class ZStringWriter : TextWriter + internal sealed class ZStringWriter : TextWriter { private Utf16ValueStringBuilder sb; private bool isOpen; diff --git a/src/SmartFormat.sln b/src/SmartFormat.sln index 69284e82..15ee1006 100644 --- a/src/SmartFormat.sln +++ b/src/SmartFormat.sln @@ -25,6 +25,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SmartFormat.Net", "SmartFor EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SmartFormat.Extensions.Time", "SmartFormat.Extensions.Time\SmartFormat.Extensions.Time.csproj", "{62553041-4606-47FC-B44E-8D6D51F23E22}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SmartFormat.ZString.Tests", "SmartFormat.ZString.Tests\SmartFormat.ZString.Tests.csproj", "{72652F62-537C-4C57-9D2A-4FD6C4BF8425}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -121,6 +123,14 @@ Global {62553041-4606-47FC-B44E-8D6D51F23E22}.Release|Any CPU.Build.0 = Release|Any CPU {62553041-4606-47FC-B44E-8D6D51F23E22}.Release|x86.ActiveCfg = Release|Any CPU {62553041-4606-47FC-B44E-8D6D51F23E22}.Release|x86.Build.0 = Release|Any CPU + {72652F62-537C-4C57-9D2A-4FD6C4BF8425}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {72652F62-537C-4C57-9D2A-4FD6C4BF8425}.Debug|Any CPU.Build.0 = Debug|Any CPU + {72652F62-537C-4C57-9D2A-4FD6C4BF8425}.Debug|x86.ActiveCfg = Debug|Any CPU + {72652F62-537C-4C57-9D2A-4FD6C4BF8425}.Debug|x86.Build.0 = Debug|Any CPU + {72652F62-537C-4C57-9D2A-4FD6C4BF8425}.Release|Any CPU.ActiveCfg = Release|Any CPU + {72652F62-537C-4C57-9D2A-4FD6C4BF8425}.Release|Any CPU.Build.0 = Release|Any CPU + {72652F62-537C-4C57-9D2A-4FD6C4BF8425}.Release|x86.ActiveCfg = Release|Any CPU + {72652F62-537C-4C57-9D2A-4FD6C4BF8425}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE