Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 33 additions & 32 deletions src/ZString.Unity/Assets/Scripts/ZString/PreparedFormat.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Text;
using System.Buffers;

Expand All @@ -11,7 +12,7 @@ public sealed partial class Utf16PreparedFormat<T1>

readonly Utf16FormatSegment[] segments;

public Utf16PreparedFormat(string format)
public Utf16PreparedFormat([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format)
{
this.FormatString = format;
this.segments = PreparedFormatHelper.Utf16Parse(format);
Expand Down Expand Up @@ -76,7 +77,7 @@ public sealed partial class Utf16PreparedFormat<T1, T2>

readonly Utf16FormatSegment[] segments;

public Utf16PreparedFormat(string format)
public Utf16PreparedFormat([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format)
{
this.FormatString = format;
this.segments = PreparedFormatHelper.Utf16Parse(format);
Expand Down Expand Up @@ -146,7 +147,7 @@ public sealed partial class Utf16PreparedFormat<T1, T2, T3>

readonly Utf16FormatSegment[] segments;

public Utf16PreparedFormat(string format)
public Utf16PreparedFormat([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format)
{
this.FormatString = format;
this.segments = PreparedFormatHelper.Utf16Parse(format);
Expand Down Expand Up @@ -221,7 +222,7 @@ public sealed partial class Utf16PreparedFormat<T1, T2, T3, T4>

readonly Utf16FormatSegment[] segments;

public Utf16PreparedFormat(string format)
public Utf16PreparedFormat([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format)
{
this.FormatString = format;
this.segments = PreparedFormatHelper.Utf16Parse(format);
Expand Down Expand Up @@ -301,7 +302,7 @@ public sealed partial class Utf16PreparedFormat<T1, T2, T3, T4, T5>

readonly Utf16FormatSegment[] segments;

public Utf16PreparedFormat(string format)
public Utf16PreparedFormat([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format)
{
this.FormatString = format;
this.segments = PreparedFormatHelper.Utf16Parse(format);
Expand Down Expand Up @@ -386,7 +387,7 @@ public sealed partial class Utf16PreparedFormat<T1, T2, T3, T4, T5, T6>

readonly Utf16FormatSegment[] segments;

public Utf16PreparedFormat(string format)
public Utf16PreparedFormat([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format)
{
this.FormatString = format;
this.segments = PreparedFormatHelper.Utf16Parse(format);
Expand Down Expand Up @@ -476,7 +477,7 @@ public sealed partial class Utf16PreparedFormat<T1, T2, T3, T4, T5, T6, T7>

readonly Utf16FormatSegment[] segments;

public Utf16PreparedFormat(string format)
public Utf16PreparedFormat([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format)
{
this.FormatString = format;
this.segments = PreparedFormatHelper.Utf16Parse(format);
Expand Down Expand Up @@ -571,7 +572,7 @@ public sealed partial class Utf16PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8>

readonly Utf16FormatSegment[] segments;

public Utf16PreparedFormat(string format)
public Utf16PreparedFormat([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format)
{
this.FormatString = format;
this.segments = PreparedFormatHelper.Utf16Parse(format);
Expand Down Expand Up @@ -671,7 +672,7 @@ public sealed partial class Utf16PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8,

readonly Utf16FormatSegment[] segments;

public Utf16PreparedFormat(string format)
public Utf16PreparedFormat([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format)
{
this.FormatString = format;
this.segments = PreparedFormatHelper.Utf16Parse(format);
Expand Down Expand Up @@ -776,7 +777,7 @@ public sealed partial class Utf16PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8,

readonly Utf16FormatSegment[] segments;

public Utf16PreparedFormat(string format)
public Utf16PreparedFormat([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format)
{
this.FormatString = format;
this.segments = PreparedFormatHelper.Utf16Parse(format);
Expand Down Expand Up @@ -886,7 +887,7 @@ public sealed partial class Utf16PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8,

readonly Utf16FormatSegment[] segments;

public Utf16PreparedFormat(string format)
public Utf16PreparedFormat([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format)
{
this.FormatString = format;
this.segments = PreparedFormatHelper.Utf16Parse(format);
Expand Down Expand Up @@ -1001,7 +1002,7 @@ public sealed partial class Utf16PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8,

readonly Utf16FormatSegment[] segments;

public Utf16PreparedFormat(string format)
public Utf16PreparedFormat([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format)
{
this.FormatString = format;
this.segments = PreparedFormatHelper.Utf16Parse(format);
Expand Down Expand Up @@ -1121,7 +1122,7 @@ public sealed partial class Utf16PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8,

readonly Utf16FormatSegment[] segments;

public Utf16PreparedFormat(string format)
public Utf16PreparedFormat([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format)
{
this.FormatString = format;
this.segments = PreparedFormatHelper.Utf16Parse(format);
Expand Down Expand Up @@ -1246,7 +1247,7 @@ public sealed partial class Utf16PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8,

readonly Utf16FormatSegment[] segments;

public Utf16PreparedFormat(string format)
public Utf16PreparedFormat([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format)
{
this.FormatString = format;
this.segments = PreparedFormatHelper.Utf16Parse(format);
Expand Down Expand Up @@ -1376,7 +1377,7 @@ public sealed partial class Utf16PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8,

readonly Utf16FormatSegment[] segments;

public Utf16PreparedFormat(string format)
public Utf16PreparedFormat([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format)
{
this.FormatString = format;
this.segments = PreparedFormatHelper.Utf16Parse(format);
Expand Down Expand Up @@ -1511,7 +1512,7 @@ public sealed partial class Utf16PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8,

readonly Utf16FormatSegment[] segments;

public Utf16PreparedFormat(string format)
public Utf16PreparedFormat([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format)
{
this.FormatString = format;
this.segments = PreparedFormatHelper.Utf16Parse(format);
Expand Down Expand Up @@ -1652,7 +1653,7 @@ public sealed partial class Utf8PreparedFormat<T1>
readonly Utf8FormatSegment[] segments;
readonly byte[] utf8PreEncodedbuffer;

public Utf8PreparedFormat(string format)
public Utf8PreparedFormat([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format)
{
this.FormatString = format;
this.segments = PreparedFormatHelper.Utf8Parse(format, out utf8PreEncodedbuffer);
Expand Down Expand Up @@ -1718,7 +1719,7 @@ public sealed partial class Utf8PreparedFormat<T1, T2>
readonly Utf8FormatSegment[] segments;
readonly byte[] utf8PreEncodedbuffer;

public Utf8PreparedFormat(string format)
public Utf8PreparedFormat([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format)
{
this.FormatString = format;
this.segments = PreparedFormatHelper.Utf8Parse(format, out utf8PreEncodedbuffer);
Expand Down Expand Up @@ -1789,7 +1790,7 @@ public sealed partial class Utf8PreparedFormat<T1, T2, T3>
readonly Utf8FormatSegment[] segments;
readonly byte[] utf8PreEncodedbuffer;

public Utf8PreparedFormat(string format)
public Utf8PreparedFormat([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format)
{
this.FormatString = format;
this.segments = PreparedFormatHelper.Utf8Parse(format, out utf8PreEncodedbuffer);
Expand Down Expand Up @@ -1865,7 +1866,7 @@ public sealed partial class Utf8PreparedFormat<T1, T2, T3, T4>
readonly Utf8FormatSegment[] segments;
readonly byte[] utf8PreEncodedbuffer;

public Utf8PreparedFormat(string format)
public Utf8PreparedFormat([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format)
{
this.FormatString = format;
this.segments = PreparedFormatHelper.Utf8Parse(format, out utf8PreEncodedbuffer);
Expand Down Expand Up @@ -1946,7 +1947,7 @@ public sealed partial class Utf8PreparedFormat<T1, T2, T3, T4, T5>
readonly Utf8FormatSegment[] segments;
readonly byte[] utf8PreEncodedbuffer;

public Utf8PreparedFormat(string format)
public Utf8PreparedFormat([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format)
{
this.FormatString = format;
this.segments = PreparedFormatHelper.Utf8Parse(format, out utf8PreEncodedbuffer);
Expand Down Expand Up @@ -2032,7 +2033,7 @@ public sealed partial class Utf8PreparedFormat<T1, T2, T3, T4, T5, T6>
readonly Utf8FormatSegment[] segments;
readonly byte[] utf8PreEncodedbuffer;

public Utf8PreparedFormat(string format)
public Utf8PreparedFormat([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format)
{
this.FormatString = format;
this.segments = PreparedFormatHelper.Utf8Parse(format, out utf8PreEncodedbuffer);
Expand Down Expand Up @@ -2123,7 +2124,7 @@ public sealed partial class Utf8PreparedFormat<T1, T2, T3, T4, T5, T6, T7>
readonly Utf8FormatSegment[] segments;
readonly byte[] utf8PreEncodedbuffer;

public Utf8PreparedFormat(string format)
public Utf8PreparedFormat([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format)
{
this.FormatString = format;
this.segments = PreparedFormatHelper.Utf8Parse(format, out utf8PreEncodedbuffer);
Expand Down Expand Up @@ -2219,7 +2220,7 @@ public sealed partial class Utf8PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8>
readonly Utf8FormatSegment[] segments;
readonly byte[] utf8PreEncodedbuffer;

public Utf8PreparedFormat(string format)
public Utf8PreparedFormat([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format)
{
this.FormatString = format;
this.segments = PreparedFormatHelper.Utf8Parse(format, out utf8PreEncodedbuffer);
Expand Down Expand Up @@ -2320,7 +2321,7 @@ public sealed partial class Utf8PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T
readonly Utf8FormatSegment[] segments;
readonly byte[] utf8PreEncodedbuffer;

public Utf8PreparedFormat(string format)
public Utf8PreparedFormat([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format)
{
this.FormatString = format;
this.segments = PreparedFormatHelper.Utf8Parse(format, out utf8PreEncodedbuffer);
Expand Down Expand Up @@ -2426,7 +2427,7 @@ public sealed partial class Utf8PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T
readonly Utf8FormatSegment[] segments;
readonly byte[] utf8PreEncodedbuffer;

public Utf8PreparedFormat(string format)
public Utf8PreparedFormat([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format)
{
this.FormatString = format;
this.segments = PreparedFormatHelper.Utf8Parse(format, out utf8PreEncodedbuffer);
Expand Down Expand Up @@ -2537,7 +2538,7 @@ public sealed partial class Utf8PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T
readonly Utf8FormatSegment[] segments;
readonly byte[] utf8PreEncodedbuffer;

public Utf8PreparedFormat(string format)
public Utf8PreparedFormat([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format)
{
this.FormatString = format;
this.segments = PreparedFormatHelper.Utf8Parse(format, out utf8PreEncodedbuffer);
Expand Down Expand Up @@ -2653,7 +2654,7 @@ public sealed partial class Utf8PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T
readonly Utf8FormatSegment[] segments;
readonly byte[] utf8PreEncodedbuffer;

public Utf8PreparedFormat(string format)
public Utf8PreparedFormat([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format)
{
this.FormatString = format;
this.segments = PreparedFormatHelper.Utf8Parse(format, out utf8PreEncodedbuffer);
Expand Down Expand Up @@ -2774,7 +2775,7 @@ public sealed partial class Utf8PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T
readonly Utf8FormatSegment[] segments;
readonly byte[] utf8PreEncodedbuffer;

public Utf8PreparedFormat(string format)
public Utf8PreparedFormat([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format)
{
this.FormatString = format;
this.segments = PreparedFormatHelper.Utf8Parse(format, out utf8PreEncodedbuffer);
Expand Down Expand Up @@ -2900,7 +2901,7 @@ public sealed partial class Utf8PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T
readonly Utf8FormatSegment[] segments;
readonly byte[] utf8PreEncodedbuffer;

public Utf8PreparedFormat(string format)
public Utf8PreparedFormat([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format)
{
this.FormatString = format;
this.segments = PreparedFormatHelper.Utf8Parse(format, out utf8PreEncodedbuffer);
Expand Down Expand Up @@ -3031,7 +3032,7 @@ public sealed partial class Utf8PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T
readonly Utf8FormatSegment[] segments;
readonly byte[] utf8PreEncodedbuffer;

public Utf8PreparedFormat(string format)
public Utf8PreparedFormat([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format)
{
this.FormatString = format;
this.segments = PreparedFormatHelper.Utf8Parse(format, out utf8PreEncodedbuffer);
Expand Down Expand Up @@ -3167,7 +3168,7 @@ public sealed partial class Utf8PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T
readonly Utf8FormatSegment[] segments;
readonly byte[] utf8PreEncodedbuffer;

public Utf8PreparedFormat(string format)
public Utf8PreparedFormat([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format)
{
this.FormatString = format;
this.segments = PreparedFormatHelper.Utf8Parse(format, out utf8PreEncodedbuffer);
Expand Down
22 changes: 22 additions & 0 deletions src/ZString.Unity/Assets/Scripts/ZString/StringSyntaxAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#if !NET7_0_OR_GREATER

namespace System.Diagnostics.CodeAnalysis
{
// Polyfill: lets IDEs recognize composite format strings on targets older than .NET 7.
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
internal sealed class StringSyntaxAttribute : Attribute
{
public const string CompositeFormat = "CompositeFormat";

public StringSyntaxAttribute(string syntax)
{
Syntax = syntax;
Arguments = Array.Empty<object?>();
}

public string Syntax { get; }
public object?[] Arguments { get; }
}
}

#endif

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading