internal static int Run(string[] args, BuildPaths buildPaths, TextWriter textWriter, IAnalyzerAssemblyLoader analyzerLoader) { FatalError.Handler = FailFast.OnFatalException; var responseFile = Path.Combine(buildPaths.ClientDirectory, CSharpCompiler.ResponseFileName); var compiler = new Csc(responseFile, buildPaths, args, analyzerLoader); return ConsoleUtil.RunWithUtf8Output(compiler.Arguments.Utf8Output, textWriter, tw => compiler.Run(tw)); }
public TestableCompilerServerHost( IAnalyzerAssemblyLoader loader = null, Func<string, MetadataReferenceProperties, PortableExecutableReference> assemblyReferenceProvider = null) : base(ServerUtil.DefaultClientDirectory, ServerUtil.DefaultSdkDirectory) { AnalyzerAssemblyLoader = loader; AssemblyReferenceProvider = assemblyReferenceProvider; }
internal static int Run(string clientDirectory, string sdkDirectory, string[] args, IAnalyzerAssemblyLoader analyzerLoader) { FatalError.Handler = FailFast.OnFatalException; var responseFile = Path.Combine(clientDirectory, VisualBasicCompiler.ResponseFileName); Vbc compiler = new Vbc(responseFile, clientDirectory, Directory.GetCurrentDirectory(), sdkDirectory, args, analyzerLoader); return ConsoleUtil.RunWithOutput(compiler.Arguments.Utf8Output, (textWriterOut, _) => compiler.Run(textWriterOut)); }
public static int Run(CommandLineParser parser, string responseFile, string[] args, string clientDirectory, string baseDirectory, string sdkDirectory, string additionalReferenceDirectories, IAnalyzerAssemblyLoader analyzerLoader, TextWriter output) { return new PhpCompiler(parser, responseFile, args, clientDirectory, baseDirectory, sdkDirectory, additionalReferenceDirectories, analyzerLoader) .Run(output); }
internal static int Run(IEnumerable<string> arguments, IEnumerable<string> extraArguments, RequestLanguage language, CompileFunc compileFunc, IAnalyzerAssemblyLoader analyzerAssemblyLoader) { var client = new DesktopBuildClient(language, compileFunc, analyzerAssemblyLoader); var clientDir = AppDomain.CurrentDomain.BaseDirectory; var sdkDir = RuntimeEnvironment.GetRuntimeDirectory(); var workingDir = Directory.GetCurrentDirectory(); var buildPaths = new BuildPaths(clientDir: clientDir, workingDir: workingDir, sdkDir: sdkDir); var originalArguments = BuildClient.GetCommandLineArgs(arguments).Concat(extraArguments).ToArray(); return client.RunCompilation(originalArguments, buildPaths).ExitCode; }
public VisualStudioAnalyzer(string fullPath, IVsFileChangeEx fileChangeService, HostDiagnosticUpdateSource hostDiagnosticUpdateSource, ProjectId projectId, Workspace workspace, IAnalyzerAssemblyLoader loader, string language) { _fullPath = fullPath; _tracker = new FileChangeTracker(fileChangeService, fullPath); _tracker.UpdatedOnDisk += OnUpdatedOnDisk; _tracker.StartFileChangeListeningAsync(); _tracker.EnsureSubscription(); _hostDiagnosticUpdateSource = hostDiagnosticUpdateSource; _projectId = projectId; _workspace = workspace; _loader = loader; _language = language; }
public Pchp(string[] args, IAnalyzerAssemblyLoader analyzerLoader) :base( PhpCommandLineParser.Default, Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ResponseFileName), CreateArgs(args), AppDomain.CurrentDomain.BaseDirectory, Directory.GetCurrentDirectory(), System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory(), Environment.GetEnvironmentVariable("LIB") + @";C:\Windows\Microsoft.NET\assembly\GAC_MSIL", analyzerLoader) { }
public CommonCompiler(CommandLineParser parser, string responseFile, string[] args, string clientDirectory, string baseDirectory, string sdkDirectoryOpt, string additionalReferenceDirectories, IAnalyzerAssemblyLoader analyzerLoader) { IEnumerable<string> allArgs = args; _clientDirectory = clientDirectory; Debug.Assert(null == responseFile || PathUtilities.IsAbsolute(responseFile)); if (!SuppressDefaultResponseFile(args) && PortableShim.File.Exists(responseFile)) { allArgs = new[] { "@" + responseFile }.Concat(allArgs); } this.Arguments = parser.Parse(allArgs, baseDirectory, sdkDirectoryOpt, additionalReferenceDirectories); this.MessageProvider = parser.MessageProvider; this.AnalyzerLoader = analyzerLoader; }
/// <summary> /// Creates an AnalyzerFileReference with the given <paramref name="fullPath"/> and <paramref name="assemblyLoader"/>. /// </summary> /// <param name="fullPath">Full path of the analyzer assembly.</param> /// <param name="assemblyLoader">Loader for obtaining the <see cref="Assembly"/> from the <paramref name="fullPath"/></param> public AnalyzerFileReference(string fullPath, IAnalyzerAssemblyLoader assemblyLoader) { if (fullPath == null) { throw new ArgumentNullException(nameof(fullPath)); } if (assemblyLoader == null) { throw new ArgumentNullException(nameof(assemblyLoader)); } _fullPath = fullPath; _diagnosticAnalyzers = new Extensions <DiagnosticAnalyzer>(this, IsDiagnosticAnalyzerAttribute); _assemblyLoader = assemblyLoader; }
internal Vbc( string responseFile, BuildPaths buildPaths, string[] args, IAnalyzerAssemblyLoader analyzerLoader ) : base( VisualBasicCommandLineParser.Default, responseFile, args, buildPaths, Environment.GetEnvironmentVariable("LIB"), analyzerLoader ) { }
/// <summary> /// Run a compilation through the compiler server and print the output /// to the console. If the compiler server fails, run the fallback /// compiler. /// </summary> public static int RunWithConsoleOutput( string[] args, string clientDir, string workingDir, string sdkDir, IAnalyzerAssemblyLoader analyzerLoader, RequestLanguage language, Func <string, string, string[], IAnalyzerAssemblyLoader, int> fallbackCompiler) { args = args.Select(arg => arg.Trim()).ToArray(); bool hasShared; string keepAlive; string errorMessage; List <string> parsedArgs; if (!CommandLineParser.TryParseClientArgs( args, out parsedArgs, out hasShared, out keepAlive, out errorMessage)) { Console.Out.WriteLine(errorMessage); return(CommonCompiler.Failed); } if (hasShared) { var responseTask = TryRunServerCompilation( language, clientDir, workingDir, parsedArgs, default(CancellationToken), keepAlive: keepAlive, libEnvVariable: Environment.GetEnvironmentVariable("LIB")); var response = responseTask.Result; if (response != null) { return(HandleResponse(response)); } } return(fallbackCompiler(clientDir, sdkDir, parsedArgs.ToArray(), analyzerLoader)); }
/// <summary> /// Run a compilation through the compiler server and print the output /// to the console. If the compiler server fails, run the fallback /// compiler. /// </summary> public static int RunWithConsoleOutput( string[] args, string clientDir, string workingDir, string sdkDir, IAnalyzerAssemblyLoader analyzerLoader, RequestLanguage language, Func<string, string, string[], IAnalyzerAssemblyLoader, int> fallbackCompiler) { args = args.Select(arg => arg.Trim()).ToArray(); bool hasShared; string keepAlive; string errorMessage; List<string> parsedArgs; if (!CommandLineParser.TryParseClientArgs( args, out parsedArgs, out hasShared, out keepAlive, out errorMessage)) { Console.Out.WriteLine(errorMessage); return CommonCompiler.Failed; } if (hasShared) { var responseTask = TryRunServerCompilation( language, clientDir, workingDir, parsedArgs, default(CancellationToken), keepAlive: keepAlive, libEnvVariable: Environment.GetEnvironmentVariable("LIB")); var response = responseTask.Result; if (response != null) { return HandleResponse(response, clientDir, sdkDir, analyzerLoader, fallbackCompiler, parsedArgs); } } return fallbackCompiler(clientDir, sdkDir, parsedArgs.ToArray(), analyzerLoader); }
internal VisualBasicCompilerServer( Func <string, MetadataReferenceProperties, PortableExecutableReference> metadataProvider, string[] args, BuildPaths buildPaths, string?libDirectory, IAnalyzerAssemblyLoader analyzerLoader ) : this( metadataProvider, Path.Combine(buildPaths.ClientDirectory, ResponseFileName), args, buildPaths, libDirectory, analyzerLoader ) { }
internal CSharpInteractiveCompiler( string responseFile, BuildPaths buildPaths, string[] args, IAnalyzerAssemblyLoader analyzerLoader ) // Unlike C# compiler we do not use LIB environment variable. It's only supported for historical reasons. : base( CSharpCommandLineParser.Script, responseFile, args, buildPaths, null, analyzerLoader ) { }
/// <summary> /// Creates an AnalyzerFileReference with the given <paramref name="fullPath"/> and <paramref name="assemblyLoader"/>. /// </summary> /// <param name="fullPath">Full path of the analyzer assembly.</param> /// <param name="assemblyLoader">Loader for obtaining the <see cref="Assembly"/> from the <paramref name="fullPath"/></param> public AnalyzerFileReference(string fullPath, IAnalyzerAssemblyLoader assemblyLoader) { if (fullPath == null) { throw new ArgumentNullException(nameof(fullPath)); } if (assemblyLoader == null) { throw new ArgumentNullException(nameof(assemblyLoader)); } _fullPath = fullPath; _lazyAllAnalyzers = default(ImmutableArray <DiagnosticAnalyzer>); _lazyAnalyzersPerLanguage = ImmutableDictionary <string, ImmutableArray <DiagnosticAnalyzer> > .Empty; _assemblyLoader = assemblyLoader; }
internal VisualBasicCompilerServer( Func <string, MetadataReferenceProperties, PortableExecutableReference> metadataProvider, string?responseFile, string[] args, BuildPaths buildPaths, string?libDirectory, IAnalyzerAssemblyLoader analyzerLoader ) : base( VisualBasicCommandLineParser.Default, responseFile, args, buildPaths, libDirectory, analyzerLoader ) { _metadataProvider = metadataProvider; }
public AbstractMSBuildTestFixture(ITestOutputHelper output) : base(output) { _assemblyLoader = new AssemblyLoader(this.LoggerFactory); _analyzerAssemblyLoader = ShadowCopyAnalyzerAssemblyLoader.Instance; // Since we can only load MSBuild once into our process we need to include // prerelease version so that our .NET 7 tests will pass. var configuration = new Dictionary <string, string> { ["sdk:IncludePrereleases"] = bool.TrueString }.ToConfiguration(); _msbuildLocator = MSBuildLocator.CreateDefault(this.LoggerFactory, _assemblyLoader, configuration); // Some tests require MSBuild to be discovered early // to ensure that the Microsoft.Build.* assemblies can be located _msbuildLocator.RegisterDefaultInstance(this.LoggerFactory.CreateLogger("MSBuildTests"), dotNetInfo: null); }
public static int Run( string[] args, string clientDir, string workingDir, string sdkDir, string tempDir, TextWriter textWriter, IAnalyzerAssemblyLoader analyzerLoader ) => Vbc.Run( args, new BuildPaths( clientDir: clientDir, workingDir: workingDir, sdkDir: sdkDir, tempDir: tempDir ), textWriter, analyzerLoader );
public CommonCompiler(CommandLineParser parser, string responseFile, string[] args, string clientDirectory, string baseDirectory, string sdkDirectoryOpt, string additionalReferenceDirectories, IAnalyzerAssemblyLoader assemblyLoader) { IEnumerable<string> allArgs = args; _clientDirectory = clientDirectory; Debug.Assert(null == responseFile || PathUtilities.IsAbsolute(responseFile)); if (!SuppressDefaultResponseFile(args) && File.Exists(responseFile)) { allArgs = new[] { "@" + responseFile }.Concat(allArgs); } this.Arguments = parser.Parse(allArgs, baseDirectory, sdkDirectoryOpt, additionalReferenceDirectories); this.MessageProvider = parser.MessageProvider; this.AssemblyLoader = assemblyLoader; this.EmbeddedSourcePaths = GetEmbedddedSourcePaths(Arguments); if (Arguments.ParseOptions.Features.ContainsKey("debug-determinism")) { EmitDeterminismKey(Arguments, args, baseDirectory, parser); } }
internal static int Run( string[] args, BuildPaths buildPaths, TextWriter textWriter, IAnalyzerAssemblyLoader analyzerLoader ) { FatalError.Handler = FailFast.OnFatalException; var responseFile = Path.Combine( buildPaths.ClientDirectory, VisualBasicCompiler.ResponseFileName ); var compiler = new Vbc(responseFile, buildPaths, args, analyzerLoader); return(ConsoleUtil.RunWithUtf8Output( compiler.Arguments.Utf8Output, textWriter, tw => compiler.Run(tw) )); }
public static bool Check( string baseDirectory, IEnumerable <CommandLineAnalyzerReference> analyzerReferences, IAnalyzerAssemblyLoader loader, ICompilerServerLogger?logger = null) { try { logger?.Log("Begin Analyzer Consistency Check"); return(CheckCore(baseDirectory, analyzerReferences, loader, logger)); } catch (Exception e) { logger?.LogException(e, "Analyzer Consistency Check"); return(false); } finally { logger?.Log("End Analyzer Consistency Check"); } }
public static IServiceProvider Create( ITestOutputHelper testOutput, IOmniSharpEnvironment environment, ILoggerFactory loggerFactory, IAssemblyLoader assemblyLoader, IAnalyzerAssemblyLoader analyzerAssemblyLoader, IMSBuildLocator msbuildLocator, IConfiguration configurationData = null, DotNetCliVersion dotNetCliVersion = DotNetCliVersion.Current, IEventEmitter eventEmitter = null) { eventEmitter = eventEmitter ?? NullEventEmitter.Instance; var dotNetCliService = CreateDotNetCliService(dotNetCliVersion, loggerFactory, eventEmitter); var configuration = CreateConfiguration(configurationData, dotNetCliService); var sharedTextWriter = CreateSharedTextWriter(testOutput); return(new TestServiceProvider( environment, loggerFactory, assemblyLoader, analyzerAssemblyLoader, sharedTextWriter, msbuildLocator, eventEmitter, dotNetCliService, configuration)); }
public static int RunCompiler( string clientDirectory, string[] args, string baseDirectory, string sdkDirectory, string libDirectory, IAnalyzerAssemblyLoader analyzerLoader, TextWriter output, CancellationToken cancellationToken, out bool utf8output) { var compiler = new CSharpCompilerServer(args, clientDirectory, baseDirectory, sdkDirectory, libDirectory, analyzerLoader); utf8output = compiler.Arguments.Utf8Output; foreach (var analyzer in compiler.Arguments.AnalyzerReferences) { CompilerServerFileWatcher.AddPath(analyzer.FilePath); } return(compiler.Run(output, cancellationToken)); }
public static bool Check(string baseDirectory, IEnumerable<CommandLineAnalyzerReference> analyzerReferences, IAnalyzerAssemblyLoader loader, IEnumerable<string> ignorableReferenceNames = null) { if (ignorableReferenceNames == null) { ignorableReferenceNames = s_defaultIgnorableReferenceNames; } try { CompilerServerLogger.Log("Begin Analyzer Consistency Check"); return CheckCore(baseDirectory, analyzerReferences, loader, ignorableReferenceNames); } catch (Exception e) { CompilerServerLogger.LogException(e, "Analyzer Consistency Check"); return false; } finally { CompilerServerLogger.Log("End Analyzer Consistency Check"); } }
public static BuildResponse RunCompiler( string clientDirectory, string[] args, string baseDirectory, string sdkDirectory, string libDirectory, IAnalyzerAssemblyLoader analyzerLoader, CancellationToken cancellationToken) { var compiler = new VisualBasicCompilerServer(args, clientDirectory, baseDirectory, sdkDirectory, libDirectory, analyzerLoader); bool utf8output = compiler.Arguments.Utf8Output; if (!AnalyzerConsistencyChecker.Check(baseDirectory, compiler.Arguments.AnalyzerReferences, analyzerLoader)) { return(new AnalyzerInconsistencyBuildResponse()); } TextWriter output = new StringWriter(CultureInfo.InvariantCulture); int returnCode = compiler.Run(output, cancellationToken); return(new CompletedBuildResponse(returnCode, utf8output, output.ToString(), string.Empty)); }
private TestServiceProvider( IOmniSharpEnvironment environment, ILoggerFactory loggerFactory, IAssemblyLoader assemblyLoader, IAnalyzerAssemblyLoader analyzerAssemblyLoader, ISharedTextWriter sharedTextWriter, IMSBuildLocator msbuildLocator, IEventEmitter eventEmitter, IDotNetCliService dotNetCliService, IConfigurationRoot configuration) { _logger = loggerFactory.CreateLogger <TestServiceProvider>(); var services = _services = new ServiceCollection(); services .AddLogging() .AddOptions() .AddMemoryCache(); services .AddSingleton(environment) .AddSingleton(loggerFactory) .AddSingleton(assemblyLoader) .AddSingleton(sharedTextWriter) .AddSingleton(msbuildLocator) .AddSingleton(eventEmitter) .AddSingleton(dotNetCliService) .AddSingleton(configuration) .AddSingleton(configuration as IConfiguration) .Configure <OmniSharpOptions>(configuration) .PostConfigure <OmniSharpOptions>(OmniSharpOptions.PostConfigure) .AddSingleton(analyzerAssemblyLoader); services.TryAddSingleton(_ => new ManualFileSystemWatcher()); services.TryAddSingleton <IFileSystemNotifier>(_ => _.GetRequiredService <ManualFileSystemWatcher>()); services.TryAddSingleton <IFileSystemWatcher>(_ => _.GetRequiredService <ManualFileSystemWatcher>()); _serviceProvider = services.BuildServiceProvider(); }
public static BuildResponse RunCompiler( string clientDirectory, string[] args, string baseDirectory, string sdkDirectory, string libDirectory, IAnalyzerAssemblyLoader analyzerLoader, CancellationToken cancellationToken) { var compiler = new VisualBasicCompilerServer(args, clientDirectory, baseDirectory, sdkDirectory, libDirectory, analyzerLoader); bool utf8output = compiler.Arguments.Utf8Output; if (!AnalyzerConsistencyChecker.Check(baseDirectory, compiler.Arguments.AnalyzerReferences, analyzerLoader)) { return new AnalyzerInconsistencyBuildResponse(); } TextWriter output = new StringWriter(CultureInfo.InvariantCulture); int returnCode = compiler.Run(output, cancellationToken); return new CompletedBuildResponse(returnCode, utf8output, output.ToString(), string.Empty); }
internal void ResolveAnalyzersFromArguments( string language, List <DiagnosticInfo> diagnostics, CommonMessageProvider messageProvider, IAnalyzerAssemblyLoader analyzerLoader, bool skipAnalyzers, out ImmutableArray <DiagnosticAnalyzer> analyzers, out ImmutableArray <ISourceGenerator> generators) { var analyzerBuilder = ImmutableArray.CreateBuilder <DiagnosticAnalyzer>(); var generatorBuilder = ImmutableArray.CreateBuilder <ISourceGenerator>(); EventHandler <AnalyzerLoadFailureEventArgs> errorHandler = (o, e) => { var analyzerReference = o as AnalyzerFileReference; RoslynDebug.Assert(analyzerReference is object); DiagnosticInfo?diagnostic; switch (e.ErrorCode) { case AnalyzerLoadFailureEventArgs.FailureErrorCode.UnableToLoadAnalyzer: diagnostic = new DiagnosticInfo(messageProvider, messageProvider.WRN_UnableToLoadAnalyzer, analyzerReference.FullPath, e.Message); break; case AnalyzerLoadFailureEventArgs.FailureErrorCode.UnableToCreateAnalyzer: diagnostic = new DiagnosticInfo(messageProvider, messageProvider.WRN_AnalyzerCannotBeCreated, e.TypeName ?? "", analyzerReference.FullPath, e.Message); break; case AnalyzerLoadFailureEventArgs.FailureErrorCode.NoAnalyzers: diagnostic = new DiagnosticInfo(messageProvider, messageProvider.WRN_NoAnalyzerInAssembly, analyzerReference.FullPath); break; case AnalyzerLoadFailureEventArgs.FailureErrorCode.ReferencesFramework: diagnostic = new DiagnosticInfo(messageProvider, messageProvider.WRN_AnalyzerReferencesFramework, analyzerReference.FullPath, e.TypeName !); break; case AnalyzerLoadFailureEventArgs.FailureErrorCode.ReferencesNewerCompiler: diagnostic = new DiagnosticInfo(messageProvider, messageProvider.WRN_AnalyzerReferencesNewerCompiler, analyzerReference.FullPath, e.ReferencedCompilerVersion !.ToString(), typeof(AnalyzerFileReference).Assembly.GetName().Version !.ToString()); break;
public static IServiceProvider Create( ITestOutputHelper testOutput, IOmniSharpEnvironment environment, ILoggerFactory loggerFactory, IAssemblyLoader assemblyLoader, IAnalyzerAssemblyLoader analyzerAssemblyLoader, IMSBuildLocator msbuildLocator, IEnumerable <KeyValuePair <string, string> > configurationData = null, DotNetCliVersion dotNetCliVersion = DotNetCliVersion.Current, IEventEmitter eventEmitter = null) { eventEmitter = eventEmitter ?? NullEventEmitter.Instance; var dotNetCliService = CreateDotNetCliService(dotNetCliVersion, loggerFactory, eventEmitter); var configuration = CreateConfiguration(configurationData, dotNetCliService); var memoryCache = CreateMemoryCache(); var optionsMonitor = CreateOptionsMonitor(configuration); var sharedTextWriter = CreateSharedTextWriter(testOutput); return(new TestServiceProvider( environment, loggerFactory, assemblyLoader, analyzerAssemblyLoader, memoryCache, sharedTextWriter, msbuildLocator, eventEmitter, dotNetCliService, configuration, optionsMonitor)); }
public ProjectManager( ILoggerFactory loggerFactory, MSBuildOptions options, IEventEmitter eventEmitter, IFileSystemWatcher fileSystemWatcher, MetadataFileReferenceCache metadataFileReferenceCache, PackageDependencyChecker packageDependencyChecker, ProjectLoader projectLoader, OmniSharpWorkspace workspace, IAnalyzerAssemblyLoader analyzerAssemblyLoader, ImmutableArray <IMSBuildEventSink> eventSinks, DotNetInfo dotNetInfo) { _logger = loggerFactory.CreateLogger <ProjectManager>(); _options = options ?? new MSBuildOptions(); _eventEmitter = eventEmitter; _fileSystemWatcher = fileSystemWatcher; _metadataFileReferenceCache = metadataFileReferenceCache; _packageDependencyChecker = packageDependencyChecker; _projectFiles = new ProjectFileInfoCollection(); _failedToLoadProjectFiles = new HashSet <string>(StringComparer.OrdinalIgnoreCase); _projectsRequestedOnDemand = new ConcurrentDictionary <string, int>(StringComparer.OrdinalIgnoreCase); _projectLoader = projectLoader; _workspace = workspace; _eventSinks = eventSinks; _dotNetInfo = dotNetInfo; _queue = new BufferBlock <ProjectToUpdate>(); _processLoopCancellation = new CancellationTokenSource(); _processLoopTask = Task.Run(() => ProcessLoopAsync(_processLoopCancellation.Token)); _analyzerAssemblyLoader = analyzerAssemblyLoader; _onDirectoryFileChanged = OnDirectoryFileChanged; if (_options.LoadProjectsOnDemand) { _workspace.AddWaitForProjectModelReadyHandler(WaitForProjectModelReadyAsync); } }
protected CSharpCompiler( CSharpCommandLineParser parser, string?responseFile, string[] args, BuildPaths buildPaths, string?additionalReferenceDirectories, IAnalyzerAssemblyLoader assemblyLoader ) : base( parser, responseFile, args, buildPaths, additionalReferenceDirectories, assemblyLoader ) { _diagnosticFormatter = new CommandLineDiagnosticFormatter( buildPaths.WorkingDirectory, Arguments.PrintFullPaths, Arguments.ShouldIncludeErrorEndLocation ); _tempDirectory = buildPaths.TempDirectory; }
private static int HandleResponse(BuildResponse response, string clientDir, string sdkDir, IAnalyzerAssemblyLoader analyzerLoader, Func<string, string, string[], IAnalyzerAssemblyLoader, int> fallbackCompiler, List<string> parsedArgs) { switch (response.Type) { case BuildResponse.ResponseType.MismatchedVersion: Console.Error.WriteLine(CommandLineParser.MismatchedVersionErrorText); return CommonCompiler.Failed; case BuildResponse.ResponseType.Completed: var completedResponse = (CompletedBuildResponse)response; return ConsoleUtil.RunWithOutput( completedResponse.Utf8Output, (outWriter, errorWriter) => { outWriter.Write(completedResponse.Output); errorWriter.Write(completedResponse.ErrorOutput); return completedResponse.ReturnCode; }); case BuildResponse.ResponseType.AnalyzerInconsistency: return fallbackCompiler(clientDir, sdkDir, parsedArgs.ToArray(), analyzerLoader); default: throw new InvalidOperationException("Encountered unknown response type"); } }
internal VisualBasicCompilerServer(string[] args, string clientDirectory, string baseDirectory, string sdkDirectory, string libDirectory, IAnalyzerAssemblyLoader analyzerLoader) : base(VisualBasicCommandLineParser.Default, clientDirectory != null ? Path.Combine(clientDirectory, ResponseFileName) : null, args, clientDirectory, baseDirectory, sdkDirectory, libDirectory, analyzerLoader) { }
private static IEnumerable <AnalyzerReference> ResolveAnalyzerReferencesForProject(ProjectFileInfo projectFileInfo, IAnalyzerAssemblyLoader analyzerAssemblyLoader) { foreach (var analyzerAssemblyPath in projectFileInfo.Analyzers.Distinct()) { analyzerAssemblyLoader.AddDependencyLocation(analyzerAssemblyPath); } return(projectFileInfo.Analyzers.Select(analyzerCandicatePath => new AnalyzerFileReference(analyzerCandicatePath, analyzerAssemblyLoader))); }
protected CSharpCompiler(CSharpCommandLineParser parser, string responseFile, string[] args, string clientDirectory, string baseDirectory, string sdkDirectoryOpt, string additionalReferenceDirectories, IAnalyzerAssemblyLoader analyzerLoader) : base(parser, responseFile, args, clientDirectory, baseDirectory, sdkDirectoryOpt, additionalReferenceDirectories, analyzerLoader) { _diagnosticFormatter = new CommandLineDiagnosticFormatter(baseDirectory, Arguments.PrintFullPaths, Arguments.ShouldIncludeErrorEndLocation); }
public HostAnalyzerManager(IEnumerable <HostDiagnosticAnalyzerPackage> hostAnalyzerPackages, IAnalyzerAssemblyLoader hostAnalyzerAssemblyLoader, AbstractHostDiagnosticUpdateSource hostDiagnosticUpdateSource) : this(CreateAnalyzerReferencesFromPackages(hostAnalyzerPackages, new HostAnalyzerReferenceDiagnosticReporter(hostDiagnosticUpdateSource), hostAnalyzerAssemblyLoader), hostAnalyzerPackages.ToImmutableArrayOrEmpty(), hostDiagnosticUpdateSource) { }
internal DesktopBuildClient(RequestLanguage language, CompileFunc compileFunc, IAnalyzerAssemblyLoader analyzerAssemblyLoader) { _language = language; _compileFunc = compileFunc; _analyzerAssemblyLoader = analyzerAssemblyLoader; }
internal ImmutableArray <DiagnosticAnalyzer> ResolveAnalyzersFromArguments( string language, List <DiagnosticInfo> diagnostics, CommonMessageProvider messageProvider, IAnalyzerAssemblyLoader analyzerLoader) { var analyzerBuilder = ImmutableArray.CreateBuilder <DiagnosticAnalyzer>(); EventHandler <AnalyzerLoadFailureEventArgs> errorHandler = (o, e) => { var analyzerReference = o as AnalyzerFileReference; DiagnosticInfo diagnostic; switch (e.ErrorCode) { case AnalyzerLoadFailureEventArgs.FailureErrorCode.UnableToLoadAnalyzer: diagnostic = new DiagnosticInfo(messageProvider, messageProvider.WRN_UnableToLoadAnalyzer, analyzerReference.FullPath, e.Message); break; case AnalyzerLoadFailureEventArgs.FailureErrorCode.UnableToCreateAnalyzer: diagnostic = new DiagnosticInfo(messageProvider, messageProvider.WRN_AnalyzerCannotBeCreated, e.TypeName, analyzerReference.FullPath, e.Message); break; case AnalyzerLoadFailureEventArgs.FailureErrorCode.NoAnalyzers: diagnostic = new DiagnosticInfo(messageProvider, messageProvider.WRN_NoAnalyzerInAssembly, analyzerReference.FullPath); break; case AnalyzerLoadFailureEventArgs.FailureErrorCode.None: default: return; } // Filter this diagnostic based on the compilation options so that /nowarn and /warnaserror etc. take effect. diagnostic = messageProvider.FilterDiagnosticInfo(diagnostic, this.CompilationOptions); if (diagnostic != null) { diagnostics.Add(diagnostic); } }; var resolvedReferences = ArrayBuilder <AnalyzerFileReference> .GetInstance(); foreach (var reference in AnalyzerReferences) { var resolvedReference = ResolveAnalyzerReference(reference, analyzerLoader); if (resolvedReference != null) { resolvedReferences.Add(resolvedReference); // register the reference to the analyzer loader: analyzerLoader.AddDependencyLocation(resolvedReference.FullPath); } else { diagnostics.Add(new DiagnosticInfo(messageProvider, messageProvider.ERR_MetadataFileNotFound, reference.FilePath)); } } // All analyzer references are registered now, we can start loading them: foreach (var resolvedReference in resolvedReferences) { resolvedReference.AnalyzerLoadFailed += errorHandler; resolvedReference.AddAnalyzers(analyzerBuilder, language); resolvedReference.AnalyzerLoadFailed -= errorHandler; } resolvedReferences.Free(); return(analyzerBuilder.ToImmutable()); }
internal DesktopBuildClient(RequestLanguage language, CompileFunc compileFunc, IAnalyzerAssemblyLoader analyzerAssemblyLoader) { _language = language; _compileFunc = compileFunc; _analyzerAssemblyLoader = analyzerAssemblyLoader; }
internal ImmutableArray<DiagnosticAnalyzer> ResolveAnalyzersFromArguments( string language, List<DiagnosticInfo> diagnostics, CommonMessageProvider messageProvider, IAnalyzerAssemblyLoader analyzerLoader) { var analyzerBuilder = ImmutableArray.CreateBuilder<DiagnosticAnalyzer>(); EventHandler<AnalyzerLoadFailureEventArgs> errorHandler = (o, e) => { var analyzerReference = o as AnalyzerFileReference; DiagnosticInfo diagnostic; switch (e.ErrorCode) { case AnalyzerLoadFailureEventArgs.FailureErrorCode.UnableToLoadAnalyzer: diagnostic = new DiagnosticInfo(messageProvider, messageProvider.WRN_UnableToLoadAnalyzer, analyzerReference.FullPath, e.Message); break; case AnalyzerLoadFailureEventArgs.FailureErrorCode.UnableToCreateAnalyzer: diagnostic = new DiagnosticInfo(messageProvider, messageProvider.WRN_AnalyzerCannotBeCreated, e.TypeName, analyzerReference.FullPath, e.Message); break; case AnalyzerLoadFailureEventArgs.FailureErrorCode.NoAnalyzers: diagnostic = new DiagnosticInfo(messageProvider, messageProvider.WRN_NoAnalyzerInAssembly, analyzerReference.FullPath); break; case AnalyzerLoadFailureEventArgs.FailureErrorCode.None: default: return; } // Filter this diagnostic based on the compilation options so that /nowarn and /warnaserror etc. take effect. diagnostic = messageProvider.FilterDiagnosticInfo(diagnostic, this.CompilationOptions); if (diagnostic != null) { diagnostics.Add(diagnostic); } }; var resolvedReferences = ArrayBuilder<AnalyzerFileReference>.GetInstance(); foreach (var reference in AnalyzerReferences) { var resolvedReference = ResolveAnalyzerReference(reference, analyzerLoader); if (resolvedReference != null) { resolvedReferences.Add(resolvedReference); // register the reference to the analyzer loader: analyzerLoader.AddDependencyLocation(resolvedReference.FullPath); } else { diagnostics.Add(new DiagnosticInfo(messageProvider, messageProvider.ERR_MetadataFileNotFound, reference.FilePath)); } } // All analyzer references are registered now, we can start loading them: foreach (var resolvedReference in resolvedReferences) { resolvedReference.AnalyzerLoadFailed += errorHandler; resolvedReference.AddAnalyzers(analyzerBuilder, language); resolvedReference.AnalyzerLoadFailed -= errorHandler; } resolvedReferences.Free(); return analyzerBuilder.ToImmutable(); }
private AnalyzerFileReference ResolveAnalyzerReference(CommandLineAnalyzerReference reference, IAnalyzerAssemblyLoader analyzerLoader) { string resolvedPath = FileUtilities.ResolveRelativePath(reference.FilePath, basePath: null, baseDirectory: BaseDirectory, searchPaths: ReferencePaths, fileExists: PortableShim.File.Exists); if (resolvedPath != null) { resolvedPath = FileUtilities.TryNormalizeAbsolutePath(resolvedPath); } if (resolvedPath != null) { return new AnalyzerFileReference(resolvedPath, analyzerLoader); } return null; }
/// <summary> /// Resolves analyzer references stored in <see cref="AnalyzerReferences"/> using given file resolver. /// </summary> /// <param name="analyzerLoader">Load an assembly from a file path</param> /// <returns>Yields resolved <see cref="AnalyzerFileReference"/> or <see cref="UnresolvedAnalyzerReference"/>.</returns> public IEnumerable<AnalyzerReference> ResolveAnalyzerReferences(IAnalyzerAssemblyLoader analyzerLoader) { foreach (CommandLineAnalyzerReference cmdLineReference in AnalyzerReferences) { yield return ResolveAnalyzerReference(cmdLineReference, analyzerLoader) ?? (AnalyzerReference)new UnresolvedAnalyzerReference(cmdLineReference.FilePath); } }
public AnalyzerAssemblyLoader() { _fallbackLoader = new DesktopAnalyzerAssemblyLoader(); }
public static int Run(string[] args, string clientDir, string workingDir, string sdkDir, TextWriter textWriter, IAnalyzerAssemblyLoader analyzerLoader) => Csc.Run(args, new BuildPaths(clientDir: clientDir, workingDir: workingDir, sdkDir: sdkDir), textWriter, analyzerLoader);
internal Vbc(string responseFile, string clientDirectory, string baseDirectory, string sdkDirectory, string[] args, IAnalyzerAssemblyLoader analyzerLoader) : base(VisualBasicCommandLineParser.Default, responseFile, args, clientDirectory, baseDirectory, sdkDirectory, Environment.GetEnvironmentVariable("LIB"), analyzerLoader) { }
public VisualStudioAnalyzer(string fullPath, IVsFileChangeEx fileChangeService, HostDiagnosticUpdateSource hostDiagnosticUpdateSource, ProjectId projectId, Workspace workspace, IAnalyzerAssemblyLoader loader, string language) { _fullPath = fullPath; _tracker = new FileChangeTracker(fileChangeService, fullPath); _tracker.UpdatedOnDisk += OnUpdatedOnDisk; _tracker.StartFileChangeListeningAsync(); _hostDiagnosticUpdateSource = hostDiagnosticUpdateSource; _projectId = projectId; _workspace = workspace; _loader = loader; _language = language; }
internal static DesktopBuildClient CreateBuildClient( RequestLanguage language, CompileFunc compileFunc = null, TextWriter textWriter = null, IAnalyzerAssemblyLoader analyzerAssemblyLoader = null) { compileFunc = compileFunc ?? GetCompileFunc(language); textWriter = textWriter ?? new StringWriter(); analyzerAssemblyLoader = analyzerAssemblyLoader ?? new Mock<IAnalyzerAssemblyLoader>(MockBehavior.Strict).Object; return new DesktopBuildClient(language, compileFunc, analyzerAssemblyLoader); }
internal Csi(string responseFile, string baseDirectory, string[] args, IAnalyzerAssemblyLoader analyzerLoader) : base(CSharpCommandLineParser.Interactive, responseFile, args, Path.GetDirectoryName(typeof(CSharpCompiler).Assembly.Location), baseDirectory, RuntimeEnvironment.GetRuntimeDirectory(), null /* TODO: what to pass as additionalReferencePaths? */, analyzerLoader) { }
private static bool CheckCore(string baseDirectory, IEnumerable<CommandLineAnalyzerReference> analyzerReferences, IAnalyzerAssemblyLoader loader, IEnumerable<string> ignorableReferenceNames) { var resolvedPaths = new List<string>(); foreach (var analyzerReference in analyzerReferences) { string resolvedPath = FileUtilities.ResolveRelativePath(analyzerReference.FilePath, basePath: null, baseDirectory: baseDirectory, searchPaths: SpecializedCollections.EmptyEnumerable<string>(), fileExists: File.Exists); if (File.Exists(resolvedPath)) { resolvedPath = FileUtilities.TryNormalizeAbsolutePath(resolvedPath); if (resolvedPath != null) { resolvedPaths.Add(resolvedPath); } } // Don't worry about paths we can't resolve. The compiler will report an error for that later. } // First, check that the set of references is complete, modulo items in the safe list. foreach (var resolvedPath in resolvedPaths) { var missingDependencies = AssemblyUtilities.IdentifyMissingDependencies(resolvedPath, resolvedPaths); foreach (var missingDependency in missingDependencies) { if (!ignorableReferenceNames.Any(name => missingDependency.Name.StartsWith(name))) { CompilerServerLogger.Log($"Analyzer assembly {resolvedPath} depends on '{missingDependency}' but it was not found."); return false; } } } // Second, load all of the assemblies upfront. foreach (var resolvedPath in resolvedPaths) { loader.AddDependencyLocation(resolvedPath); } var loadedAssemblies = new List<Assembly>(); foreach (var resolvedPath in resolvedPaths) { loadedAssemblies.Add(loader.LoadFromPath(resolvedPath)); } // Third, check that the MVIDs of the files on disk match the MVIDs of the loaded assemblies. for (int i = 0; i < resolvedPaths.Count; i++) { var resolvedPath = resolvedPaths[i]; var loadedAssembly = loadedAssemblies[i]; var resolvedPathMvid = AssemblyUtilities.ReadMvid(resolvedPath); var loadedAssemblyMvid = loadedAssembly.ManifestModule.ModuleVersionId; if (resolvedPathMvid != loadedAssemblyMvid) { CompilerServerLogger.Log($"Analyzer assembly {resolvedPath} has MVID '{resolvedPathMvid}' but loaded assembly '{loadedAssembly.FullName}' has MVID '{loadedAssemblyMvid}'."); return false; } } return true; }
public PhpCompiler(CommandLineParser parser, string responseFile, string[] args, string clientDirectory, string baseDirectory, string sdkDirectory, string additionalReferenceDirectories, IAnalyzerAssemblyLoader analyzerLoader) : base(parser, responseFile, args, clientDirectory, baseDirectory, sdkDirectory, additionalReferenceDirectories, analyzerLoader) { }
internal VisualBasicCompilerServer(Func<string, MetadataReferenceProperties, PortableExecutableReference> metadataProvider, string[] args, string clientDirectory, string baseDirectory, string sdkDirectory, string libDirectory, IAnalyzerAssemblyLoader analyzerLoader) : base(VisualBasicCommandLineParser.Default, clientDirectory != null ? Path.Combine(clientDirectory, ResponseFileName) : null, args, clientDirectory, baseDirectory, sdkDirectory, libDirectory, analyzerLoader) { _metadataProvider = metadataProvider; }
public static ProjectInfo CreateProjectInfo(this ProjectFileInfo projectFileInfo, IAnalyzerAssemblyLoader analyzerAssemblyLoader) { var analyzerReferences = ResolveAnalyzerReferencesForProject(projectFileInfo, analyzerAssemblyLoader); return(ProjectInfo.Create( id: projectFileInfo.Id, version: VersionStamp.Create(), name: projectFileInfo.Name, assemblyName: projectFileInfo.AssemblyName, language: LanguageNames.CSharp, filePath: projectFileInfo.FilePath, outputFilePath: projectFileInfo.TargetPath, compilationOptions: projectFileInfo.CreateCompilationOptions(), analyzerReferences: analyzerReferences)); }
public HostAnalyzerManager(Lazy <ImmutableArray <HostDiagnosticAnalyzerPackage> > hostAnalyzerPackages, IAnalyzerAssemblyLoader hostAnalyzerAssemblyLoader, AbstractHostDiagnosticUpdateSource hostDiagnosticUpdateSource, PrimaryWorkspace primaryWorkspace) : this(new Lazy <ImmutableArray <AnalyzerReference> >(() => CreateAnalyzerReferencesFromPackages(hostAnalyzerPackages.Value, new HostAnalyzerReferenceDiagnosticReporter(hostDiagnosticUpdateSource, primaryWorkspace), hostAnalyzerAssemblyLoader), isThreadSafe : true), hostAnalyzerPackages, hostDiagnosticUpdateSource) { }
internal CSharpCompilerServer(Func<string, MetadataReferenceProperties, PortableExecutableReference> metadataProvider, string[] args, BuildPaths buildPaths, string libDirectory, IAnalyzerAssemblyLoader analyzerLoader) : base(CSharpCommandLineParser.Default, buildPaths.ClientDirectory != null ? Path.Combine(buildPaths.ClientDirectory, ResponseFileName) : null, args, buildPaths, libDirectory, analyzerLoader) { _metadataProvider = metadataProvider; }
private AnalyzerFileReference ResolveAnalyzerReference(CommandLineAnalyzerReference reference, IAnalyzerAssemblyLoader analyzerLoader) { string resolvedPath = FileUtilities.ResolveRelativePath(reference.FilePath, basePath: null, baseDirectory: BaseDirectory, searchPaths: ReferencePaths, fileExists: File.Exists); if (resolvedPath != null) { resolvedPath = FileUtilities.TryNormalizeAbsolutePath(resolvedPath); } if (resolvedPath != null) { return(new AnalyzerFileReference(resolvedPath, analyzerLoader)); } return(null); }
internal Csc(string responseFile, BuildPaths buildPaths, string[] args, IAnalyzerAssemblyLoader analyzerLoader) : base(CSharpCommandLineParser.Default, responseFile, args, buildPaths.ClientDirectory, buildPaths.WorkingDirectory, buildPaths.SdkDirectory, Environment.GetEnvironmentVariable("LIB"), analyzerLoader) { }
internal static int Run(IEnumerable <string> arguments, IEnumerable <string> extraArguments, RequestLanguage language, CompileFunc compileFunc, IAnalyzerAssemblyLoader analyzerAssemblyLoader) { var client = new DesktopBuildClient(language, compileFunc, analyzerAssemblyLoader); var clientDir = AppDomain.CurrentDomain.BaseDirectory; var sdkDir = RuntimeEnvironment.GetRuntimeDirectory(); var workingDir = Directory.GetCurrentDirectory(); var buildPaths = new BuildPaths(clientDir: clientDir, workingDir: workingDir, sdkDir: sdkDir); var originalArguments = BuildClient.GetCommandLineArgs(arguments).Concat(extraArguments).ToArray(); return(client.RunCompilation(originalArguments, buildPaths).ExitCode); }
internal CSharpInteractiveCompiler(string responseFile, string baseDirectory, string sdkDirectoryOpt, string[] args, IAnalyzerAssemblyLoader analyzerLoader) // Unlike C# compiler we do not use LIB environment variable. It's only supported for historical reasons. : base(CSharpCommandLineParser.ScriptRunner, responseFile, args, AppContext.BaseDirectory, baseDirectory, sdkDirectoryOpt, null, analyzerLoader) { }
public CommonCompiler(CommandLineParser parser, string responseFile, string[] args, string clientDirectory, string baseDirectory, string sdkDirectoryOpt, string additionalReferenceDirectories, IAnalyzerAssemblyLoader assemblyLoader) { IEnumerable <string> allArgs = args; _clientDirectory = clientDirectory; Debug.Assert(null == responseFile || PathUtilities.IsAbsolute(responseFile)); if (!SuppressDefaultResponseFile(args) && PortableShim.File.Exists(responseFile)) { allArgs = new[] { "@" + responseFile }.Concat(allArgs); } this.Arguments = parser.Parse(allArgs, baseDirectory, sdkDirectoryOpt, additionalReferenceDirectories); this.MessageProvider = parser.MessageProvider; this.AssemblyLoader = assemblyLoader; if (Arguments.ParseOptions.Features.ContainsKey("debug-determinism")) { EmitDeterminismKey(Arguments, args, baseDirectory, parser); } }
private AbstractProject GetOrCreateProjectFromArgumentsAndReferences( IWorkspaceProjectContextFactory workspaceProjectContextFactory, IAnalyzerAssemblyLoader analyzerAssemblyLoader, string projectFilename, IReadOnlyDictionary<string, DeferredProjectInformation> allProjectInfos, IReadOnlyDictionary<string, string> targetPathsToProjectPaths) { var languageName = GetLanguageOfProject(projectFilename); if (languageName == null) { return null; } if (!allProjectInfos.TryGetValue(projectFilename, out var projectInfo)) { // This could happen if we were called recursively about a dangling P2P reference // that isn't actually in the solution. return null; } var commandLineParser = _workspaceServices.GetLanguageServices(languageName).GetService<ICommandLineParserService>(); var projectDirectory = PathUtilities.GetDirectoryName(projectFilename); var commandLineArguments = commandLineParser.Parse( projectInfo.CommandLineArguments, projectDirectory, isInteractive: false, sdkDirectory: RuntimeEnvironment.GetRuntimeDirectory()); // TODO: Should come from sln file? var projectName = PathUtilities.GetFileName(projectFilename, includeExtension: false); // `AbstractProject` only sets the filename if it actually exists. Since we want // our ids to match, mimic that behavior here. var projectId = File.Exists(projectFilename) ? GetOrCreateProjectIdForPath(projectFilename, projectName) : GetOrCreateProjectIdForPath(projectName, projectName); // See if we've already created this project and we're now in a recursive call to // hook up a P2P ref. if (_projectMap.TryGetValue(projectId, out var project)) { return project; } OutputToOutputWindow($"\tCreating '{projectName}':\t{commandLineArguments.SourceFiles.Length} source files,\t{commandLineArguments.MetadataReferences.Length} references."); var solution5 = _serviceProvider.GetService(typeof(SVsSolution)) as IVsSolution5; // If the index is stale, it might give us a path that doesn't exist anymore that the // solution doesn't know about - be resilient to that case. Guid projectGuid; try { projectGuid = solution5.GetGuidOfProjectFile(projectFilename); } catch (ArgumentException) { var message = $"Failed to get the project guid for '{projectFilename}' from the solution, using random guid instead."; Debug.Fail(message); OutputToOutputWindow(message); projectGuid = Guid.NewGuid(); } // NOTE: If the indexing service fails for a project, it will give us an *empty* // target path, which we aren't prepared to handle. Instead, convert it to a *null* // value, which we do handle. var outputPath = projectInfo.TargetPath; if (outputPath == string.Empty) { outputPath = null; } var projectContext = workspaceProjectContextFactory.CreateProjectContext( languageName, projectName, projectFilename, projectGuid: projectGuid, hierarchy: null, binOutputPath: outputPath); project = (AbstractProject)projectContext; projectContext.SetOptions(projectInfo.CommandLineArguments.Join(" ")); foreach (var sourceFile in commandLineArguments.SourceFiles) { projectContext.AddSourceFile(sourceFile.Path); } foreach (var sourceFile in commandLineArguments.AdditionalFiles) { projectContext.AddAdditionalFile(sourceFile.Path); } var addedProjectReferences = new HashSet<string>(); foreach (var projectReferencePath in projectInfo.ReferencedProjectFilePaths) { // NOTE: ImmutableProjects might contain projects for other languages like // Xaml, or Typescript where the project file ends up being identical. var referencedProject = ImmutableProjects.SingleOrDefault( p => (p.Language == LanguageNames.CSharp || p.Language == LanguageNames.VisualBasic) && StringComparer.OrdinalIgnoreCase.Equals(p.ProjectFilePath, projectReferencePath)); if (referencedProject == null) { referencedProject = GetOrCreateProjectFromArgumentsAndReferences( workspaceProjectContextFactory, analyzerAssemblyLoader, projectReferencePath, allProjectInfos, targetPathsToProjectPaths); } var referencedProjectContext = referencedProject as IWorkspaceProjectContext; if (referencedProjectContext != null) { // TODO: Can we get the properties from corresponding metadata reference in // commandLineArguments? addedProjectReferences.Add(projectReferencePath); projectContext.AddProjectReference( referencedProjectContext, new MetadataReferenceProperties()); } else if (referencedProject != null) { // This project was already created by the regular project system. See if we // can find the matching project somehow. var existingReferenceOutputPath = referencedProject?.BinOutputPath; if (existingReferenceOutputPath != null) { addedProjectReferences.Add(projectReferencePath); projectContext.AddMetadataReference( existingReferenceOutputPath, new MetadataReferenceProperties()); } } else { // We don't know how to create this project. Another language or something? OutputToOutputWindow($"Failed to create a project for '{projectReferencePath}'."); } } foreach (var reference in commandLineArguments.ResolveMetadataReferences(project.CurrentCompilationOptions.MetadataReferenceResolver)) { // Some references may fail to be resolved - if they are, we'll still pass them // through, in case they come into existence later (they may be built by other // parts of the build system). var unresolvedReference = reference as UnresolvedMetadataReference; var path = unresolvedReference == null ? ((PortableExecutableReference)reference).FilePath : unresolvedReference.Reference; if (targetPathsToProjectPaths.TryGetValue(path, out var possibleProjectReference) && addedProjectReferences.Contains(possibleProjectReference)) { // We already added a P2P reference for this, we don't need to add the file reference too. continue; } projectContext.AddMetadataReference(path, reference.Properties); } foreach (var reference in commandLineArguments.ResolveAnalyzerReferences(analyzerAssemblyLoader)) { var path = reference.FullPath; if (!PathUtilities.IsAbsolute(path)) { path = PathUtilities.CombineAbsoluteAndRelativePaths( projectDirectory, path); } projectContext.AddAnalyzerReference(path); } return (AbstractProject)projectContext; }