Exemplo n.º 1
0
        public async Task RuntimeErrorAreListedByErrorPageMiddleware()
        {
            // The desktop CLR does not correctly read the stack trace from portable PDBs. However generating full pdbs
            // is only supported on machines with CLSID_CorSymWriter available. On desktop, we'll skip this test on
            // machines without this component.
#if NET451
            if (!SymbolsUtility.SupportsFullPdbGeneration())
            {
                return;
            }
#endif

            // Arrange
            var expectedMessage   = HtmlEncoder.Default.Encode("throw new Exception(\"Error from view\");");
            var expectedMediaType = MediaTypeHeaderValue.Parse("text/html; charset=utf-8");

            // Act
            var response = await Client.GetAsync("http://localhost/RuntimeError");

            // Assert
            Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode);
            Assert.Equal(expectedMediaType, response.Content.Headers.ContentType);
            var content = await response.Content.ReadAsStringAsync();

            Assert.Contains("/Views/ErrorPageMiddleware/RuntimeError.cshtml", content);
            Assert.Contains(expectedMessage, content);
        }
        public RoslynCompilationService(IMetadataReferenceManager referenceManager, Assembly operatingAssembly)
        {
            if (referenceManager == null)
            {
                throw new ArgumentNullException(nameof(referenceManager));
            }

            if (operatingAssembly == null)
            {
                throw new ArgumentNullException(nameof(operatingAssembly));
            }

            metadataReferenceManager = referenceManager;
            this.operatingAssembly   = operatingAssembly;

            isDevelopment = IsAssemblyDebugBuild(OperatingAssembly);

            var pdbFormat = SymbolsUtility.SupportsFullPdbGeneration() ?
                            DebugInformationFormat.Pdb :
                            DebugInformationFormat.PortablePdb;

            EmitOptions = new EmitOptions(debugInformationFormat: pdbFormat);


            var cacheOptions = Options.Create(new MemoryCacheOptions());

            _cache = new MemoryCache(cacheOptions);
        }
Exemplo n.º 3
0
        public RoslynCompilationService(IMetadataReferenceManager referenceManager, Assembly operatingAssembly)
        {
            this.metadataReferenceManager = referenceManager ?? throw new ArgumentNullException(nameof(referenceManager));
            this.OperatingAssembly        = operatingAssembly ?? throw new ArgumentNullException(nameof(operatingAssembly));

            isDevelopment = AssemblyDebugModeUtility.IsAssemblyDebugBuild(OperatingAssembly);
            var pdbFormat = SymbolsUtility.SupportsFullPdbGeneration() ?
                            DebugInformationFormat.Pdb :
                            DebugInformationFormat.PortablePdb;

            EmitOptions = new EmitOptions(debugInformationFormat: pdbFormat);
        }