Skip to content

Commit

Permalink
Ignore property with [IgnoreDataMember] attribute
Browse files Browse the repository at this point in the history
That atribute is used by WCF to ignore objects.
  • Loading branch information
Rodrigo Cesar committed May 29, 2024
1 parent c02a4d3 commit e2dd0ba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/csharp-models-to-json/ModelCollector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ private static Model CreateModel(TypeDeclarationSyntax node)
private static bool IsIgnored(SyntaxList<AttributeListSyntax> propertyAttributeLists) =>
propertyAttributeLists.Any(attributeList =>
attributeList.Attributes.Any(attribute =>
attribute.Name.ToString().Equals("JsonIgnore")));
attribute.Name.ToString().Equals("JsonIgnore") ||
attribute.Name.ToString().Equals("IgnoreDataMember")));

private static bool IsAccessible(SyntaxTokenList modifiers) => modifiers.All(modifier =>
modifier.ToString() != "const" &&
Expand Down
3 changes: 3 additions & 0 deletions lib/csharp-models-to-json_test/ModelCollector_test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ public class A : IController<Controller>
[JsonIgnore]
public string Ignored { get; set; }
[IgnoreDataMember]
public string Ignored2 { get; set; }
public void AMember()
{
}
Expand Down

0 comments on commit e2dd0ba

Please sign in to comment.