Skip to content

Commit c2bb4e0

Browse files
authored
Reorder methods (#151)
* Reorder methods * Update snapshots
1 parent d8d6991 commit c2bb4e0

File tree

42 files changed

+515
-515
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+515
-515
lines changed

src/NetEscapades.EnumGenerators/SourceGenerationHelper.cs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,34 @@ public static bool HasFlagFast(this
305305
""");
306306
}
307307

308+
sb.Append(
309+
"""
310+
311+
312+
/// <summary>
313+
/// Cast a value of <see cref="
314+
""").Append(fullyQualifiedName).Append(@""" /> to the underlying type (<c>")
315+
.Append(enumToGenerate.UnderlyingType).Append(
316+
"""
317+
</c>).
318+
/// This is mainly a convenience method.
319+
/// </summary>
320+
/// <returns>The value of <see cref="
321+
""").Append(fullyQualifiedName).Append(
322+
"""
323+
" /> cast to the underlying type.</returns>
324+
public static
325+
""").Append(enumToGenerate.UnderlyingType).Append(" AsUnderlyingType(this ").Append(fullyQualifiedName).Append(
326+
"""
327+
value)
328+
{
329+
return (
330+
""").Append(enumToGenerate.UnderlyingType).Append(
331+
"""
332+
) value;
333+
}
334+
""");
335+
308336
sb.Append(
309337
"""
310338
@@ -338,34 +366,6 @@ public static bool IsDefined(
338366
};
339367
""");
340368

341-
sb.Append(
342-
"""
343-
344-
345-
/// <summary>
346-
/// Cast a value of <see cref="
347-
""").Append(fullyQualifiedName).Append(@""" /> to the underlying type (<c>")
348-
.Append(enumToGenerate.UnderlyingType).Append(
349-
"""
350-
</c>).
351-
/// This is mainly a convenience method.
352-
/// </summary>
353-
/// <returns>The value of <see cref="
354-
""").Append(fullyQualifiedName).Append(
355-
"""
356-
" /> cast to the underlying type.</returns>
357-
public static
358-
""").Append(enumToGenerate.UnderlyingType).Append(" AsUnderlyingType(this ").Append(fullyQualifiedName).Append(
359-
"""
360-
value)
361-
{
362-
return (
363-
""").Append(enumToGenerate.UnderlyingType).Append(
364-
"""
365-
) value;
366-
}
367-
""");
368-
369369
sb.Append(
370370
"""
371371

tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsForFlagsEnum_Params.verified.txt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//------------------------------------------------------------------------------
1+
//------------------------------------------------------------------------------
22
// <auto-generated>
33
// This code was generated by the NetEscapades.EnumGenerators source generator
44
//
@@ -69,6 +69,16 @@ namespace MyTestNameSpace
6969
public static bool HasFlagFast(this global::MyTestNameSpace.MyEnum value, global::MyTestNameSpace.MyEnum flag)
7070
=> flag == 0 ? true : (value & flag) == flag;
7171

72+
/// <summary>
73+
/// Cast a value of <see cref="global::MyTestNameSpace.MyEnum" /> to the underlying type (<c>int</c>).
74+
/// This is mainly a convenience method.
75+
/// </summary>
76+
/// <returns>The value of <see cref="global::MyTestNameSpace.MyEnum" /> cast to the underlying type.</returns>
77+
public static int AsUnderlyingType(this global::MyTestNameSpace.MyEnum value)
78+
{
79+
return (int) value;
80+
}
81+
7282
/// <summary>
7383
/// Returns a boolean telling whether the given enum value exists in the enumeration.
7484
/// </summary>
@@ -83,16 +93,6 @@ namespace MyTestNameSpace
8393
_ => false,
8494
};
8595

86-
/// <summary>
87-
/// Cast a value of <see cref="global::MyTestNameSpace.MyEnum" /> to the underlying type (<c>int</c>).
88-
/// This is mainly a convenience method.
89-
/// </summary>
90-
/// <returns>The value of <see cref="global::MyTestNameSpace.MyEnum" /> cast to the underlying type.</returns>
91-
public static int AsUnderlyingType(this global::MyTestNameSpace.MyEnum value)
92-
{
93-
return (int) value;
94-
}
95-
9696
/// <summary>
9797
/// Returns a boolean telling whether an enum with the given name exists in the enumeration.
9898
/// </summary>

tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsInChildNamespace.verified.txt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//------------------------------------------------------------------------------
1+
//------------------------------------------------------------------------------
22
// <auto-generated>
33
// This code was generated by the NetEscapades.EnumGenerators source generator
44
//
@@ -56,6 +56,16 @@ namespace MyTestNameSpace
5656
private static string ToStringFastWithMetadata(this global::MyTestNameSpace.MyEnum value)
5757
=> value.ToStringFast();
5858

59+
/// <summary>
60+
/// Cast a value of <see cref="global::MyTestNameSpace.MyEnum" /> to the underlying type (<c>int</c>).
61+
/// This is mainly a convenience method.
62+
/// </summary>
63+
/// <returns>The value of <see cref="global::MyTestNameSpace.MyEnum" /> cast to the underlying type.</returns>
64+
public static int AsUnderlyingType(this global::MyTestNameSpace.MyEnum value)
65+
{
66+
return (int) value;
67+
}
68+
5969
/// <summary>
6070
/// Returns a boolean telling whether the given enum value exists in the enumeration.
6171
/// </summary>
@@ -69,16 +79,6 @@ namespace MyTestNameSpace
6979
_ => false,
7080
};
7181

