Exemplo n.º 1
0
        internal string[] Generate(RemotableLogger2 logger, BuildEnvironment environment)
        {
            if (!_initialized)
            {
                throw new InvalidOperationException("Initialize must be called before calling Generate");
            }

            _remoteLoggerProvider.TaskLog = logger;

            return(new SourceGeneratorHost(environment).Generate());
        }
Exemplo n.º 2
0
        private void GenerateForCollection(HostCollection collection)
        {
            (SourceGeneratorHostWrapper Wrapper, AppDomain Domain)hostEntry = (null, null);

            try
            {
                if (!collection.Hosts.TryTake(out hostEntry))
                {
                    hostEntry = CreateDomain(collection);
                }
                else
                {
                    // Try pinging the remote appdomain, as it may throw a RemotingException exception with this error:
                    // Error : Object '/b612ce25_b538_486d_882a_28a019c782ed/p6lmd0em_mrlqpchbk5gh2mk_10.rem' has been disconnected or does not exist at the server.
                    try
                    {
                        if (hostEntry.Wrapper.Ping())
                        {
                            Log.LogMessage($"Reusing generation host ({collection.Entry.OwnerFile}, {string.Join(", ", collection.Entry.Analyzers)})");
                        }
                    }
                    catch (System.Runtime.Remoting.RemotingException /*e*/)
                    {
                        Log.LogMessage($"Discarding disconnected generation host for ({collection.Entry.OwnerFile}, {string.Join(", ", collection.Entry.Analyzers)})");

                        hostEntry = CreateDomain(collection);
                    }
                }

                Logger.RemotableLogger2 remotableLogger = new Logger.RemotableLogger2(_taskLogger.CreateLogger("Logger.RemotableLogger"));

                var environment = new BuildEnvironment(
                    Configuration,
                    Platform,
                    ProjectFile,
                    OutputPath,
                    TargetFramework,
                    VisualStudioVersion,
                    TargetFrameworkRootPath,
                    BinLogOutputPath,
                    BinLogEnabled
                    );

                GenereratedFiles = hostEntry.Wrapper.Generate(remotableLogger, environment);
            }
            finally
            {
                if (collection != null)
                {
                    collection.Hosts.Add(hostEntry);
                }
            }
        }
        internal string[] Generate(RemotableLogger2 logger, BuildEnvironment environment)
        {
            if (!_initialized)
            {
                throw new InvalidOperationException("Initialize must be called before calling Generate");
            }

            _remoteLoggerProvider.TaskLog = logger;

            return(new SourceGeneratorEngine(
                       environment: environment
#if IS_BUILD_HOST
                       , assemblyReferenceProvider: Uno.SourceGeneration.Host.Server.DesktopGenerationServerHost.SharedAssemblyReferenceProvider
#else
                       , null
#endif
                       ).Generate());
        }
Exemplo n.º 4
0
        internal string[] Generate(RemotableLogger2 logger, BuildEnvironment environment)
        {
            _remoteLoggerProvider.TaskLog = logger;

            return(new SourceGeneratorHost(environment).Generate());
        }