Skip to content

Commit 95c04fc

Browse files
committed
feat: add Method impl feature and the default value fix.
1 parent 4c3ba54 commit 95c04fc

2 files changed

Lines changed: 22 additions & 5 deletions

File tree

src/libraries/TedToolkit.RoslynHelper/Extensions/SyntaxExtensions.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Microsoft.CodeAnalysis;
1+
using System.Runtime.CompilerServices;
2+
using Microsoft.CodeAnalysis;
23
using Microsoft.CodeAnalysis.CSharp;
34
using Microsoft.CodeAnalysis.CSharp.Syntax;
45
using TedToolkit.RoslynHelper.Names;
@@ -133,7 +134,25 @@ public static AttributeListSyntax GeneratedCodeAttribute(Type generator)
133134
/// <returns></returns>
134135
public static AttributeSyntax NonUserCodeAttribute()
135136
{
136-
return Attribute(IdentifierName("global::System.Diagnostics.DebuggerNonUserCode"));
137+
return Attribute(IdentifierName("global::System.Diagnostics.DebuggerNonUserCodeAttribute"));
138+
}
139+
140+
/// <summary>
141+
/// Method Impl Attribute
142+
/// </summary>
143+
/// <param name="methodImplOptions"></param>
144+
/// <returns></returns>
145+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
146+
public static AttributeSyntax MethodImplAttribute(MethodImplOptions methodImplOptions)
147+
{
148+
return Attribute(IdentifierName("global::System.Runtime.CompilerServices.MethodImplAttribute"))
149+
.WithArgumentList(AttributeArgumentList(
150+
[
151+
AttributeArgument(MemberAccessExpression(
152+
SyntaxKind.SimpleMemberAccessExpression,
153+
IdentifierName("global::System.Runtime.CompilerServices.MethodImplOptions"),
154+
IdentifierName("AggressiveInlining")))
155+
]));
137156
}
138157

139158
/// <summary>

src/libraries/TedToolkit.RoslynHelper/Names/ParameterName.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,7 @@ public ParameterSyntax ParameterSyntax
8989

9090
if (value == null)
9191
{
92-
return type.IsValueType
93-
? LiteralExpression(SyntaxKind.DefaultLiteralExpression)
94-
: LiteralExpression(SyntaxKind.NullLiteralExpression);
92+
return LiteralExpression(SyntaxKind.DefaultLiteralExpression);
9593
}
9694

9795
switch (type.SpecialType)

0 commit comments

Comments
 (0)