public void TestSetUp()
 {
     if (RuntimeInfo.GetRuntime().IsMono())
     {
         Assert.Ignore("Test only relevant under .NET Framework");
     }
 }
        public void GetInstallations_NotEmpty()
        {
            Skip.If(RuntimeInfo.GetRuntime().IsMono());
            var allInstallations = FrameworkInfo.GetInstallations();

            Assert.NotEmpty(allInstallations);
        }
        public void GetLatest_NotNull()
        {
            Skip.If(RuntimeInfo.GetRuntime().IsMono());
            var latest = FrameworkInfo.GetLatest(Environment.Version.Major);

            Assert.NotNull(latest);
        }
        [Test] // Verifies that some value is extracted anywhere the tests runs
        public void GetRuntime_NotNull()
        {
            var actual = RuntimeInfo.GetRuntime();

            Assert.NotNull(actual);
            Assert.NotNull(actual.Name);
            Assert.NotNull(actual.Version);
        }
        public void StackTraceFactory_NotRunningOnMono_NotMonoStackTraceFactory()
        {
            Skip.If(RuntimeInfo.GetRuntime().IsMono());

            var sut = new SentryOptions();

            Assert.IsNotType <MonoSentryStackTraceFactory>(sut.SentryStackTraceFactory);
        }
    public void SetReleaseAndVersionNetFx_OnNetFx_NonNullReleaseAndVersion()
    {
        // This test is only relevant when running on CLR.
        Skip.If(RuntimeInfo.GetRuntime().IsMono());

        var input = new Runtime(".NET Framework");

        RuntimeInfo.SetNetFxReleaseAndVersion(input);

        input.Version.Should().NotBeNull();
        input.FrameworkInstallation.Should().NotBeNull();
        input.FrameworkInstallation.Version.Should().NotBeNull();
    }
Example #7
0
 CodeCompilation.CodeCompiler GetOrCreateCompiler()
 {
     if (cachedCompiler == null)
     {
         var runtime = RuntimeInfo.GetRuntime();
         if (runtime.Error != null)
         {
             throw new TemplatingEngineException(runtime.Error);
         }
         cachedCompiler = createCompilerFunc?.Invoke(runtime) ?? new CscCodeCompiler(runtime);
     }
     return(cachedCompiler);
 }
 public void GetInstallations_AllReleasesAreMappedToVersion()
 {
     Skip.If(RuntimeInfo.GetRuntime().IsMono());
     var allInstallations = FrameworkInfo.GetInstallations();
     foreach (var installation in allInstallations)
     {
         if (installation.Release != null)
         {
             // Release has no version mapped
             Assert.NotNull(installation.Version);
         }
     }
 }
Example #9
0
        public void SetReleaseAndVersionNetFx_OnNetFx_NonNullReleaseAndVersion()
        {
            if (RuntimeInfo.GetRuntime().IsMono())
            {
                Assert.Inconclusive("This test is only relevant when running on CLR.");
            }
            else
            {
                var input = new Runtime(".NET Framework");
                RuntimeInfo.SetReleaseAndVersionNetFx(input);

                Assert.NotNull(input.Version);
                Assert.NotNull(input.Release);
            }
        }
        public void GetFromMonoRuntime_OnMono_VersionNotNull()
        {
            if (!RuntimeInfo.GetRuntime().IsMono())
            {
                Assert.Ignore("This test is only relevant when running on Mono.");
            }
            else
            {
                var actual = RuntimeInfo.GetFromMonoRuntime();

                Assert.AreEqual("Mono", actual.Name);
                Assert.NotNull(actual.Version);
                Assert.Null(actual.FrameworkInstallation);
                Assert.NotNull(actual.Raw);
            }
        }
 public static void UseInProcessCompiler(this TemplatingEngine engine)
 {
     engine.SetCompilerFunc(() => new RoslynCodeCompiler(RuntimeInfo.GetRuntime()));
 }
Example #12
0
        private async ThreadingTasks.Task <IProcessTransformationRunFactory> GetTransformationRunFactoryAsync(TextWriter output, CancellationToken cancellationToken)
        {
            try
            {
                if (!this.isChannelRegistered)
                {
                    Hashtable properties = new Hashtable
                    {
                        [nameof(IChannel.ChannelName)] = TransformationRunFactory.TransformationRunFactoryService
                    };

                    this.isChannelRegistered = ChannelServices.RegisterChannel(new NamedPipeChannel <ITransformationRunFactoryService>(properties, new BinarySerializationProvider()));
                }
            }
            catch (SubSonicRemotingException ex)
            {
                await LogErrorAsync(ex.Message);
            }

            if ((transformProcess == null) || (!RunFactoryIsAlive() || transformProcess.HasExited))
            {   // this host process is capable of supporting multiple runners
                if (transformProcess != null && !transformProcess.HasExited)
                {
                    transformProcess.Kill();
                }

                string path = Path.Combine(
                    Path.GetDirectoryName(typeof(SubSonicCoreVisualStudioAsyncPackage).Assembly.Location),
                    "T4HostProcess",
                    SubSonicMenuCommands.SubSonicHostProcessFileName);

                if (!File.Exists(path))
                {
                    throw new FileNotFoundException(SubSonicCoreErrors.FileNotFound, SubSonicMenuCommands.SubSonicHostProcessFileName);
                }

                ProcessStartInfo psi = new ProcessStartInfo(path, SubSonicCoreVisualStudioCommonResources.HostArgumentString.Format(TransformationRunFactory.TransformationRunFactoryService, Package().HostOptions.Timeout))
                {
                    CreateNoWindow         = true,
                    UseShellExecute        = false,
                    RedirectStandardError  = output != null,
                    RedirectStandardOutput = output != null
                };

                RuntimeInfo runtime = RuntimeInfo.GetRuntime(package.HostOptions.RuntimeKind);

                if (runtime.Kind == RuntimeKind.NetCore)
                {
                    psi.Arguments = $"\"{psi.FileName}\" {psi.Arguments}";
                    psi.FileName  = Path.GetFullPath(Path.Combine(runtime.RuntimeDirectory, "..", "..", "..", "dotnet"));
                }

                try
                {
                    _ = Core.Utilities.StartProcess(psi, output, output, out System.Diagnostics.Process theT4Host, cancellationToken);

                    transformProcess = theT4Host;
                }
                catch (Exception ex)
                {
                    await LogErrorAsync(ex.ToString(), new Location(TemplateFile));

                    return(default);