Пример #1
0
        public void NestedClasses()
        {
            string code = @"using System;

//test
[Description(""Test"")]
class ScriptA
{
    int Count;
    int fieldI;
    int prop {get;set;}
    void main0() {}
    void main1(int test) {}
    void main2(int test, int test2) {}

    class Printer
    {
        void Print(int test) {}
        string Name {get;set;}

        class Settings
        {
            void Print(int test) {}
            string Name {get;set;}
        }
    }
}

class ScriptB
{
    int CountB;
    int fieldIB;
    int propB {get;set;}
    void main0() {}
    void main1B(int test) {}
    void main2B(int test, int test2) {}
}";

            var map = Reflector.GetMapOf(code).OrderBy(x => x.ParentDisplayName)
                      .Select(x => string.Format("{0}.{1}: Line {2}", x.ParentDisplayName, x.DisplayName, x.Line))
                      .ToArray();

            string mapDisplay = string.Join(Environment.NewLine, map);

            TextAssert.Equal(mapDisplay,
                             @"ScriptA.prop: Line 9
ScriptA.main0(): Line 10
ScriptA.main1(): Line 11
ScriptA.main2(,): Line 12
ScriptA.Printer.Print(): Line 16
ScriptA.Printer.Name: Line 17
ScriptA.Printer.Settings.Print(): Line 21
ScriptA.Printer.Settings.Name: Line 22
ScriptB.propB: Line 31
ScriptB.main0(): Line 32
ScriptB.main1B(): Line 33
ScriptB.main2B(,): Line 34");
        }
Пример #2
0
        public void Parsing_3()
        {
            var template =
                @"for (int $i$ = 0; $i$ < $length$; $i$++)
{
    $|$
}";
            var expected =
                @"for (int i = 0; i < length; i++)
    {
        |
    }";

            var result = CSScriptIntellisense.Snippets.PrepareForIncertion(template, 4);

            TextAssert.Equal(expected, result.ReplacementString);
        }