72-
/// <summary>
73-
/// Cast a value of <see cref="global::MyTestNameSpace.MyEnum" /> to the underlying type (<c>int</c>).
74-
/// This is mainly a convenience method.
75-
/// </summary>
76-
/// <returns>The value of <see cref="global::MyTestNameSpace.MyEnum" /> cast to the underlying type.</returns>
77-
public static int AsUnderlyingType(this global::MyTestNameSpace.MyEnum value)
78-
{
79-
return (int) value;
80-
}
81-
8282
/// <summary>
8383
/// Returns a boolean telling whether an enum with the given name exists in the enumeration.
8484
/// </summary>

tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsInGlobalNamespace.verified.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@
5454
private static string ToStringFastWithMetadata(this global::MyEnum value)
5555
=> value.ToStringFast();
5656

57+
/// <summary>
58+
/// Cast a value of <see cref="global::MyEnum" /> to the underlying type (<c>int</c>).
59+
/// This is mainly a convenience method.
60+
/// </summary>
61+
/// <returns>The value of <see cref="global::MyEnum" /> cast to the underlying type.</returns>
62+
public static int AsUnderlyingType(this global::MyEnum value)
63+
{
64+
return (int) value;
65+
}
66+
5767
/// <summary>
5868
/// Returns a boolean telling whether the given enum value exists in the enumeration.
5969
/// </summary>
@@ -67,16 +77,6 @@
6777
_ => false,
6878
};
6979

70-
/// <summary>
71-
/// Cast a value of <see cref="global::MyEnum" /> to the underlying type (<c>int</c>).
72-
/// This is mainly a convenience method.
73-
/// </summary>
74-
/// <returns>The value of <see cref="global::MyEnum" /> cast to the underlying type.</returns>
75-
public static int AsUnderlyingType(this global::MyEnum value)
76-
{
77-
return (int) value;
78-
}
79-
8080
/// <summary>
8181
/// Returns a boolean telling whether an enum with the given name exists in the enumeration.
8282
/// </summary>

tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsInNestedClass.verified.txt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//------------------------------------------------------------------------------
1+
//------------------------------------------------------------------------------
22
// <auto-generated>
33
// This code was generated by the NetEscapades.EnumGenerators source generator
44
//
@@ -56,6 +56,16 @@ namespace MyTestNameSpace
5656
private static string ToStringFastWithMetadata(this global::MyTestNameSpace.InnerClass.MyEnum value)
5757
=> value.ToStringFast();
5858

