Example #1
0
        public void Member_ids_are_parsed_as_expected(MemberIdParserTestCase testCase)
        {
            // ARRANGE
            var parser = new MemberIdParser(testCase.Input, testCase.OuterTypes);

            // ACT
            var memberId = parser.Parse();

            // ASSERT
            Assert.NotNull(memberId);
            Assert.Equal(testCase.ExpectedMemberId, memberId);
        }
Example #2
0
        public static bool TryParse(string?value, IReadOnlyCollection <TypeId> outerTypes, out MemberId?memberId)
#endif
        {
            if (value == null)
            {
                memberId = default;
                return(false);
            }

            try
            {
                var parser = new MemberIdParser(value, outerTypes);
                memberId = parser.Parse();
                return(true);
            }
            catch (MemberIdParserException)
            {
                memberId = default;
                return(false);
            }
        }
Example #3
0
        /// <summary>
        /// Parses the specified value into a <see cref="MemberId"/>.
        /// </summary>
        /// <remarks>
        /// The values is assumed to be a member id as generated by the C# compiler
        /// in the xml documentation file for a assembly.
        /// For a description of the format see
        /// <see href="https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/xmldoc/processing-the-xml-file">Microsoft Docs</see>
        /// <para>
        /// Because the id of a nested type cannot be distinguished from the id of a non-nested type,
        /// a list of known non-nested ("outer types") needs to be passed in so that ids of
        /// nested types are parsed correctly.
        /// </para>
        /// <para>
        /// For example the id <c>T:Namespace.Class1.NestedClass</c>
        /// would be parsed into a type named <c>NestedClass</c> with a namespace <c>Namespace.Class1</c>.
        /// When the list of outer types contains the type <c>Namespace.Class1</c>, the id is parsed correctly.
        /// </para>
        /// </remarks>
        /// <exception cref="MemberIdParserException">Thrown when the specified value could not be parsed as member id.</exception>
        public static MemberId Parse(string value, IReadOnlyCollection <TypeId> outerTypes)
        {
            var parser = new MemberIdParser(value, outerTypes);

            return(parser.Parse());
        }