Skip to content

Commit

Permalink
fix: Generate appropriate XML documentation for resource name operators
Browse files Browse the repository at this point in the history
There's nothing to inherit, so inheritdoc is inappropriate.

Fixes #649.

Tests in next commit.
  • Loading branch information
jskeet committed Jul 26, 2023
1 parent bb77a24 commit 5f22923
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Google.Api.Generator/Generation/ResourceNamesGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,11 @@ private OperatorDeclarationSyntax EqualityOperator()
var b = Parameter(_ctx.Type(_def.ResourceNameTyp), "b");
return OperatorMethod(_ctx.Type<bool>(), "==")(a, b)
.WithBody(This.Call(nameof(object.ReferenceEquals))(a, b).Or(Parens(a.Call(EqualsIEquatable(), conditional: true)(b).NullCoalesce(false))))
.WithXmlDoc(XmlDoc.InheritDoc);
.WithXmlDoc(XmlDoc.Summary("Determines whether two specified resource names have the same value."),
XmlDoc.Param(a, "The first resource name to compare, or null."),
XmlDoc.Param(b, "The second resource name to compare, or null."),
XmlDoc.Returns("true if the value of ", a, " is the same as the value of ", b, "; otherwise, false.")
);
}

private OperatorDeclarationSyntax InequalityOperator()
Expand All @@ -497,7 +501,11 @@ private OperatorDeclarationSyntax InequalityOperator()
var b = Parameter(_ctx.Type(_def.ResourceNameTyp), "b");
return OperatorMethod(_ctx.Type<bool>(), "!=")(a, b)
.WithBody(Not(Parens(a.Equality(b))))
.WithXmlDoc(XmlDoc.InheritDoc);
.WithXmlDoc(XmlDoc.Summary("Determines whether two specified resource names have different values."),
XmlDoc.Param(a, "The first resource name to compare, or null."),
XmlDoc.Param(b, "The second resource name to compare, or null."),
XmlDoc.Returns("true if the value of ", a, " is different from the value of ", b, "; otherwise, false.")
);
}
}

Expand Down

0 comments on commit 5f22923

Please sign in to comment.