Permalink
Browse files

Fix #44, start Structured docs, whitespace & comments

  • Loading branch information...
1 parent fabf314 commit 2a6297f1599f7258321d07b6694e401a813a802e Kathleen Dollard committed Jul 22, 2014
Showing with 721 additions and 206 deletions.
  1. BIN Documentation/RoslynDom Walkthroughs.docx
  2. +1 −1 RoslynDom/BasesAndBaseHelpers/RDomBaseOfT.cs
  3. +25 −5 RoslynDom/BasesAndBaseHelpers/RDomBaseTTSyntaxTSymbol.cs
  4. +4 −0 RoslynDom/BasesAndBaseHelpers/RDomBaseType.cs
  5. +5 −1 RoslynDom/Implementations/RDomEnum.cs
  6. +4 −0 RoslynDom/Implementations/RDomField.cs
  7. +4 −0 RoslynDom/Implementations/RDomInvalidTypeMember.cs
  8. +5 −0 RoslynDom/Implementations/RDomMethod.cs
  9. +4 −18 RoslynDom/Implementations/RDomProperty.cs
  10. +9 −44 RoslynDom/Implementations/RDomStructure.cs
  11. +13 −0 RoslynDom/Implementations/RDomVerticalWhitespace.cs
  12. +2 −0 RoslynDom/RoslynDom.csproj
  13. +1 −0 RoslynDom/RoslynUtilities.cs
  14. +46 −0 RoslynDom/StructuredDocumentation.cs
  15. +6 −6 RoslynDomCSharpFactories/AttributeFactory.cs
  16. +35 −24 RoslynDomCSharpFactories/BaseFactories/RDomBaseItemFactory.cs
  17. +2 −1 RoslynDomCSharpFactories/BaseFactories/RDomExpressionFactory.cs
  18. +152 −3 RoslynDomCSharpFactories/BuildSyntaxExtensions.cs
  19. +0 −40 RoslynDomCSharpFactories/Factories/RDomAttributeFactory.cs
  20. +3 −0 RoslynDomCSharpFactories/Factories/RDomClassFactory.cs
  21. +3 −0 RoslynDomCSharpFactories/Factories/RDomEnumFactory.cs
  22. +6 −2 RoslynDomCSharpFactories/Factories/RDomFieldFactory.cs
  23. +1 −0 RoslynDomCSharpFactories/Factories/RDomInterfaceFactory.cs
  24. +15 −7 RoslynDomCSharpFactories/Factories/RDomMethodFactory.cs
  25. +5 −3 RoslynDomCSharpFactories/Factories/RDomNamespaceFactory.cs
  26. +2 −1 RoslynDomCSharpFactories/Factories/RDomParameterFactory.cs
  27. +3 −1 RoslynDomCSharpFactories/Factories/RDomPropertyFactory.cs
  28. +3 −2 RoslynDomCSharpFactories/Factories/RDomReferencedTypeFactory.cs
  29. +1 −0 RoslynDomCSharpFactories/Factories/RDomStructureFactory.cs
  30. +36 −0 RoslynDomCSharpFactories/Factories/RDomStructuredDocumentationFactory.cs
  31. +3 −2 RoslynDomCSharpFactories/Factories/RDomUsingFactory.cs
  32. +2 −1 RoslynDomCSharpFactories/FactoriesForStatements/RDomBlockStatementFactory.cs
  33. +1 −1 RoslynDomCSharpFactories/FactoriesForStatements/RDomDeclarationStatementFactory.cs
  34. +1 −0 RoslynDomCSharpFactories/FactoriesForStatements/RDomWhileStatementFactory.cs
  35. +8 −7 RoslynDomCSharpFactories/PublicAnnotationFactory.cs
  36. +1 −0 RoslynDomCSharpFactories/RoslynDomCSharpFactories.csproj
  37. +16 −0 RoslynDomCommon/BaseInterfaces/IComment.cs
  38. +15 −0 RoslynDomCommon/BaseInterfaces/IPublicAnnotation.cs
  39. +11 −0 RoslynDomCommon/BaseInterfaces/IStructuredDocumentation.cs
  40. +1 −1 RoslynDomCommon/BaseInterfaces/IType.cs
  41. +5 −1 RoslynDomCommon/BaseInterfaces/ITypeMember.cs
  42. +13 −0 RoslynDomCommon/BaseInterfaces/IVerticalWhitespace.cs
  43. +10 −0 RoslynDomCommon/CharacteristicInterfaces/IHasStructuredDocumentation.cs
  44. +1 −1 RoslynDomCommon/Interfaces/IField.cs
  45. +11 −2 RoslynDomCommon/PublicAnnotation.cs
  46. +5 −5 RoslynDomCommon/PublicAnnotationList.cs
  47. +5 −0 RoslynDomCommon/RoslynDomCommon.csproj
  48. +8 −2 RoslynDomExampleTests/Walkthrough_1_code.cs
  49. +16 −16 RoslynDomExampleTests/Walkthroughs.cs
  50. +7 −0 RoslynDomRDomCommon/FactoryProvider.cs
  51. +4 −1 RoslynDomRDomCommon/IRDomFactory.cs
  52. +9 −1 RoslynDomRDomCommon/RDomBase.cs
  53. +11 −3 RoslynDomRDomCommon/RDomBaseFactoryHelper.cs
  54. +111 −0 RoslynDomTests/PlaySpace.cs
  55. +2 −2 RoslynDomTests/PublicAnnotationTests.cs
  56. +1 −0 RoslynDomTests/RoslynDomTests.csproj
  57. +1 −1 RoslynDomTests/StatementTests.cs
  58. +46 −0 RoslynDomTests/StructuredXmlDocumentationTests.cs
