Skip to content

Commit

Permalink
fix: enum field not retrieved
Browse files Browse the repository at this point in the history
  • Loading branch information
labbbirder committed Feb 23, 2024
1 parent fb475c2 commit f64afaa
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
12 changes: 6 additions & 6 deletions VSProj~/DirectAttribute.sg/AttributeReceiver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ internal class AttributeReceiver : ISyntaxReceiver
{
public class Record
{
public TypeDeclarationSyntax TypeDeclaration;
public BaseTypeDeclarationSyntax TypeDeclaration;
public bool confirmed = false;
public void Deconstruct(out TypeDeclarationSyntax td,out bool cf)
public void Deconstruct(out BaseTypeDeclarationSyntax td,out bool cf)
{
td = TypeDeclaration;
cf = confirmed;
Expand All @@ -27,9 +27,9 @@ public void OnVisitSyntaxNode(SyntaxNode syntaxNode)
{
if(syntaxNode is AttributeListSyntax)
{
var t = syntaxNode.FirstAncestorOrSelf<TypeDeclarationSyntax>();
//Debugger.Launch();
if(t != null)
var t = syntaxNode.FirstAncestorOrSelf<BaseTypeDeclarationSyntax>();
// Debugger.Launch();
if (t != null)
{
Append(t,true);
}
Expand All @@ -39,7 +39,7 @@ public void OnVisitSyntaxNode(SyntaxNode syntaxNode)
Append(td,false);
}
}
void Append(TypeDeclarationSyntax td, bool confirmed)
void Append(BaseTypeDeclarationSyntax td, bool confirmed)
{
var pre = TypeDeclarations.FirstOrDefault(d => d.TypeDeclaration.IsEquivalentTo(td));
if(pre != null)
Expand Down
9 changes: 9 additions & 0 deletions VSProj~/TestApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ public static void Main()
Console.WriteLine($"ga: {attr}");
}
}
public enum MyEnum
{
[Inject("Enum One")]
One,
[Inject("Enum 2")]
Two,
[Inject("Enum 3")]
Tytt,
}
internal class Foo
{
//[DirectRetrieve(typeof(Program))]
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "com.bbbirder.directattribute",
"description": "Retrieve attributes and subtypes efficiently, meanwhile, retrieve target type and member directly from an attribute",
"displayName": "Direct Attribute",
"version": "1.1.5",
"version": "1.1.6",
"hideInEditor": false,
"author": "bbbirder <[email protected]>"
}
Binary file modified plugin.unitypackage
Binary file not shown.

0 comments on commit f64afaa

Please sign in to comment.