コード例 #1
0
        public void ToStringIsImplemented()
        {
            var sut = new VariableReference {
                Identifier = "xyz"
            };
            var          actual   = sut.ToString();
            const string expected = "VariableReference(xyz)";

            Assert.AreEqual(expected, actual);
        }
コード例 #2
0
        public static string GetName(this VariableReference self, MethodBody body)
        {
            if (self == null)
            {
                return(String.Empty);
            }

            var def = self.Resolve();

            if (def == null)
            {
                return(self.ToString());
            }

            return(GetVariableName(def, body));
        }
コード例 #3
0
        public static string GetName(this VariableReference self, MethodDebugInformation debugInfo)
        {
            if (self == null)
            {
                return(String.Empty);
            }

            // as per commit 7cde491752861a331e091dca601748e9f0741e95 of Mono.Cecil, VariableReference do not have Name anymore
            if (debugInfo != null)
            {
                if (debugInfo.TryGetName((VariableDefinition)self, out var name))
                {
                    return(name);
                }
            }

            return(self.ToString());
        }
コード例 #4
0
 public void Visit(VariableReference variableReference)
 {
     _result += variableReference.ToString();
 }
コード例 #5
0
        public void It_has_a_useful_ToString_method()
        {
            var a = new VariableReference("a");

            Assert.AreEqual("VariableReference(\"a\")", a.ToString());
        }
コード例 #6
0
        public void It_has_a_useful_ToString_method()
        {
            var a = new VariableReference("a");

            Assert.AreEqual("VariableReference(\"a\")", a.ToString());
        }