private void BindAndReplaceCref(XAttribute attribute, CSharpSyntaxNode originatingSyntax) { string attributeValue = attribute.Value; CrefSyntax crefSyntax = SyntaxFactory.ParseCref(attributeValue); if (crefSyntax == null) { // This can happen if the cref is verbatim (e.g. "T:C"). return; } // CONSIDER: It would be easy to construct an XmlLocation from the XAttribute, so that // we could point the user at the actual problem. Location sourceLocation = originatingSyntax.Location; RecordSyntaxDiagnostics(crefSyntax, sourceLocation); // Respects DocumentationMode. MemberDeclarationSyntax memberDeclSyntax = BinderFactory.GetAssociatedMemberForXmlSyntax(originatingSyntax); Debug.Assert(memberDeclSyntax != null, "Why are we processing a documentation comment that is not attached to a member declaration?"); Binder binder = BinderFactory.MakeCrefBinder(crefSyntax, memberDeclSyntax, _compilation.GetBinderFactory(memberDeclSyntax.SyntaxTree)); DiagnosticBag crefDiagnostics = DiagnosticBag.GetInstance(); attribute.Value = GetDocumentationCommentId(crefSyntax, binder, crefDiagnostics); // NOTE: mutation (element must be a copy) RecordBindingDiagnostics(crefDiagnostics, sourceLocation); // Respects DocumentationMode. crefDiagnostics.Free(); }
private void BindName(XAttribute attribute, CSharpSyntaxNode originatingSyntax, bool isParameter, bool isTypeParameterRef) { XmlNameAttributeSyntax attrSyntax = ParseNameAttribute(attribute.ToString(), attribute.Parent.Name.LocalName); // CONSIDER: It would be easy to construct an XmlLocation from the XAttribute, so that // we could point the user at the actual problem. Location sourceLocation = originatingSyntax.Location; RecordSyntaxDiagnostics(attrSyntax, sourceLocation); // Respects DocumentationMode. MemberDeclarationSyntax memberDeclSyntax = BinderFactory.GetAssociatedMemberForXmlSyntax(originatingSyntax); Debug.Assert(memberDeclSyntax != null, "Why are we processing a documentation comment that is not attached to a member declaration?"); DiagnosticBag nameDiagnostics = DiagnosticBag.GetInstance(); Binder binder = MakeNameBinder(isParameter, isTypeParameterRef, _memberSymbol, _compilation); DocumentationCommentCompiler.BindName(attrSyntax, binder, _memberSymbol, ref _documentedParameters, ref _documentedTypeParameters, nameDiagnostics); RecordBindingDiagnostics(nameDiagnostics, sourceLocation); // Respects DocumentationMode. nameDiagnostics.Free(); }