public static void BackingField() { var syntaxTree = CSharpSyntaxTree.ParseText(@" namespace N { class C { private int value2; private int value1; public int Value1 { get => value1; set => value1 = value; } public int Value2 { get => value2; set => value2 = value; } } }"); var x = syntaxTree.FindFieldDeclaration("private int value2"); var y = syntaxTree.FindFieldDeclaration("private int value1"); Assert.AreEqual(1, FieldDeclarationComparer.Compare(x, y)); Assert.AreEqual(-1, FieldDeclarationComparer.Compare(y, x)); Assert.AreEqual(0, FieldDeclarationComparer.Compare(x, x)); Assert.AreEqual(0, FieldDeclarationComparer.Compare(y, y)); }
public static void Compare(FieldDeclarationSyntax x, FieldDeclarationSyntax y) { Assert.AreEqual(-1, FieldDeclarationComparer.Compare(x, y)); Assert.AreEqual(1, FieldDeclarationComparer.Compare(y, x)); Assert.AreEqual(0, FieldDeclarationComparer.Compare(x, x)); Assert.AreEqual(0, FieldDeclarationComparer.Compare(y, y)); }
public static void AttachedProperty(FieldDeclarationSyntax x, FieldDeclarationSyntax y) { Assert.AreEqual(-1, FieldDeclarationComparer.Compare(x, y)); Assert.AreEqual(1, FieldDeclarationComparer.Compare(y, x)); Assert.AreEqual(0, FieldDeclarationComparer.Compare(x, x)); Assert.AreEqual(0, FieldDeclarationComparer.Compare(y, y)); Assert.AreEqual(-1, MemberDeclarationComparer.Compare(x, y)); Assert.AreEqual(1, MemberDeclarationComparer.Compare(y, x)); Assert.AreEqual(0, MemberDeclarationComparer.Compare(x, x)); Assert.AreEqual(0, MemberDeclarationComparer.Compare(y, y)); }
public static void InitializedWithOther(FieldDeclarationSyntax x, FieldDeclarationSyntax y) { Assert.AreEqual(-1, FieldDeclarationComparer.Compare(x, y)); Assert.AreEqual(1, FieldDeclarationComparer.Compare(y, x)); Assert.AreEqual(0, FieldDeclarationComparer.Compare(x, x)); Assert.AreEqual(0, FieldDeclarationComparer.Compare(y, y)); Assert.AreEqual(-1, MemberDeclarationComparer.Compare(x, y)); Assert.AreEqual(1, MemberDeclarationComparer.Compare(y, x)); Assert.AreEqual(0, MemberDeclarationComparer.Compare(x, x)); Assert.AreEqual(0, MemberDeclarationComparer.Compare(y, y)); }
public static void InitializedWithOther() { var syntaxTree = CSharpSyntaxTree.ParseText(@" namespace N { class C { public const int PublicConst1 = PublicConst2; public const int PublicConst2 = 3; } }"); var x = syntaxTree.FindFieldDeclaration("public const int PublicConst1 = PublicConst2"); var y = syntaxTree.FindFieldDeclaration("public const int PublicConst2 = 3"); Assert.AreEqual(1, FieldDeclarationComparer.Compare(x, y)); Assert.AreEqual(-1, FieldDeclarationComparer.Compare(y, x)); Assert.AreEqual(0, FieldDeclarationComparer.Compare(x, x)); Assert.AreEqual(0, FieldDeclarationComparer.Compare(y, y)); }