59+
/// <summary>
60+
/// Cast a value of <see cref="global::MyTestNameSpace.InnerClass.MyEnum" /> to the underlying type (<c>int</c>).
61+
/// This is mainly a convenience method.
62+
/// </summary>
63+
/// <returns>The value of <see cref="global::MyTestNameSpace.InnerClass.MyEnum" /> cast to the underlying type.</returns>
64+
public static int AsUnderlyingType(this global::MyTestNameSpace.InnerClass.MyEnum value)
65+
{
66+
return (int) value;
67+
}
68+
5969
/// <summary>
6070
/// Returns a boolean telling whether the given enum value exists in the enumeration.
6171
/// </summary>
@@ -69,16 +79,6 @@ namespace MyTestNameSpace
6979
_ => false,
7080
};
7181

72-
/// <summary>
73-
/// Cast a value of <see cref="global::MyTestNameSpace.InnerClass.MyEnum" /> to the underlying type (<c>int</c>).
74-
/// This is mainly a convenience method.
75-
/// </summary>
76-
/// <returns>The value of <see cref="global::MyTestNameSpace.InnerClass.MyEnum" /> cast to the underlying type.</returns>
77-
public static int AsUnderlyingType(this global::MyTestNameSpace.InnerClass.MyEnum value)
78-
{
79-
return (int) value;
80-
}
81-
8282
/// <summary>
8383
/// Returns a boolean telling whether an enum with the given name exists in the enumeration.
8484
/// </summary>

tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithCustomName.verified.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ namespace MyTestNameSpace
5656
private static string ToStringFastWithMetadata(this global::MyTestNameSpace.MyEnum value)
5757
=> value.ToStringFast();
5858

59+
/// <summary>
60+
/// Cast a value of <see cref="global::MyTestNameSpace.MyEnum" /> to the underlying type (<c>int</c>).
61+
/// This is mainly a convenience method.
62+
/// </summary>
63+
/// <returns>The value of <see cref="global::MyTestNameSpace.MyEnum" /> cast to the underlying type.</returns>
64+
public static int AsUnderlyingType(this global::MyTestNameSpace.MyEnum value)
65+
{
66+
return (int) value;
67+
}
68+
5969
/// <summary>
6070
/// Returns a boolean telling whether the given enum value exists in the enumeration.
6171
/// </summary>
@@ -69,16 +79,6 @@ namespace MyTestNameSpace
6979
_ => false,
7080
};
7181

72-
/// <summary>
73-
/// Cast a value of <see cref="global::MyTestNameSpace.MyEnum" /> to the underlying type (<c>int</c>).
74-
/// This is mainly a convenience method.
75-
/// </summary>
76-
/// <returns>The value of <see cref="global::MyTestNameSpace.MyEnum" /> cast to the underlying type.</returns>
77-
public static int AsUnderlyingType(this global::MyTestNameSpace.MyEnum value)
78-
{
79-
return (int) value;
80-
}
81-
8282
/// <summary>
8383
/// Returns a boolean telling whether an enum with the given name exists in the enumeration.
8484
/// </summary>

tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithCustomNames.verified.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,16 @@ namespace MyTestNameSpace
6565
_ => value.AsUnderlyingType().ToString(),
6666
};
6767

68+
/// <summary>
69+
/// Cast a value of <see cref="global::MyTestNameSpace.MyEnum" /> to the underlying type (<c>int</c>).
70+
/// This is mainly a convenience method.
71+
/// </summary>
72+
/// <returns>The value of <see cref="global::MyTestNameSpace.MyEnum" /> cast to the underlying type.</returns>
73+
public static int AsUnderlyingType(this global::MyTestNameSpace.MyEnum value)
74+
{
75+
return (int) value;
76+
}
77+
6878
/// <summary>
6979
/// Returns a boolean telling whether the given enum value exists in the enumeration.
7080
/// </summary>
@@ -80,16 +90,6 @@ namespace MyTestNameSpace
8090
_ => false,
8191
};
8292

