Esempio n. 1
0
        protected override bool Execute(VSConstants.VSStd97CmdID commandId, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            ISymbolResolver resolver   = null;
            SnapshotPoint?  caretPoint = TextView.GetCaretPoint(s => resolvers.TryGetValue(s.ContentType.TypeName, out resolver));

            if (caretPoint == null)
            {
                return(false);
            }

            var symbol = resolver.GetSymbolAt(doc.FilePath, caretPoint.Value);

            if (symbol == null || symbol.HasLocalSource)
            {
                return(false);
            }

            var target = references.FirstOrDefault(r => r.AvailableAssemblies.Contains(symbol.AssemblyName));

            if (target == null)
            {
                return(false);
            }

            Debug.WriteLine("Ref12: Navigating to IndexID " + symbol.IndexId);

            target.Navigate(symbol);
            return(true);
        }
Esempio n. 2
0
        private async Task TestCSharpResolver(ISymbolResolver resolver)
        {
            // Hop on to the UI thread so the language service APIs work
            await Application.Current.Dispatcher.NextFrame();

            var symbol = resolver.GetSymbolAt(fileName, textView.FindSpan("\"\".Aggregate").End);

            Assert.IsFalse(symbol.HasLocalSource);
            Assert.AreEqual("System.Core", symbol.AssemblyName);
            Assert.AreEqual("M:System.Linq.Enumerable.Aggregate``2(System.Collections.Generic.IEnumerable{``0},``1,System.Func{``1,``0,``1})", symbol.IndexId);

            symbol = resolver.GetSymbolAt(fileName, textView.FindSpan("M(").End - 1);
            Assert.IsTrue(symbol.HasLocalSource);
            Assert.AreEqual("M:CSharp.File.A`1.B`1.M``1(`0,`1,`0,``0)", symbol.IndexId);

            symbol = resolver.GetSymbolAt(fileName, textView.FindSpan("\tInterlocked.Add").End);
            Assert.AreEqual("M:System.Threading.Interlocked.Add(System.Int32@,System.Int32)", symbol.IndexId);

            symbol = resolver.GetSymbolAt(fileName, textView.FindSpan("\tstring.Join").End);
            Assert.AreEqual("M:System.String.Join(System.String,System.String[])", symbol.IndexId);

            symbol = resolver.GetSymbolAt(fileName, textView.FindSpan("{ Arrr").End);
            Assert.AreEqual("M:CSharp.File.Arrr(System.Int32[0:,0:,0:][])", symbol.IndexId);

            symbol = resolver.GetSymbolAt(fileName, textView.FindSpan("int.TryParse").End);
            Assert.AreEqual("M:System.Int32.TryParse(System.String,System.Int32@)", symbol.IndexId);

            symbol = resolver.GetSymbolAt(fileName, textView.FindSpan("System.Globalization").End);
            Assert.IsNull(symbol);                      // Ignore namespaces

            symbol = resolver.GetSymbolAt(fileName, textView.FindSpan("e.Message + c").End);
            Assert.IsNull(symbol);                      // Don't crash on lambda parameters

            symbol = resolver.GetSymbolAt(fileName, textView.FindSpan("ref y").End);
            Assert.IsNull(symbol);                      // Don't crash on locals
        }
Esempio n. 3
0
		private async Task TestCSharpResolver(ISymbolResolver resolver) {
			// Hop on to the UI thread so the language service APIs work
			await Application.Current.Dispatcher.NextFrame();

			var symbol = resolver.GetSymbolAt(fileName, textView.FindSpan("\"\".Aggregate").End);
			Assert.IsFalse(symbol.HasLocalSource);
			Assert.AreEqual("System.Core", symbol.AssemblyName);
			Assert.AreEqual("M:System.Linq.Enumerable.Aggregate``2(System.Collections.Generic.IEnumerable{``0},``1,System.Func{``1,``0,``1})", symbol.IndexId);

			symbol = resolver.GetSymbolAt(fileName, textView.FindSpan("M(").End - 1);
			Assert.IsTrue(symbol.HasLocalSource);
			Assert.AreEqual("M:CSharp.File.A`1.B`1.M``1(`0,`1,`0,``0)", symbol.IndexId);

			symbol = resolver.GetSymbolAt(fileName, textView.FindSpan("\tInterlocked.Add").End);
			Assert.AreEqual("M:System.Threading.Interlocked.Add(System.Int32@,System.Int32)", symbol.IndexId);
			
			symbol = resolver.GetSymbolAt(fileName, textView.FindSpan("\tstring.Join").End);
			Assert.AreEqual("M:System.String.Join(System.String,System.String[])", symbol.IndexId);

			symbol = resolver.GetSymbolAt(fileName, textView.FindSpan("{ Arrr").End);
			Assert.AreEqual("M:CSharp.File.Arrr(System.Int32[0:,0:,0:][])", symbol.IndexId);
			
			symbol = resolver.GetSymbolAt(fileName, textView.FindSpan("int.TryParse").End);
			Assert.AreEqual("M:System.Int32.TryParse(System.String,System.Int32@)", symbol.IndexId);

			symbol = resolver.GetSymbolAt(fileName, textView.FindSpan("e.Message + c").End);
			Assert.IsNull(symbol);		// Don't crash on lambda parameters

			symbol = resolver.GetSymbolAt(fileName, textView.FindSpan("ref y").End);
			Assert.IsNull(symbol);		// Don't crash on locals
		}
Esempio n. 4
0
		private async Task TestCSharpResolver(ISymbolResolver resolver) {
			// Hop on to the UI thread so the language service APIs work
			await Application.Current.Dispatcher.NextFrame();

			var symbol = resolver.GetSymbolAt(fileName, textView.FindSpan("\"\".Aggregate").End);
			Assert.IsFalse(symbol.HasLocalSource);
			Assert.AreEqual("System.Core", symbol.AssemblyName);
			Assert.AreEqual("M:System.Linq.Enumerable.Aggregate``2(System.Collections.Generic.IEnumerable{``0},``1,System.Func{``1,``0,``1})", symbol.IndexId);

			symbol = resolver.GetSymbolAt(fileName, textView.FindSpan("void M<").End - 1);
			Assert.IsTrue(symbol.HasLocalSource);
			Assert.AreEqual("M:CSharp.File.A`1.B`1.M``1(`0,`1,`0,``0)", symbol.IndexId);

			symbol = resolver.GetSymbolAt(fileName, textView.FindSpan("e.Message + c").End);
			Assert.IsNull(symbol);		// Don't crash on lambda parameters
		}
Esempio n. 5
0
        public async Task VBResolverTypeTests()
        {
            // Hop on to the UI thread so the language service APIs work
            await Application.Current.Dispatcher.NextFrame();

            var symbol = resolver.GetSymbolAt(fileName, textView.FindSpan("Inherits Lazy").End);

            Assert.AreEqual("mscorlib", symbol.AssemblyName);
            Assert.AreEqual("T:System.Lazy`1", symbol.IndexId);

            symbol = resolver.GetSymbolAt(fileName, textView.FindSpan("AddHandler Microsoft.Win32").End);
            Assert.IsNull(symbol, "Namespaces should not be resolved");

            symbol = resolver.GetSymbolAt(fileName, textView.FindSpan("New List(Of Func").End);
            Assert.AreEqual("T:System.Func`2", symbol.IndexId);
        }