-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Cleanup processes started by UseReactDevelopmentServer and UseAngularCliServer #17883
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...vices.Extensions/src/ReactDevelopmentServer/ReactDevelopmentServerMiddlewareExtensions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
src/Middleware/SpaServices.Extensions/test/ListLoggerFactory.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using Microsoft.Extensions.Logging; | ||
| using Microsoft.Extensions.Logging.Abstractions; | ||
| using Xunit.Abstractions; | ||
|
|
||
| namespace Microsoft.AspNetCore.SpaServices.Extensions.Tests | ||
| { | ||
| public class ListLoggerFactory : ILoggerFactory | ||
| { | ||
| private readonly Func<string, bool> _shouldLogCategory; | ||
| private bool _disposed; | ||
|
|
||
| public ListLoggerFactory() | ||
| : this(_ => true) | ||
| { | ||
| } | ||
|
|
||
| public ListLoggerFactory(Func<string, bool> shouldLogCategory) | ||
| { | ||
| _shouldLogCategory = shouldLogCategory; | ||
| Logger = new ListLogger(); | ||
| } | ||
|
|
||
| public List<(LogLevel Level, EventId Id, string Message, object State, Exception Exception)> Log => Logger.LoggedEvents; | ||
| protected ListLogger Logger { get; set; } | ||
|
|
||
| public virtual void Clear() => Logger.Clear(); | ||
|
|
||
| public void SetTestOutputHelper(ITestOutputHelper testOutputHelper) | ||
| { | ||
| Logger.TestOutputHelper = testOutputHelper; | ||
| } | ||
|
|
||
| public virtual ILogger CreateLogger(string name) | ||
| { | ||
| CheckDisposed(); | ||
|
|
||
| return !_shouldLogCategory(name) | ||
| ? (ILogger)NullLogger.Instance | ||
| : Logger; | ||
| } | ||
|
|
||
| private void CheckDisposed() | ||
| { | ||
| if (_disposed) | ||
| { | ||
| throw new ObjectDisposedException(nameof(ListLoggerFactory)); | ||
| } | ||
| } | ||
|
|
||
| public void AddProvider(ILoggerProvider provider) | ||
| { | ||
| CheckDisposed(); | ||
| } | ||
|
|
||
| public void Dispose() | ||
| { | ||
| _disposed = true; | ||
| } | ||
|
|
||
| protected class ListLogger : ILogger | ||
| { | ||
| private readonly object _sync = new object(); | ||
|
|
||
| public ITestOutputHelper TestOutputHelper { get; set; } | ||
|
|
||
| public List<(LogLevel, EventId, string, object, Exception)> LoggedEvents { get; } | ||
| = new List<(LogLevel, EventId, string, object, Exception)>(); | ||
|
|
||
| public void Clear() | ||
| { | ||
| lock (_sync) // Guard against tests with explicit concurrency | ||
| { | ||
| LoggedEvents.Clear(); | ||
| } | ||
| } | ||
|
|
||
| public void Log<TState>( | ||
| LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter) | ||
| { | ||
| lock (_sync) // Guard against tests with explicit concurrency | ||
| { | ||
| var message = formatter(state, exception)?.Trim(); | ||
| if (message != null) | ||
| { | ||
| TestOutputHelper?.WriteLine(message + Environment.NewLine); | ||
| } | ||
|
|
||
| LoggedEvents.Add((logLevel, eventId, message, state, exception)); | ||
| } | ||
| } | ||
|
|
||
| public bool IsEnabled(LogLevel logLevel) => true; | ||
|
|
||
| public IDisposable BeginScope(object state) => null; | ||
|
|
||
| public IDisposable BeginScope<TState>(TState state) => null; | ||
| } | ||
| } | ||
| } |
12 changes: 11 additions & 1 deletion
12
...ware/SpaServices.Extensions/test/Microsoft.AspNetCore.SpaServices.Extensions.Tests.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,27 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework> | ||
| <TestDependsOnNode>true</TestDependsOnNode> | ||
| <!-- Depends on npm which is not picked up on helix --> | ||
| <!-- https://github.com/dotnet/aspnetcore/issues/18672 --> | ||
| <BuildHelixPayload>false</BuildHelixPayload> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <Reference Include="Microsoft.AspNetCore.SpaServices.Extensions" /> | ||
| <Reference Include="Microsoft.AspNetCore.Hosting" /> | ||
| <Reference Include="Microsoft.AspNetCore.TestHost" /> | ||
| <Reference Include="Microsoft.Extensions.DiagnosticAdapter" /> | ||
| <Reference Include="Microsoft.Extensions.Hosting" /> | ||
| <Reference Include="Microsoft.Extensions.Logging.Testing" /> | ||
| <Content Include="js\**\*" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <None Update="package.json"> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the behavior we get without this line?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. npm exits immediately |
||
| <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
| </None> | ||
| </ItemGroup> | ||
|
|
||
| </Project> | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.