/// <summary> /// Initializes a new instance of <see cref="OperatorDocumentation"/>. /// </summary> /// <param name="typeDocumentation">The documentation model of the type defining the operator overload.</param> /// <param name="definitions">The underlying Mono.Cecul definitions of the operator overload.</param> /// <param name="xmlDocsProvider">The XML documentation provider to use for loading XML documentation comments.</param> internal OperatorDocumentation(TypeDocumentation typeDocumentation, IEnumerable <MethodDefinition> definitions, IXmlDocsProvider xmlDocsProvider) : base(typeDocumentation) { if (definitions == null) { throw new ArgumentNullException(nameof(definitions)); } if (definitions.Select(x => x.Name).Distinct().Count() > 1) { throw new ArgumentException("All definitions have to be overloads of the same method", nameof(definitions)); } m_Overloads = definitions .Select(d => new OperatorOverloadDocumentation(this, d, xmlDocsProvider)) .ToDictionary(x => x.MemberId); Overloads = ReadOnlyCollectionAdapter.Create(m_Overloads.Values); var operatorKinds = Overloads.Select(x => x.OperatorKind).Distinct().ToArray(); Kind = operatorKinds.Length == 1 ? operatorKinds[0] : throw new ArgumentException("Cannot combine overloads of different operators"); }
/// <summary> /// Initializes a new instance of <see cref="ConstructorDocumentation"/> /// </summary> /// <param name="typeDocumentation">The documentation model for the type that defines the constructor.</param> /// <param name="definitions">The definitions of the type's constructor</param> /// <param name="xmlDocsProvider">The XML documentation provider to use for loading XML documentation comments.</param> /// <exception cref="ArgumentNullException">Thrown when one of the constructor arguments is null.</exception> /// <exception cref="ArgumentException">Thrown when <paramref name="definitions"/> contains definitions with different method names.</exception> internal ConstructorDocumentation(TypeDocumentation typeDocumentation, IEnumerable <MethodDefinition> definitions, IXmlDocsProvider xmlDocsProvider) : base(typeDocumentation) { if (definitions == null) { throw new ArgumentNullException(nameof(definitions)); } if (xmlDocsProvider == null) { throw new ArgumentNullException(nameof(xmlDocsProvider)); } if (definitions.Select(x => x.Name).Distinct().Count() > 1) { throw new ArgumentException("All definitions have to be overloads of the same method", nameof(definitions)); } m_Overloads = definitions .Select(d => new ConstructorOverloadDocumentation(this, d, xmlDocsProvider)) .ToDictionary(d => d.MemberId); Overloads = ReadOnlyCollectionAdapter.Create(m_Overloads.Values); m_Name = definitions.First().Name; }
/// <summary> /// Initializes a new instance of <see cref="EventDocumentation"/>. /// </summary> /// <param name="typeDocumentation">The documentation model of the type defining the event.</param> /// <param name="definition">The underlying Mono.Cecil definition of the event.</param> /// <param name="xmlDocsProvider">The XML documentation provider to use for loading XML documentation comments.</param> /// <exception cref="ArgumentNullException">Thrown when one of the constructor arguments is null.</exception> internal EventDocumentation(TypeDocumentation typeDocumentation, EventDefinition definition, IXmlDocsProvider xmlDocsProvider) : base(typeDocumentation, definition.ToMemberId(), xmlDocsProvider, definition) { Definition = definition ?? throw new ArgumentNullException(nameof(definition)); Type = definition.EventType.ToTypeId(); CSharpDefinition = CSharpDefinitionFormatter.GetDefinition(definition); }
/// <summary> /// Initializes a new instance of <see cref="FieldDocumentation"/>. /// </summary> /// <param name="typeDocumentation">The documentation model of the type defining the field.</param> /// <param name="definition">The underlying Mono.Cecil definition of the field.</param> /// <param name="xmlDocsProvider">The XML documentation provider to use for loading XML documentation comments.</param> /// <exception cref="ArgumentNullException">Thrown when one of the constructor arguments is null.</exception> internal FieldDocumentation(TypeDocumentation typeDocumentation, FieldDefinition definition, IXmlDocsProvider xmlDocsProvider) : base(typeDocumentation, definition.ToMemberId(), xmlDocsProvider, definition) { Definition = definition ?? throw new ArgumentNullException(nameof(definition)); xmlDocsProvider = xmlDocsProvider ?? throw new ArgumentNullException(nameof(xmlDocsProvider)); Type = definition.FieldType.ToTypeId(); CSharpDefinition = CSharpDefinitionFormatter.GetDefinition(definition); Value = xmlDocsProvider.TryGetDocumentationComments(MemberId)?.Value ?? TextBlock.Empty; }
/// <summary> /// Initializes a new instance of <see cref="PropertyDocumentation"/>. /// </summary> /// <param name="typeDocumentation">The documentation model of the type defining the property.</param> /// <param name="definition">The underlying Mono.Cecil definition of the property.</param> /// <param name="xmlDocsProvider">The XML documentation provider to use for loading XML documentation comments.</param> internal PropertyDocumentation(TypeDocumentation typeDocumentation, PropertyDefinition definition, IXmlDocsProvider xmlDocsProvider) : base(typeDocumentation, definition.ToMemberId(), xmlDocsProvider, definition) { Definition = definition ?? throw new ArgumentNullException(nameof(definition)); xmlDocsProvider = xmlDocsProvider ?? throw new ArgumentNullException(nameof(xmlDocsProvider)); Type = definition.PropertyType.ToTypeId(); CSharpDefinition = CSharpDefinitionFormatter.GetDefinition(definition); var documentationComments = xmlDocsProvider?.TryGetDocumentationComments(MemberId); Value = documentationComments?.Value; Exceptions = documentationComments?.Exceptions?.AsReadOnlyList() ?? Array.Empty <ExceptionElement>(); }
internal void AddNestedType(TypeDocumentation nestedType) { if (nestedType is null) { throw new ArgumentNullException(nameof(nestedType)); } if (nestedType.DeclaringType != this) { throw new ArgumentException("Cannot add nested type with a different declaring type", nameof(nestedType)); } m_NestedTypes.Add(nestedType); }
// private protected constructor => prevent implementation outside of this assembly private protected SimpleMemberDocumentation(TypeDocumentation typeDocumentation, MemberId memberId, IXmlDocsProvider xmlDocsProvider, ICustomAttributeProvider definitionAttributes) : base(typeDocumentation) { if (xmlDocsProvider == null) { throw new ArgumentNullException(nameof(xmlDocsProvider)); } MemberId = memberId ?? throw new ArgumentNullException(nameof(memberId)); definitionAttributes = definitionAttributes ?? throw new ArgumentNullException(nameof(definitionAttributes)); var documentationComments = xmlDocsProvider.TryGetDocumentationComments(memberId); Summary = documentationComments?.Summary ?? TextBlock.Empty; Remarks = documentationComments?.Remarks ?? TextBlock.Empty; SeeAlso = documentationComments?.SeeAlso?.AsReadOnlyList() ?? Array.Empty <SeeAlsoElement>(); Example = documentationComments?.Example ?? TextBlock.Empty; IsObsolete = definitionAttributes.IsObsolete(out var obsoleteMessage); ObsoleteMessage = obsoleteMessage; }
// private protected constructor => prevent implementation outside of this assembly private protected MemberDocumentation(TypeDocumentation typeDocumentation) { TypeDocumentation = typeDocumentation ?? throw new ArgumentNullException(nameof(typeDocumentation)); }
/// <summary> /// Adds the specified type to the namespace's type list. /// </summary> internal void AddType(TypeDocumentation typeDocumentation) => m_Types.Add(typeDocumentation.TypeId, typeDocumentation);
/// <inheritdoc /> public override IDocumentation?TryGetDocumentation(MemberId id) => MemberId.Equals(id) ? this : TypeDocumentation.TryGetDocumentation(id);
// private protected constructor => prevent implementation outside of this assembly private protected OverloadableMemberDocumentation(TypeDocumentation typeDocumentation) : base(typeDocumentation) { }