diff --git a/NTypewriter.CodeModel.Roslyn/EnumValue.cs b/NTypewriter.CodeModel.Roslyn/EnumValue.cs index 629cf07..e74675b 100644 --- a/NTypewriter.CodeModel.Roslyn/EnumValue.cs +++ b/NTypewriter.CodeModel.Roslyn/EnumValue.cs @@ -10,7 +10,7 @@ internal sealed class EnumValue : IEnumValue public object Value => symbol.ConstantValue; public string Name => symbol.Name; public IEnumerable Attributes => AttributeCollection.Create(symbol); - + public IDocumentationCommentXml DocComment => DocumentationCommentXml.Create(symbol); private EnumValue(IFieldSymbol symbol) { diff --git a/NTypewriter.CodeModel.Tests/EnumValue/DocComments/expectedResult.txt b/NTypewriter.CodeModel.Tests/EnumValue/DocComments/expectedResult.txt new file mode 100644 index 0000000..b6645e7 --- /dev/null +++ b/NTypewriter.CodeModel.Tests/EnumValue/DocComments/expectedResult.txt @@ -0,0 +1,5 @@ +One +Two +Three +This is the number four. (4)Four +This is the number five. (5)Five diff --git a/NTypewriter.CodeModel.Tests/EnumValue/DocComments/inputCode.cs b/NTypewriter.CodeModel.Tests/EnumValue/DocComments/inputCode.cs new file mode 100644 index 0000000..0dcb040 --- /dev/null +++ b/NTypewriter.CodeModel.Tests/EnumValue/DocComments/inputCode.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.ComponentModel; + +namespace NTypewriter.Tests.CodeModel +{ + enum EnumWithDocComments + { + One = 1, + Two = 2, + Three = 3, + /// + /// This is the number four. (4) + /// + Four = 4, + /// + /// This is the number five. (5) + /// + Five = 5, + } +} \ No newline at end of file diff --git a/NTypewriter.CodeModel.Tests/EnumValue/DocComments/inputTemplate.tsnt b/NTypewriter.CodeModel.Tests/EnumValue/DocComments/inputTemplate.tsnt new file mode 100644 index 0000000..5e19d23 --- /dev/null +++ b/NTypewriter.CodeModel.Tests/EnumValue/DocComments/inputTemplate.tsnt @@ -0,0 +1,11 @@ +{{- capture captured + for enum in data.Enums | Symbols.WhereNamespaceStartsWith "NTypewriter.Tests.CodeModel" + for enumValue in enum.Values }} +{{- if enumValue.DocComment && enumValue.DocComment.Summary }} + {{- enumValue.DocComment.Summary }} +{{- end }} +{{- enumValue.Name }} +{{ end + end + end + Save captured "result" }} \ No newline at end of file diff --git a/NTypewriter.CodeModel.Tests/EnumValue/EnumRenderingTests.cs b/NTypewriter.CodeModel.Tests/EnumValue/EnumRenderingTests.cs index 9b8619f..9c9ac6a 100644 --- a/NTypewriter.CodeModel.Tests/EnumValue/EnumRenderingTests.cs +++ b/NTypewriter.CodeModel.Tests/EnumValue/EnumRenderingTests.cs @@ -13,5 +13,11 @@ public async Task Attributes() { await RunTestForProperty(); } + + [TestMethod] + public async Task DocComments() + { + await RunTestForProperty(); + } } } \ No newline at end of file diff --git a/NTypewriter.CodeModel.Tests/NTypewriter.CodeModel.Tests.csproj b/NTypewriter.CodeModel.Tests/NTypewriter.CodeModel.Tests.csproj index 979f616..3a35226 100644 --- a/NTypewriter.CodeModel.Tests/NTypewriter.CodeModel.Tests.csproj +++ b/NTypewriter.CodeModel.Tests/NTypewriter.CodeModel.Tests.csproj @@ -24,6 +24,7 @@ + @@ -117,6 +118,8 @@ + + @@ -283,6 +286,9 @@ + + + diff --git a/NTypewriter.CodeModel/IEnumValue.cs b/NTypewriter.CodeModel/IEnumValue.cs index 3fbe78d..2e725db 100644 --- a/NTypewriter.CodeModel/IEnumValue.cs +++ b/NTypewriter.CodeModel/IEnumValue.cs @@ -23,5 +23,10 @@ public interface IEnumValue /// All attributes declared on the enum value. /// IEnumerable Attributes { get; } + + /// + /// The XML documentation for the comment associated with the symbol. + /// + IDocumentationCommentXml DocComment { get; } } } \ No newline at end of file