File tree Expand file tree Collapse file tree 3 files changed +34
-2
lines changed
SeWzc.X11Sharp.SourceGenerator Expand file tree Collapse file tree 3 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,12 @@ namespace {{namespaceName}};
6969
7070 partial {{ keyword }} {{ typeDeclaration . Identifier }} : IComparable<{{ typeDeclaration . Identifier }} >
7171 {
72+ /// <inheritdoc />
73+ public override string ToString()
74+ {
75+ return $"0x{Id:X}";
76+ }
77+
7278 /// <inheritdoc />
7379 [MethodImpl(MethodImplOptions.AggressiveInlining)]
7480 public int CompareTo({{ typeDeclaration . Identifier }} other)
Original file line number Diff line number Diff line change 11using System . ComponentModel ;
2+ using System . Diagnostics . CodeAnalysis ;
23using System . Runtime . CompilerServices ;
34using System . Runtime . InteropServices ;
45
@@ -9,7 +10,7 @@ namespace SeWzc.X11Sharp.Structs;
910/// </summary>
1011/// <param name="Value">内部的 CLong 类型。</param>
1112[ EditorBrowsable ( EditorBrowsableState . Advanced ) ]
12- public readonly record struct Long ( CLong Value ) : IComparable < Long >
13+ public readonly record struct Long ( CLong Value ) : IComparable < Long > , IFormattable
1314{
1415 /// <summary>
1516 /// 使用 nint 构造 Long。
@@ -34,6 +35,18 @@ public int CompareTo(Long other)
3435 return Value . Value . CompareTo ( other . Value . Value ) ;
3536 }
3637
38+ /// <inheritdoc />
39+ public override string ToString ( )
40+ {
41+ return Value . Value . ToString ( ) ;
42+ }
43+
44+ /// <inheritdoc />
45+ public string ToString ( [ StringSyntax ( "NumericFormat" ) ] string ? format , IFormatProvider ? provider = null )
46+ {
47+ return Value . Value . ToString ( format , provider ) ;
48+ }
49+
3750 #region 运算符重载
3851
3952 // 强制转换就不用文档了
Original file line number Diff line number Diff line change 11using System . ComponentModel ;
2+ using System . Diagnostics . CodeAnalysis ;
23using System . Runtime . CompilerServices ;
34using System . Runtime . InteropServices ;
45
@@ -9,7 +10,7 @@ namespace SeWzc.X11Sharp.Structs;
910/// </summary>
1011/// <param name="Value">内部的 CULong 类型。</param>
1112[ EditorBrowsable ( EditorBrowsableState . Advanced ) ]
12- public readonly record struct ULong ( CULong Value ) : IComparable < ULong >
13+ public readonly record struct ULong ( CULong Value ) : IComparable < ULong > , IFormattable
1314{
1415 /// <summary>
1516 /// 使用 nuint 构造 ULong。
@@ -34,6 +35,18 @@ public int CompareTo(ULong other)
3435 return Value . Value . CompareTo ( other . Value . Value ) ;
3536 }
3637
38+ /// <inheritdoc />
39+ public override string ToString ( )
40+ {
41+ return Value . Value . ToString ( ) ;
42+ }
43+
44+ /// <inheritdoc />
45+ public string ToString ( [ StringSyntax ( "NumericFormat" ) ] string ? format , IFormatProvider ? provider = null )
46+ {
47+ return Value . Value . ToString ( format , provider ) ;
48+ }
49+
3750 #region 运算符重载
3851
3952 // 强制转换就不用文档了
You can’t perform that action at this time.
0 commit comments