Binary file not shown.
@@ -12,7 +12,7 @@ public abstract class RDomBase<T> : RDomBase, IDom<T>
{
private ISameIntent<T> sameIntent = SameIntent_Factory.SameIntent<T>();
- protected RDomBase(IEnumerable<PublicAnnotation> publicAnnotations)
+ protected RDomBase(IEnumerable<IPublicAnnotation> publicAnnotations)
: base(publicAnnotations)
{ }
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
+using System.Linq;
+using System.Xml.Linq;
using Microsoft.CodeAnalysis;
using RoslynDom.Common;
@@ -17,18 +19,36 @@ public abstract class RDomBase<T, TSymbol> : RDomBase<T>, IRoslynDom<T, TSymbol>
private string _containingTypeName;
protected RDomBase(SyntaxNode rawItem, IDom parent, SemanticModel model)
- : base(RDomFactoryHelper.GetPublicAnnotations(rawItem, parent))
+ : base(RDomFactoryHelper.GetPublicAnnotations(rawItem, parent, model))
{
_rawSyntax = rawItem;
_originalRawSyntax = rawItem;
Parent = parent;
if (model != null)
{
_symbol = (TSymbol)model.GetDeclaredSymbol(rawItem);
- //if (_symbol != null)
- //{
- // _attributes = RDomAttribute.MakeAttributes(this, Symbol, _rawSyntax, model);
- //}
+ if (_symbol != null)
+ {
+ var thisAsHasStructuredDocs = this as IHasStructuredDocumentation;
+ if (thisAsHasStructuredDocs != null)
+ {
+ var docsItem = RDomFactoryHelper.GetStructuredDocumentation(rawItem, parent, model).FirstOrDefault();
+ var docs = Symbol.GetDocumentationCommentXml();
+ if (!string.IsNullOrWhiteSpace(docs))
+ {
+ var xDocument = XDocument.Parse(docs);
+ docsItem.RawItem = xDocument;
+ var summaryNode = xDocument.DescendantNodes()
+ .OfType<XElement>()
+ .Where(x => x.Name == "summary")
+ .Select(x => x.Value);
+ var description = summaryNode.FirstOrDefault().Replace("/r", "").Replace("\n", "").Trim();
+ docsItem.Description = description;
+ thisAsHasStructuredDocs.StructuredDocumentation = docsItem;
+ thisAsHasStructuredDocs.Description = description;
+ }
+ }
+ }
}
}
@@ -129,6 +129,10 @@ public MemberKind MemberKind
public StemMemberKind StemMemberKind
{ get { return _stemMemberKind; } }
+
+ public IStructuredDocumentation StructuredDocumentation { get; set; }
+
+ public string Description { get ; set;}
}
}
@@ -16,7 +16,7 @@ public RDomEnum(SyntaxNode rawItem, IDom parent, SemanticModel model)
internal RDomEnum(RDomEnum oldRDom)
: base(oldRDom)
{
- Attributes.AddOrMoveAttributeRange( oldRDom.Attributes.Select(x=>x.Copy()));
+ Attributes.AddOrMoveAttributeRange(oldRDom.Attributes.Select(x => x.Copy()));
AccessModifier = oldRDom.AccessModifier;
UnderlyingType = oldRDom.UnderlyingType;
}
@@ -48,5 +48,9 @@ public StemMemberKind StemMemberKind
get { return StemMemberKind.Enum; }
}
+
+ public IStructuredDocumentation StructuredDocumentation { get; set; }
+
+ public string Description { get; set; }
}
}
@@ -62,5 +62,9 @@ public override object RequestValue(string name)
{ return ReturnType.QualifiedName; }
return base.RequestValue(name);
}
+
+ public IStructuredDocumentation StructuredDocumentation { get; set; }
+
+ public string Description { get ; set;}
}
}
@@ -41,5 +41,9 @@ public MemberKind MemberKind
{
get { return MemberKind.InvalidMember; }
}
+
+ public IStructuredDocumentation StructuredDocumentation { get; set; }
+
+ public string Description { get ; set;}
}
}
@@ -3,6 +3,7 @@
using RoslynDom.Common;
using System.Linq;
using System.Linq;
+using System;
namespace RoslynDom
{
@@ -112,6 +113,10 @@ public bool HasBlock
public MemberKind MemberKind
{ get { return MemberKind.Method; } }
+ public IStructuredDocumentation StructuredDocumentation { get;set; }
+
+ public string Description { get ; set; }
+
public override object RequestValue(string name)
{
if (name == "TypeName")
@@ -112,24 +112,7 @@ public IEnumerable<IParameter> Parameters
// This is for VB, wihch I have not yet implemented, but don't want things crashing so will ignore
{ get { return _parameters; } }
- //public void RemoveGetStatement(IStatement statement)
- //{ _getStatements.Remove(statement); }
-
- //public void AddGetStatement(IStatement statement)
- //{ _getStatements.Add(statement); }
-
- //public IEnumerable<IStatement> GetStatements
- //{ get { return _getStatements; } }
-
- //public void RemoveSetStatement(IStatement statement)
- //{ _setStatements.Remove(statement); }
-
- //public void AddSetStatement(IStatement statement)
- //{ _setStatements.Add(statement); }
-
- //public IEnumerable<IStatement> SetStatements
- //{ get { return _setStatements; } }
-
+
public MemberKind MemberKind
{ get { return MemberKind.Property; } }
@@ -139,5 +122,8 @@ public override object RequestValue(string name)
{ return ReturnType.QualifiedName; }
return base.RequestValue(name);
}
+ public IStructuredDocumentation StructuredDocumentation { get; set; }
+
+ public string Description { get ; set;}
}
}
@@ -7,24 +7,16 @@ namespace RoslynDom
{
public class RDomStructure : RDomBaseType<IStructure>, IStructure
{
- private AttributeList _attributes = new AttributeList();
-
public RDomStructure(SyntaxNode rawItem, IDom parent, SemanticModel model)
- : base(rawItem,parent, model, MemberKind.Structure, StemMemberKind.Structure)
+ : base(rawItem, parent, model, MemberKind.Structure, StemMemberKind.Structure)
{ }
internal RDomStructure(RDomStructure oldRDom)
: base(oldRDom)
{ }
- public AttributeList Attributes
- { get { return _attributes; } }
-
- public IEnumerable<IClass> Classes
- {
- get
- { return Members.OfType<IClass>(); }
- }
+ public IEnumerable<IClass> Classes
+ { get { return Members.OfType<IClass>(); } }
public IEnumerable<IType> Types
{
@@ -36,45 +28,18 @@ public IEnumerable<IType> Types
}
public IEnumerable<IStructure> Structures
- {
- get
- { return Members.OfType<IStructure>(); }
- }
+ { get { return Members.OfType<IStructure>(); } }
public IEnumerable<IInterface> Interfaces
- {
- get
- { return Members.OfType<IInterface>(); }
- }
+ { get { return Members.OfType<IInterface>(); } }
public IEnumerable<IEnum> Enums
- {
- get
- { return Members.OfType<IEnum>(); }
- }
-
- public IEnumerable<ITypeParameter> TypeParameters
- {
- get
- {
- return this.TypedSymbol.TypeParametersFrom();
- }
- }
+ { get { return Members.OfType<IEnum>(); } }
- public IEnumerable<IReferencedType> ImplementedInterfaces
- {
- get
- {
- return this.ImpementedInterfacesFrom(false);
- }
- }
+ public IEnumerable<IReferencedType> ImplementedInterfaces
+ { get { return this.ImpementedInterfacesFrom(false); } }
public IEnumerable<IReferencedType> AllImplementedInterfaces
- {
- get
- {
- return this.ImpementedInterfacesFrom(true);
- }
- }
+ { get { return this.ImpementedInterfacesFrom(true); } }
}
}
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using RoslynDom.Common;
+
+namespace RoslynDom
+{
+ //public class RDomVerticalWhitespace : ITypeMember, IStemMember, IStatement
+ //{
+ //}
+}
@@ -66,6 +66,7 @@
<Compile Include="Implementations\RDomInterface.cs" />
<Compile Include="Implementations\RDomInvalidTypeMember.cs" />
<Compile Include="Implementations\RDomAccessor.cs" />
+ <Compile Include="Implementations\RDomVerticalWhitespace.cs" />
<Compile Include="RegisterCSharpFactories.cs" />
<Compile Include="RoslynDomSymbolUtilities.cs" />
<Compile Include="RoslynUtilities.cs" />
@@ -93,6 +94,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="StatementImplementations\RDomIfStatement.cs" />
<Compile Include="StatementImplementations\RDomBlockStatement.cs" />
+ <Compile Include="StructuredDocumentation.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
@@ -8,6 +8,7 @@ public static class RoslynUtilities
{
public static SyntaxNode Format(SyntaxNode node)
{
+ // var formattingOptions = FormattingOptions.;
var span = node.FullSpan;
node = Formatter.Format(node, span, new CustomWorkspace());
return node;
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using RoslynDom.Common;
+
+namespace RoslynDom
+{
+ public class RDomStructuredDocumentation : IStructuredDocumentation, IHasSameIntentMethod
+ {
+ private string description;
+
+ public RDomStructuredDocumentation()
+ { }
+
+ public RDomStructuredDocumentation(object rawDocumentation, string description)
+ {
+ RawItem = rawDocumentation;
+ Description = description;
+ }
+
+ public RDomStructuredDocumentation(RDomStructuredDocumentation old)
+ {
+ RawItem = old.RawItem;
+ }
+ public string Description { get; set; }
+
+ public object RawItem { get; set; }
+
+
+ public bool SameIntent<T>(T other)
+ where T : class
+ {
+ var otherAnnotation = other as IStructuredDocumentation;
+
+ if (RawItem != otherAnnotation.RawItem) return false;
+ return true;
+ }
+
+ public bool SameIntent<T>(T otherAnnotation, bool ignoreValue)
+ where T : class
+ {
+ return SameIntent(otherAnnotation);
+ }
+
+ }
+}
@@ -50,8 +50,8 @@ public IEnumerable<SyntaxNode> BuildSyntax(IAttribute item)
var itemAsT = item as IAttribute;
var nameSyntax = SyntaxFactory.ParseName(itemAsT.Name);
var arguments = new SeparatedSyntaxList<AttributeArgumentSyntax>();
- var values = itemAsT.AttributeValues.SelectMany(x => BuildAttributeValueSyntax(x));
- values = values.Select(x => x.NormalizeWhitespace());
+ var values = itemAsT.AttributeValues.Select(x => BuildAttributeValueSyntax(x));
+ //values = values.Select(x => x.Format());
arguments = arguments.AddRange(values.OfType<AttributeArgumentSyntax>());
var argumentList = SyntaxFactory.AttributeArgumentList(arguments);
var node = SyntaxFactory.Attribute(nameSyntax, argumentList);
@@ -67,7 +67,7 @@ public IEnumerable<SyntaxNode> BuildSyntax(AttributeList attributeList)
{
var attribList = SyntaxFactory.AttributeList();
var attributeSyntaxItems = attributes.SelectMany(x => BuildSyntax(x)).ToArray();
- attributeSyntaxItems = attributeSyntaxItems.Select(x => x.NormalizeWhitespace()).ToArray();
+ // TODO: attributeSyntaxItems = attributeSyntaxItems.Select(x => x.Format()).ToArray();
attribList = attribList.AddAttributes(attributeSyntaxItems.OfType<AttributeSyntax>().ToArray());
list = list.Add(attribList);
}
@@ -92,7 +92,7 @@ public IEnumerable<IAttribute> ExtractAttributes(SyntaxNode parentNode, IDom new
#region Private methods to support build syntax
- private IEnumerable<SyntaxNode> BuildAttributeValueSyntax(IAttributeValue atttributeValue)
+ private AttributeArgumentSyntax BuildAttributeValueSyntax(IAttributeValue atttributeValue)
{
var argNameSyntax = SyntaxFactory.IdentifierName(atttributeValue.Name);
var kind = RoslynCSharpUtilities.SyntaxKindFromLiteralKind(atttributeValue.ValueType, atttributeValue.Value);
@@ -105,7 +105,7 @@ private IEnumerable<SyntaxNode> BuildAttributeValueSyntax(IAttributeValue atttri
var token = (SyntaxToken)methodInfo.Invoke(null, new object[] { atttributeValue.Value });
expr = SyntaxFactory.LiteralExpression(kind, token);
}
- SyntaxNode node;
+ AttributeArgumentSyntax node;
if (atttributeValue.Style == AttributeValueStyle.Colon)
{
node = SyntaxFactory.AttributeArgument(
@@ -123,7 +123,7 @@ private IEnumerable<SyntaxNode> BuildAttributeValueSyntax(IAttributeValue atttri
SyntaxFactory.NameEquals(argNameSyntax),
null, expr);
}
- return new SyntaxNode[] { node };
+ return node ;
}
#endregion
Oops, something went wrong.

0 comments on commit 2a6297f

Please sign in to comment.