diff --git a/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.cs b/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.cs index a8e2c76b..e11bbdb1 100644 --- a/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.cs +++ b/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.cs @@ -1040,7 +1040,7 @@ private static void AppendMockSubject_ImplementClass_AddEvent(StringBuilder sb, } sb.Append("\t\t/// "); + .Append(@event.Name).AppendLine("\" />"); sb.Append(@event.Attributes, "\t\t"); if (explicitInterfaceImplementation) { @@ -1123,9 +1123,8 @@ private static void AppendMockSubject_ImplementClass_AddProperty(StringBuilder s sb.Append("\t\t/// $"{p.Type.Fullname}"))}]") - .EscapeForXmlDoc() - : property.Name.EscapeForXmlDoc()) + $"[{string.Join(", ", property.IndexerParameters.Value.Select(p => $"{p.Type.Fullname.EscapeForXmlDoc()}"))}]") + : property.Name) .AppendLine("\" />"); sb.Append(property.Attributes, "\t\t"); if (explicitInterfaceImplementation) @@ -1769,7 +1768,7 @@ private static void DefineSetupInterface(StringBuilder sb, Class @class, MemberT property.MemberType == memberType; foreach (Property property in @class.AllProperties().Where(propertyPredicate)) { - sb.AppendXmlSummary($"Setup for the {property.Type.Fullname.EscapeForXmlDoc()} property ."); + sb.AppendXmlSummary($"Setup for the {property.Type.Fullname.EscapeForXmlDoc()} property ."); sb.Append("\t\tglobal::Mockolate.Setup.PropertySetup<").Append(property.Type.Fullname).Append("> ").Append(property.Name).Append(" { get; }").AppendLine(); sb.AppendLine(); } @@ -1782,7 +1781,7 @@ private static void DefineSetupInterface(StringBuilder sb, Class @class, MemberT => @event.ExplicitImplementation is null && @event.MemberType == memberType; foreach (Event @event in @class.AllEvents().Where(eventPredicate)) { - sb.AppendXmlSummary($"Setup for the event ."); + sb.AppendXmlSummary($"Setup for the event ."); sb.Append("\t\tglobal::Mockolate.Setup.EventSetup ").Append(@event.Name).Append(" { get; }").AppendLine(); sb.AppendLine(); } @@ -2542,7 +2541,7 @@ private static void DefineRaiseInterface(StringBuilder sb, Class @class, MemberT @event.MemberType == memberType; foreach (Event @event in @class.AllEvents().Where(predicate)) { - sb.AppendXmlSummary($"Raise the event."); + sb.AppendXmlSummary($"Raise the event."); sb.Append("\t\tvoid ").Append(@event.Name).Append("(").Append(FormatParametersWithTypeAndName(@event.Delegate.Parameters)).Append(");").AppendLine(); sb.AppendLine(); } @@ -2554,7 +2553,7 @@ private static void DefineRaiseInterface(StringBuilder sb, Class @class, MemberT .Select(g => g.Single()) .Where(m => m.Delegate.Parameters.Count > 0)) { - sb.AppendXmlSummary($"Raise the event."); + sb.AppendXmlSummary($"Raise the event."); sb.Append("\t\tvoid ").Append(@event.Name).Append("(global::Mockolate.Parameters.IDefaultEventParameters parameters);").AppendLine(); sb.AppendLine(); } @@ -2623,7 +2622,7 @@ private static void DefineVerifyInterface(StringBuilder sb, Class @class, string property.MemberType == memberType; foreach (Property property in @class.AllProperties().Where(propertyPredicate)) { - sb.AppendXmlSummary($"Verify interactions with the {property.Type.Fullname.EscapeForXmlDoc()} property ."); + sb.AppendXmlSummary($"Verify interactions with the {property.Type.Fullname.EscapeForXmlDoc()} property ."); sb.Append("\t\tglobal::Mockolate.Verify.VerificationPropertyResult<").Append(verifyName).Append(", ").Append(property.Type.Fullname).Append("> ").Append(property.Name).Append(" { get; }").AppendLine(); sb.AppendLine(); } @@ -2723,12 +2722,22 @@ private static void AppendMethodVerifyDefinition(StringBuilder sb, Method method { string methodName = methodNameOverride ?? method.Name; sb.Append("\t\t/// ").AppendLine(); - sb.Append("\t\t/// Verify invocations for the method p.RefKind.GetString() + p.Type.Fullname.EscapeForXmlDoc()))); - sb.Append(")\"/>").Append(method.Parameters.Count > 0 ? " with the given " : ""); + if (methodNameOverride is null) + { + sb.Append("\t\t/// Verify invocations for the method p.RefKind.GetString() + p.Type.Fullname.EscapeForXmlDoc()))); + sb.Append(")\"/>"); + } + else + { + sb.Append("\t\t/// Verify invocations for the delegate "); + } + + sb.Append(method.Parameters.Count > 0 ? " with the given " : ""); if (useParameters) { sb.Append(""); diff --git a/Tests/Mockolate.SourceGenerators.Tests/MockTests.DelegateTests.cs b/Tests/Mockolate.SourceGenerators.Tests/MockTests.DelegateTests.cs index c07419dd..0d32f7ab 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/MockTests.DelegateTests.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/MockTests.DelegateTests.cs @@ -291,5 +291,32 @@ await That(result.Sources).ContainsKey("Mock.Program_ProcessResult.g.cs").WhoseV .Contains("result1.TriggerCallbacks(result, value)") .IgnoringNewlineStyle(); } + + [Fact] + public async Task Delegate_ShouldHaveCorrectReferenceInXMLDocumentation() + { + GeneratorResult result = Generator + .Run(""" + using System; + using Mockolate; + + namespace MyCode; + + public class Program + { + public static void Main(string[] args) + { + _ = DoSomething.CreateMock(); + } + + public delegate int DoSomething(int x, int y); + } + """); + + await That(result.Sources).ContainsKey("Mock.Program_DoSomething.g.cs").WhoseValue + .Contains("Verify invocations for the delegate with the given , .").And + .Contains("Verify invocations for the delegate with the given .").And + .DoesNotContain("Verify invocations for the method