@@ -68,7 +68,8 @@ this MethodDeclarationSyntax node
6868 && (
6969 y . ArgumentList ? . Arguments . All ( z =>
7070 z . NameEquals ? . Name . ToString ( ) != "EntryPoint"
71- ) ?? true
71+ )
72+ ?? true
7273 )
7374 ? y . AddArgumentListArguments (
7475 AttributeArgument (
@@ -264,6 +265,22 @@ public static bool TryGetNativeName(
264265 return nativeName != null ;
265266 }
266267
268+ /// <summary>
269+ /// Ensures the attribute list contains the [Flags] attribute.
270+ /// </summary>
271+ public static SyntaxList < AttributeListSyntax > WithFlags (
272+ this IEnumerable < AttributeListSyntax > attributeLists
273+ )
274+ {
275+ var list = List ( [ .. attributeLists ] ) ;
276+ if ( list . ContainsAttribute ( "System.Flags" ) )
277+ {
278+ return list ;
279+ }
280+
281+ return list . Add ( AttributeList ( SingletonSeparatedList ( Attribute ( IdentifierName ( "Flags" ) ) ) ) ) ;
282+ }
283+
267284 /// <summary>
268285 /// Sets or replaces the native name attribute in the given attribute list.
269286 /// </summary>
@@ -272,23 +289,19 @@ public static SyntaxList<AttributeListSyntax> WithNativeName(
272289 string nativeName
273290 )
274291 {
275- var nativeNameAttribute = AttributeList (
276- [
277- Attribute (
278- IdentifierName ( "NativeName" ) ,
279- AttributeArgumentList (
280- [
281- AttributeArgument (
282- LiteralExpression (
283- SyntaxKind . StringLiteralExpression ,
284- Literal ( $ "\" { nativeName } \" ", nativeName )
285- )
286- ) ,
287- ]
288- )
289- ) ,
290- ]
291- ) ;
292+ var nativeNameAttribute = AttributeList ( [
293+ Attribute (
294+ IdentifierName ( "NativeName" ) ,
295+ AttributeArgumentList ( [
296+ AttributeArgument (
297+ LiteralExpression (
298+ SyntaxKind . StringLiteralExpression ,
299+ Literal ( $ "\" { nativeName } \" ", nativeName )
300+ )
301+ ) ,
302+ ] )
303+ ) ,
304+ ] ) ;
292305
293306 return List (
294307 attributeLists
0 commit comments