public Assembler(ISanitiser sanitiser, IInstructionParser instructionParser, IBinaryAssembler binaryAssembler, ISymbolResolver symbolResolver) { _sanitiser = sanitiser; _instructionParser = instructionParser; _binaryAssembler = binaryAssembler; _symbolResolver = symbolResolver; }
public CompilationContext(ICompilerStore store, IFactory <ILinkingInfo> linkingInfoFactory, ISymbolResolver symbolResolver, StorageManager storageManager) { Symbols = symbolResolver; Storage = storageManager; Linking = linkingInfoFactory.Create(); _store = store; _linkingInfoFactory = linkingInfoFactory; }
private COMProxyInterfaceInstance(COMCLSIDEntry clsid, ISymbolResolver resolver, COMInterfaceEntry intf, COMRegistry registry) { NdrParser parser = new NdrParser(resolver); Entry = parser.ReadFromComProxyFile(clsid.DefaultServer, clsid.Clsid, new Guid[] { intf.Iid }).FirstOrDefault(); ComplexTypes = parser.ComplexTypes; OriginalName = intf.Name; ClassEntry = clsid; m_registry = registry; }
private static Guid GetProcessAppId(NtProcess process, ISymbolResolver resolver) { IntPtr appid = AddressFromSymbol(resolver, process.Is64Bit, GetSymbolName("g_AppId")); if (appid == IntPtr.Zero) { return(Guid.Empty); } return(process.ReadStruct <Guid>(appid.ToInt64())); }
internal NdrParseContext(NdrTypeCache type_cache, ISymbolResolver symbol_resolver, MIDL_STUB_DESC stub_desc, IntPtr type_desc, int desc_size, IMemoryReader reader) { TypeCache = type_cache; SymbolResolver = symbol_resolver; StubDesc = stub_desc; TypeDesc = type_desc; CorrDescSize = desc_size; Reader = reader; }
public static int ReadInt(NtProcess process, ISymbolResolver resolver, string symbol) { IntPtr p = AddressFromSymbol(resolver, process.Is64Bit, GetSymbolName(symbol)); if (p != IntPtr.Zero) { return(process.ReadStruct <int>(p.ToInt64())); } return(0); }
private static string ReadString(NtProcess process, ISymbolResolver resolver, string symbol) { IntPtr str = AddressFromSymbol(resolver, process.Is64Bit, GetSymbolName(symbol)); if (str != IntPtr.Zero) { return(ReadUnicodeString(process, str)); } return(String.Empty); }
public CircuitMagic(ISymbolResolver resolver, ISnippets snippets, ILogger <Workspace> logger, IReferences references) : base( "circuit", new Documentation { Summary = "Takes a given function or operation and generates the quantum circuit it represents." }) { this.SymbolResolver = resolver; this.Snippets = (Snippets)snippets; this.Logger = logger; this.GlobalReferences = references; }
private static void CheckSymbolResolver(NtProcess process, ISymbolResolver symbol_resolver) { int pid = process == null ? NtProcess.Current.ProcessId : process.ProcessId; if (symbol_resolver is DbgHelpSymbolResolver dbghelp_resolver) { if (dbghelp_resolver.Process.ProcessId != pid) { throw new ArgumentException("Symbol resolver must be for the same process as the passed process"); } } }
public static COMProxyInstance GetFromFile(string path, ISymbolResolver resolver, COMRegistry registry) { if (m_proxies_by_file.ContainsKey(path)) { return(m_proxies_by_file[path]); } else { COMProxyInstance proxy = new COMProxyInstance(path, resolver, registry); m_proxies_by_file[path] = proxy; return(proxy); } }
internal NdrParseContext(NdrTypeCache type_cache, ISymbolResolver symbol_resolver, MIDL_STUB_DESC stub_desc, IntPtr type_desc, NDR_EXPR_DESC expr_desc, NdrInterpreterOptFlags2 opt_flags, IMemoryReader reader, NdrParserFlags parser_flags) { TypeCache = type_cache; SymbolResolver = symbol_resolver; StubDesc = stub_desc; TypeDesc = type_desc; ExprDesc = expr_desc; OptFlags = opt_flags; Reader = reader; Flags = parser_flags; }
public static COMProxyInstance GetFromCLSID(COMCLSIDEntry clsid, ISymbolResolver resolver) { if (m_proxies.ContainsKey(clsid.Clsid)) { return(m_proxies[clsid.Clsid]); } else { COMProxyInstance proxy = new COMProxyInstance(clsid.DefaultServer, clsid.Clsid, resolver, clsid.Database); m_proxies[clsid.Clsid] = proxy; return(proxy); } }
public TextDocumentLoader( IDafnyParser parser, ISymbolResolver symbolResolver, IProgramVerifier verifier, ISymbolTableFactory symbolTableFactory, IVerificationNotificationPublisher notificationPublisher ) { _parser = parser; _symbolResolver = symbolResolver; _verifier = verifier; _symbolTableFactory = symbolTableFactory; _notificationPublisher = notificationPublisher; }
/// <summary> /// Constructs a new magic command given a resolver used to find /// operations and functions, and a configuration source used to set /// configuration options. /// </summary> public TraceMagic(ISymbolResolver resolver, IConfigurationSource configurationSource, ILogger <TraceMagic> logger) : base( "trace", new Microsoft.Jupyter.Core.Documentation { Summary = "Visualizes the execution path of the given operation.", Description = $@" This magic command renders an HTML-based visualization of a runtime execution path of the given operation using the QuantumSimulator. #### Required parameters - Q# operation or function name. This must be the first parameter, and must be a valid Q# operation or function name that has been defined either in the notebook or in a Q# file in the same folder. - Arguments for the Q# operation or function must also be specified as `key=value` pairs. #### Optional parameters - `{ParameterNameDepth}=<integer>` (default=1): The depth at which to render operations along the execution path. ".Dedent(), Examples = new[] { @" Visualize the execution path of a Q# operation defined as `operation MyOperation() : Result`: ``` In []: %trace MyOperation Out[]: <HTML visualization of the operation> ``` ".Dedent(), @" Visualize the execution path of a Q# operation defined as `operation MyOperation(a : Int, b : Int) : Result`: ``` In []: %trace MyOperation a=5 b=10 Out[]: <HTML visualization of the operation> ``` ".Dedent(), $@" Visualize operations at depth 2 on the execution path of a Q# operation defined as `operation MyOperation() : Result`: ``` In []: %trace MyOperation {ParameterNameDepth}=2 Out[]: <HTML visualization of the operation> ``` ".Dedent(), } }, logger) { this.SymbolResolver = resolver; this.ConfigurationSource = configurationSource; }
public static void PrepareSolution(TestContext context) { DTE.Solution.Open(Path.Combine(SolutionDir, "TestBed.sln")); componentModel = (IComponentModel)VsIdeTestHostContext.ServiceProvider.GetService(typeof(SComponentModel)); fileName = Path.GetFullPath(Path.Combine(SolutionDir, "Basic", "File.vb")); DTE.ItemOperations.OpenFile(fileName).Activate(); textView = GetCurentTextView(); isRoslyn = RoslynUtilities.IsRoslynInstalled(VsIdeTestHostContext.ServiceProvider); if (isRoslyn) resolver = new RoslynSymbolResolver(); else resolver = new VBResolver(); }
public BicepDefinitionHandler( ISymbolResolver symbolResolver, ICompilationManager compilationManager, IFileResolver fileResolver, IWorkspace workspace, ILanguageServerFacade languageServer, IModuleDispatcher moduleDispatcher) : base() { this.symbolResolver = symbolResolver; this.compilationManager = compilationManager; this.fileResolver = fileResolver; this.workspace = workspace; this.languageServer = languageServer; this.moduleDispatcher = moduleDispatcher; }
public X86DisassemblyContentProviderFactory(X86DisassemblyContentProviderFactoryDependencies deps, int bitness, DisassemblyContentFormatterOptions formatterOptions, ISymbolResolver symbolResolver, string header, NativeCodeOptimization optimization, NativeCodeBlock[] blocks, NativeCodeInfo codeInfo, NativeVariableInfo[] variableInfo, string methodName) { if (blocks == null) { throw new ArgumentNullException(nameof(blocks)); } this.deps = deps ?? throw new ArgumentNullException(nameof(deps)); this.bitness = bitness; this.formatterOptions = formatterOptions; this.symbolResolver = symbolResolver; this.header = header; this.optimization = optimization; this.blocks = blocks ?? throw new ArgumentNullException(nameof(blocks)); this.codeInfo = codeInfo as X86NativeCodeInfo; this.variableInfo = variableInfo; this.methodName = methodName; }
public IEnumerable <ParseNode> Select(object symbol, ISymbolResolver resolver) { if (null == resolver) { throw new ArgumentNullException("resolver"); } var ic = Children.Count; for (var i = 0; i < ic; ++i) { var child = Children[i]; if (Equals(symbol, resolver.GetSymbolById(child.SymbolId))) { yield return(child); } } }
static List <COMIPIDEntry> ParseIPIDEntries(NtProcess process, ISymbolResolver resolver) { IntPtr ipid_table = AddressFromSymbol(resolver, process.Is64Bit, GetSymbolName("CIPIDTable::_palloc")); if (ipid_table == IntPtr.Zero) { return(new List <COMIPIDEntry>()); } if (process.Is64Bit) { return(ParseIPIDEntries <IPIDEntryNative>(process, ipid_table, resolver)); } else { return(ParseIPIDEntries <IPIDEntryNative32>(process, ipid_table, resolver)); } }
internal static IntPtr AddressFromSymbol(ISymbolResolver resolver, bool is64bit, string symbol) { Dictionary <string, IntPtr> resolved = is64bit ? _resolved_64bit : _resolved_32bit; if (resolved.ContainsKey(symbol)) { return(resolved[symbol]); } IntPtr ret = resolver.GetAddressOfSymbol(symbol); if (ret != IntPtr.Zero) { resolved[symbol] = ret; } return(ret); }
/// <summary> /// Initializes a new instance of the <see cref="ChpMagic"/> class. /// Default constructor. /// </summary> /// <param name="resolver">Symbol resolver.</param> /// <param name="configurationSource">Source for confirgarion settings.</param> public ChpMagic(ISymbolResolver resolver, IConfigurationSource configurationSource) : base( "chp", new Documentation { Summary = "Runs a given function or operation on the StabilizerSimulator target machine.", Description = @" This magic command allows executing a given function or operation on the StabilizerSimulator, which performs a simulation of the given function or operation in which the state can always be represented by a stabilizer of the form described by CHP, and prints the resulting return value. See the [StabilizerSimulator user guide](https://github.com/qsharp-community/chp-sim/docs/user-guide.md) to learn more. #### Required parameters - Q# operation or function name. This must be the first parameter, and must be a valid Q# operation or function name that has been defined either in the notebook or in a Q# file in the same folder. - Arguments for the Q# operation or function must also be specified as `key=value` pairs. ", Examples = new[] { @" Use the StabilizerSimulator to simulate a Q# operation defined as `operation MyOperation() : Result`: ``` In []: %chp MyOperation Out[]: <return value of the operation> ``` ", @" Use the StabilizerSimulator to simulate a Q# operation defined as `operation MyOperation(a : Int, b : Int) : Result`: ``` In []: %chp MyOperation a=5 b=10 Out[]: <return value of the operation> ``` ", }, }) { this.SymbolResolver = resolver; this.configurationSource = configurationSource; }
public DebugMagic( ISymbolResolver resolver, IConfigurationSource configurationSource, IShellRouter router, IShellServer shellServer, ILogger <DebugMagic>?logger ) : base( "debug", new Microsoft.Jupyter.Core.Documentation { Summary = "Steps through the execution of a given Q# operation or function.", Description = $@" This magic command allows for stepping through the execution of a given Q# operation or function using the QuantumSimulator. #### Required parameters - Q# operation or function name. This must be the first parameter, and must be a valid Q# operation or function name that has been defined either in the notebook or in a Q# file in the same folder. - Arguments for the Q# operation or function must also be specified as `key=value` pairs. ".Dedent(), Examples = new[] { @" Step through the execution of a Q# operation defined as `operation MyOperation() : Result`: ``` In []: %debug MyOperation Out[]: <interactive HTML for stepping through the operation> ``` ".Dedent(), @" Step through the execution of a Q# operation defined as `operation MyOperation(a : Int, b : Int) : Result`: ``` In []: %debug MyOperation a=5 b=10 Out[]: <interactive HTML for stepping through the operation> ``` ".Dedent(), } }) { this.SymbolResolver = resolver; this.ConfigurationSource = configurationSource; this.ShellServer = shellServer; this.Logger = logger; router.RegisterHandler("iqsharp_debug_advance", this.HandleAdvanceMessage); }
public static void PrepareSolution(TestContext context) { DTE.Solution.Open(Path.Combine(SolutionDir, "TestBed.sln")); componentModel = (IComponentModel)VsIdeTestHostContext.ServiceProvider.GetService(typeof(SComponentModel)); fileName = Path.GetFullPath(Path.Combine(SolutionDir, "Basic", "File.vb")); DTE.ItemOperations.OpenFile(fileName).Activate(); textView = GetCurentTextView(); isRoslyn = RoslynUtilities.IsRoslynInstalled(VsIdeTestHostContext.ServiceProvider); if (isRoslyn) { resolver = new RoslynSymbolResolver(); } else { resolver = new VBResolver(); } }
public static COMProxyInterfaceInstance GetFromIID(COMInterfaceEntry intf, ISymbolResolver resolver) { if (intf == null || !intf.HasProxy) { throw new ArgumentException($"Interface {intf.Name} doesn't have a registered proxy"); } COMCLSIDEntry clsid = intf.ProxyClassEntry; if (m_proxies.ContainsKey(intf.Iid)) { return(m_proxies[intf.Iid]); } else { var instance = new COMProxyInterfaceInstance(clsid, resolver, intf, clsid.Database); m_proxies[intf.Iid] = instance; return(instance); } }
private static void FixupStructureNames(List <NdrProcedureDefinition> procs, ISymbolResolver symbol_resolver, NdrParserFlags parser_flags) { if (!parser_flags.HasFlagSet(NdrParserFlags.ResolveStructureNames) || !(symbol_resolver is ISymbolTypeResolver type_resolver)) { return; } var complex_types = new Dictionary <NdrComplexTypeReference, UserDefinedTypeInformation>(); foreach (var proc in procs) { if (!(type_resolver.GetTypeForSymbolByAddress(proc.DispatchFunction) is FunctionTypeInformation func_type)) { continue; } if (func_type.Parameters.Count != proc.Params.Count) { continue; } for (int i = 0; i < func_type.Parameters.Count; ++i) { proc.Params[i].Name = func_type.Parameters[i].Name; UpdateComplexTypes(complex_types, func_type.Parameters[i].ParameterType, proc.Params[i].Type); } if (proc.ReturnValue != null && func_type.ReturnType != null) { UpdateComplexTypes(complex_types, func_type.ReturnType, proc.ReturnValue.Type); } } HashSet <NdrComplexTypeReference> fixup_set = new HashSet <NdrComplexTypeReference>(); foreach (var pair in complex_types) { FixupComplexType(fixup_set, pair.Key, pair.Value); } }
/// <summary> /// Default constructor. /// </summary> public ToffoliMagic(ISymbolResolver resolver, ILogger <ToffoliMagic> logger) : base( "toffoli", new Microsoft.Jupyter.Core.Documentation { Summary = "Runs a given function or operation on the ToffoliSimulator target machine.", Description = @" This magic command allows executing a given function or operation on the ToffoliSimulator, which performs a simulation of the given function or operation in which the state is always a simple product state in the computational basis, and prints the resulting return value. See the [ToffoliSimulator user guide](https://docs.microsoft.com/quantum/user-guide/machines/toffoli-simulator) to learn more. #### Required parameters - Q# operation or function name. This must be the first parameter, and must be a valid Q# operation or function name that has been defined either in the notebook or in a Q# file in the same folder. - Arguments for the Q# operation or function must also be specified as `key=value` pairs. ".Dedent(), Examples = new [] { @" Use the ToffoliSimulator to simulate a Q# operation defined as `operation MyOperation() : Result`: ``` In []: %toffoli MyOperation Out[]: <return value of the operation> ``` ".Dedent(), @" Use the ToffoliSimulator to simulate a Q# operation defined as `operation MyOperation(a : Int, b : Int) : Result`: ``` In []: %toffoli MyOperation a=5 b=10 Out[]: <return value of the operation> ``` ".Dedent(), } }, logger) { this.SymbolResolver = resolver; }
/// <summary> /// Constructs a new magic command given a resolver used to find /// operations and functions, and a configuration source used to set /// configuration options. /// </summary> public SimulateMagic(ISymbolResolver resolver, IConfigurationSource configurationSource, IPerformanceMonitor monitor, ILogger <SimulateMagic> logger) : base( "simulate", new Microsoft.Jupyter.Core.Documentation { Summary = "Runs a given function or operation on the QuantumSimulator target machine.", Description = @" This magic command allows executing a given function or operation on the QuantumSimulator, which performs a full-state simulation of the given function or operation and prints the resulting return value. See the [QuantumSimulator user guide](https://docs.microsoft.com/azure/quantum/user-guide/machines/full-state-simulator) to learn more. #### Required parameters - Q# operation or function name. This must be the first parameter, and must be a valid Q# operation or function name that has been defined either in the notebook or in a Q# file in the same folder. - Arguments for the Q# operation or function must also be specified as `key=value` pairs. ".Dedent(), Examples = new [] { @" Simulate a Q# operation defined as `operation MyOperation() : Result`: ``` In []: %simulate MyOperation Out[]: <return value of the operation> ``` ".Dedent(), @" Simulate a Q# operation defined as `operation MyOperation(a : Int, b : Int) : Result`: ``` In []: %simulate MyOperation a=5 b=10 Out[]: <return value of the operation> ``` ".Dedent(), } }, logger) { this.SymbolResolver = resolver; this.ConfigurationSource = configurationSource; this.Monitor = monitor; }
private void OnFormShown(object sender, EventArgs e) { ISymbolResolver resolver = CreateResolver(m_Replay); if (resolver != null) { if (resolver.NeedsExePath) { using (var fd = new OpenFileDialog()) { fd.Title = "Select Executable File"; fd.CheckFileExists = true; var ext = resolver.ExeExtension; fd.Filter = "Executable Files (*" + ext + ")|*" + ext + "|All files(*.*)|*.*"; switch (fd.ShowDialog()) { case DialogResult.OK: resolver.BeginResolve(fd.FileName, this, m_Replay, m_Options.SymbolPaths, m_Options.ModulePathRemappings); break; default: m_Done = true; this.Close(); break; } } } else { resolver.BeginResolve(null, this, m_Replay, m_Options.SymbolPaths, m_Options.ModulePathRemappings); } } else { MessageBox.Show("Sorry, don't know how to resolve symbols for this platform yet"); m_Done = true; } }
public static COMProcessEntry ParseProcess(int pid, string dbghelp_path, string symbol_path) { using (var result = NtProcess.Open(pid, ProcessAccessRights.VmRead | ProcessAccessRights.QueryInformation, false)) { if (!result.IsSuccess) { return(null); } NtProcess process = result.Result; if (process.Is64Bit && !Environment.Is64BitProcess) { return(null); } using (ISymbolResolver resolver = SymbolResolver.Create(process, dbghelp_path, symbol_path)) { Sid user = process.User; return(new COMProcessEntry( pid, GetProcessFileName(process), ParseIPIDEntries(process, resolver), process.Is64Bit, GetProcessAppId(process, resolver), GetProcessAccessSecurityDescriptor(process, resolver), GetLrpcSecurityDescriptor(process, resolver), user.Name, user.ToString(), ReadString(process, resolver, "gwszLRPCEndPoint"), ReadEnum <EOLE_AUTHENTICATION_CAPABILITIES>(process, resolver, "gCapabilities"), ReadEnum <RPC_AUTHN_LEVEL>(process, resolver, "gAuthnLevel"), ReadEnum <RPC_IMP_LEVEL>(process, resolver, "gImpLevel"), ReadPointer(process, resolver, "gAccessControl"), ReadPointer(process, resolver, "ghwndOleMainThread"))); } } }
public async Task CSharpMetadataTest() { // Hop on to the UI thread so the language service APIs work await Application.Current.Dispatcher.NextFrame(DispatcherPriority.ApplicationIdle); // Use a type that is not in the public reference source textView.Caret.MoveTo(textView.FindSpan("System.IO.Log.LogStore").End); GetCurrentNativeTextView().Execute(VSConstants.VSStd97CmdID.GotoDefn); var metadataTextView = GetCurentTextView(); var docService = componentModel.GetService <ITextDocumentFactoryService>(); ITextDocument document; Assert.IsTrue(docService.TryGetTextDocument(metadataTextView.TextDataModel.DocumentBuffer, out document)); if (!RoslynUtilities.IsRoslynInstalled(VsIdeTestHostContext.ServiceProvider)) { var symbol = new CSharp10Resolver(DTE).GetSymbolAt(document.FilePath, metadataTextView.FindSpan("public LogStore(SafeFileHandle").End); Assert.IsNull(symbol); // CSharp10Resolver cannot get a Compilation for metadata as source, but must not crash. } ISymbolResolver resolver = null; if (RoslynUtilities.IsRoslynInstalled(VsIdeTestHostContext.ServiceProvider)) { resolver = new RoslynSymbolResolver(); } else if (DTE.Version == "12.0") { resolver = new CSharp12Resolver(); } if (resolver == null) { var symbol = resolver.GetSymbolAt(document.FilePath, metadataTextView.FindSpan("public LogStore(SafeFileHandle").End); Assert.IsFalse(symbol.HasLocalSource); Assert.AreEqual("mscorlib", symbol.AssemblyName); Assert.AreEqual("T:Microsoft.Win32.SafeHandles.SafeFileHandle", symbol.IndexId); } }
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 }
public override SyntaxNode ModifyDocument(SyntaxTree ast, SemanticModel model, ISymbolResolver symbolResolver, AnalyzerMessageCallback messageCallback, out bool modified) { try { var baseRewriter = new FIBaseRewriter(model, messageCallback, ast.FilePath); var newRoot = baseRewriter.Visit(ast.GetRoot()); modified = baseRewriter.wasModified; //if (modified) // messageCallback(AnalyzerMessageType.Info, "FI_Providers analyzer codegen output:\n" + newRoot, ast.FilePath, 0, 0); return(newRoot); } catch (Exception e) { messageCallback( AnalyzerMessageType.Error, string.Format("Error in FI_Providers analyzer:\n{0}\n{1}", e.Message, e.StackTrace), ast.FilePath, 0, 0); } modified = false; return(ast.GetRoot()); }
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 }
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 }