/// <summary> /// Used to lazily calculate operations in an assembly. /// Assumes that all Types in the Assembly are for operations. /// </summary> private OperationInfo[] InitOperations() { if (Assembly == null) { return(new OperationInfo[0]); } // Parse the assembly headers to find which types are operation or function types. var logger = new QSharpLogger(null); var refs = ProjectManager.LoadReferencedAssemblies(new[] { Location }, d => logger.Log(d), ex => logger.Log(ex), ignoreDllResources: CompilerMetadata.LoadFromCsharp); var callables = refs.SelectMany(pair => pair.Value.Callables); var ops = new List <OperationInfo>(); foreach (var callable in callables) { // Find the associated type. var fullName = callable.QualifiedName.ToFullName(); var type = Assembly.GetType(fullName); var info = new OperationInfo(type, callable); ops.Add(info); } // Makes sure Deprecated operations are pushed to the bottom so that they are resolved second: return(ops .OrderBy(op => op.Header.Attributes.Any(BuiltIn.MarksDeprecation) ? 1 : 0) .ToArray()); }
/// <summary> /// Builds the corresponding .net core assembly from the code in the given files. /// </summary> public AssemblyInfo BuildFiles(string[] files, CompilerMetadata metadatas, QSharpLogger logger, string dllName) { var sources = ProjectManager.LoadSourceFiles(files, d => logger?.Log(d), ex => logger?.Log(ex)); return(BuildAssembly(sources, metadatas, logger, dllName)); }
/// <summary> /// Builds the Q# syntax tree from the given files. /// The files are given as a list of filenames, as per the format expected by /// the <see cref="Microsoft.Quantum.QsCompiler.CompilationBuilder.ProjectManager.LoadSourceFiles(IEnumerable{string}, Action{VisualStudio.LanguageServer.Protocol.Diagnostic}, Action{Exception})" /> /// method. /// </summary> private static QsCompiler.SyntaxTree.QsNamespace[] BuildQsSyntaxTree(string[] files, QsReferences references, QSharpLogger logger) { var sources = ProjectManager.LoadSourceFiles(files, d => logger?.Log(d), ex => logger?.Log(ex)); return(BuildQsSyntaxTree(sources, references, logger)); }
/// <summary> /// Used to lazily calculate operations in an assembly. /// Assumes that all Types in the Assembly are for operations. /// </summary> private OperationInfo[] InitOperations() { if (Assembly == null) { return(new OperationInfo[0]); } // Parse the assembly headers to find which types are operation or function types. var logger = new QSharpLogger(null); var refs = ProjectManager.LoadReferencedAssemblies(new[] { Location }, d => logger.Log(d), ex => logger.Log(ex)); System.Diagnostics.Debug.Assert(refs.Declarations.Count == 1); var headers = refs.Declarations.Values.First(); var ops = new List <OperationInfo>(); foreach (var header in headers.Callables) { // Find the associated type. var fullName = header.QualifiedName.ToFullName(); var type = Assembly.GetType(fullName); var info = new OperationInfo(type, header); ops.Add(info); } return(ops.ToArray()); }