示例#1
0
        public async Task CreateCodeBlock_With_CodeLineBuilder()
        {
            // arrange
            var sb     = new StringBuilder();
            var writer = new CodeWriter(sb);

            // act
            await CodeBlockBuilder.New()
            .AddCode("abc;")
            .AddCode(CodeLineBuilder.New().SetLine("def;"))
            .BuildAsync(writer);

            // assert
            sb.ToString().MatchSnapshot();
        }
        public static CodeBlockBuilder FromString(string s)
        {
            if (s is null)
            {
                throw new ArgumentNullException(nameof(s));
            }

            CodeBlockBuilder builder = new CodeBlockBuilder();

            using var stringReader = new StringReader(s);

            while (stringReader.Peek() != -1)
            {
                string?line = stringReader.ReadLine();
                if (line is { })