83-
/// <summary>
84-
/// Cast a value of <see cref="global::MyTestNameSpace.MyEnum" /> to the underlying type (<c>int</c>).
85-
/// This is mainly a convenience method.
86-
/// </summary>
87-
/// <returns>The value of <see cref="global::MyTestNameSpace.MyEnum" /> cast to the underlying type.</returns>
88-
public static int AsUnderlyingType(this global::MyTestNameSpace.MyEnum value)
89-
{
90-
return (int) value;
91-
}
92-
9393
/// <summary>
9494
/// Returns a boolean telling whether an enum with the given name exists in the enumeration.
9595
/// </summary>

tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithCustomNamespace.verified.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ namespace A.B
5656
private static string ToStringFastWithMetadata(this global::MyTestNameSpace.MyEnum value)
5757
=> value.ToStringFast();
5858

59+
/// <summary>
60+
/// Cast a value of <see cref="global::MyTestNameSpace.MyEnum" /> to the underlying type (<c>int</c>).
61+
/// This is mainly a convenience method.
62+
/// </summary>
63+
/// <returns>The value of <see cref="global::MyTestNameSpace.MyEnum" /> cast to the underlying type.</returns>
64+
public static int AsUnderlyingType(this global::MyTestNameSpace.MyEnum value)
65+
{
66+
return (int) value;
67+
}
68+
5969
/// <summary>
6070
/// Returns a boolean telling whether the given enum value exists in the enumeration.
6171
/// </summary>
@@ -69,16 +79,6 @@ namespace A.B
6979
_ => false,
7080
};
7181

72-
/// <summary>
73-
/// Cast a value of <see cref="global::MyTestNameSpace.MyEnum" /> to the underlying type (<c>int</c>).
74-
/// This is mainly a convenience method.
75-
/// </summary>
76-
/// <returns>The value of <see cref="global::MyTestNameSpace.MyEnum" /> cast to the underlying type.</returns>
77-
public static int AsUnderlyingType(this global::MyTestNameSpace.MyEnum value)
78-
{
79-
return (int) value;
80-
}
81-
8282
/// <summary>
8383
/// Returns a boolean telling whether an enum with the given name exists in the enumeration.
8484
/// </summary>

tests/NetEscapades.EnumGenerators.Tests/Snapshots/EnumGeneratorTests.CanGenerateEnumExtensionsWithCustomNamespaceAndName.verified.txt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//------------------------------------------------------------------------------
1+
//------------------------------------------------------------------------------
22
// <auto-generated>
33
// This code was generated by the NetEscapades.EnumGenerators source generator
44
//
@@ -56,6 +56,16 @@ namespace A.B
5656
private static string ToStringFastWithMetadata(this global::MyTestNameSpace.MyEnum value)
5757
=> value.ToStringFast();
5858

59+
/// <summary>
60+
/// Cast a value of <see cref="global::MyTestNameSpace.MyEnum" /> to the underlying type (<c>int</c>).
61+
/// This is mainly a convenience method.
62+
/// </summary>
63+
/// <returns>The value of <see cref="global::MyTestNameSpace.MyEnum" /> cast to the underlying type.</returns>
64+
public static int AsUnderlyingType(this global::MyTestNameSpace.MyEnum value)
65+
{
66+
return (int) value;
67+
}
68+
5969
/// <summary>
6070
/// Returns a boolean telling whether the given enum value exists in the enumeration.
6171
/// </summary>
@@ -69,16 +79,6 @@ namespace A.B
6979
_ => false,
7080
};
7181

72-
/// <summary>
73-
/// Cast a value of <see cref="global::MyTestNameSpace.MyEnum" /> to the underlying type (<c>int</c>).
74-
/// This is mainly a convenience method.
75-
/// </summary>
76-
/// <returns>The value of <see cref="global::MyTestNameSpace.MyEnum" /> cast to the underlying type.</returns>
77-
public static int AsUnderlyingType(this global::MyTestNameSpace.MyEnum value)
78-
{
79-
return (int) value;
80-
}
81-
8282
/// <summary>
8383
/// Returns a boolean telling whether an enum with the given name exists in the enumeration.
8484
/// </summary>

0 commit comments

Comments
 (0)