-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move all of the C# for the libraries into a Shared folder and link to each project from there.
- Loading branch information
1 parent
5ebe1ba
commit 64a0647
Showing
20 changed files
with
1,622 additions
and
1,636 deletions.
There are no files selected for viewing
This file contains 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 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
50 changes: 25 additions & 25 deletions
50
....XUnit/AmbientTestOutputHelperAccessor.cs → ...Shared/AmbientTestOutputHelperAccessor.cs
This file contains 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,25 +1,25 @@ | ||
// Copyright (c) Martin Costello, 2018. All rights reserved. | ||
// Licensed under the Apache 2.0 license. See the LICENSE file in the project root for full license information. | ||
|
||
namespace MartinCostello.Logging.XUnit; | ||
|
||
/// <summary> | ||
/// A class representing an implementation of <see cref="ITestOutputHelperAccessor"/> that | ||
/// stores the <see cref="ITestOutputHelper"/> as an asynchronous local value. This class cannot be inherited. | ||
/// </summary> | ||
internal sealed class AmbientTestOutputHelperAccessor : ITestOutputHelperAccessor | ||
{ | ||
/// <summary> | ||
/// A backing field for the <see cref="ITestOutputHelper"/> for the current thread. | ||
/// </summary> | ||
private static readonly AsyncLocal<ITestOutputHelper?> _current = new(); | ||
|
||
/// <summary> | ||
/// Gets or sets the current <see cref="ITestOutputHelper"/>. | ||
/// </summary> | ||
public ITestOutputHelper? OutputHelper | ||
{ | ||
get { return _current.Value; } | ||
set { _current.Value = value; } | ||
} | ||
} | ||
// Copyright (c) Martin Costello, 2018. All rights reserved. | ||
// Licensed under the Apache 2.0 license. See the LICENSE file in the project root for full license information. | ||
|
||
namespace MartinCostello.Logging.XUnit; | ||
|
||
/// <summary> | ||
/// A class representing an implementation of <see cref="ITestOutputHelperAccessor"/> that | ||
/// stores the <see cref="ITestOutputHelper"/> as an asynchronous local value. This class cannot be inherited. | ||
/// </summary> | ||
internal sealed class AmbientTestOutputHelperAccessor : ITestOutputHelperAccessor | ||
{ | ||
/// <summary> | ||
/// A backing field for the <see cref="ITestOutputHelper"/> for the current thread. | ||
/// </summary> | ||
private static readonly AsyncLocal<ITestOutputHelper?> _current = new(); | ||
|
||
/// <summary> | ||
/// Gets or sets the current <see cref="ITestOutputHelper"/>. | ||
/// </summary> | ||
public ITestOutputHelper? OutputHelper | ||
{ | ||
get { return _current.Value; } | ||
set { _current.Value = value; } | ||
} | ||
} |
30 changes: 15 additions & 15 deletions
30
src/Logging.XUnit/IMessageSinkAccessor.cs → src/Shared/IMessageSinkAccessor.cs
This file contains 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,15 +1,15 @@ | ||
// Copyright (c) Martin Costello, 2018. All rights reserved. | ||
// Licensed under the Apache 2.0 license. See the LICENSE file in the project root for full license information. | ||
|
||
namespace MartinCostello.Logging.XUnit; | ||
|
||
/// <summary> | ||
/// Defines a property for accessing an <see cref="IMessageSink"/>. | ||
/// </summary> | ||
public interface IMessageSinkAccessor | ||
{ | ||
/// <summary> | ||
/// Gets or sets the <see cref="IMessageSink"/> to use. | ||
/// </summary> | ||
IMessageSink? MessageSink { get; set; } | ||
} | ||
// Copyright (c) Martin Costello, 2018. All rights reserved. | ||
// Licensed under the Apache 2.0 license. See the LICENSE file in the project root for full license information. | ||
|
||
namespace MartinCostello.Logging.XUnit; | ||
|
||
/// <summary> | ||
/// Defines a property for accessing an <see cref="IMessageSink"/>. | ||
/// </summary> | ||
public interface IMessageSinkAccessor | ||
{ | ||
/// <summary> | ||
/// Gets or sets the <see cref="IMessageSink"/> to use. | ||
/// </summary> | ||
IMessageSink? MessageSink { get; set; } | ||
} |
114 changes: 57 additions & 57 deletions
114
src/Logging.XUnit/IMessageSinkExtensions.cs → src/Shared/IMessageSinkExtensions.cs
This file contains 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,57 +1,57 @@ | ||
// Copyright (c) Martin Costello, 2018. All rights reserved. | ||
// Licensed under the Apache 2.0 license. See the LICENSE file in the project root for full license information. | ||
|
||
using System.ComponentModel; | ||
using Microsoft.Extensions.Logging; | ||
|
||
#if XUNIT_V3 | ||
namespace Xunit; | ||
#else | ||
#pragma warning disable IDE0130 | ||
namespace Xunit.Abstractions; | ||
#endif | ||
|
||
/// <summary> | ||
/// A class containing extension methods for the <see cref="IMessageSink"/> interface. This class cannot be inherited. | ||
/// </summary> | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public static class IMessageSinkExtensions | ||
{ | ||
/// <summary> | ||
/// Returns an <see cref="ILoggerFactory"/> that logs to the message sink. | ||
/// </summary> | ||
/// <param name="messageSink">The <see cref="IMessageSink"/> to create the logger factory from.</param> | ||
/// <returns> | ||
/// An <see cref="ILoggerFactory"/> that writes messages to the message sink. | ||
/// </returns> | ||
/// <exception cref="ArgumentNullException"> | ||
/// <paramref name="messageSink"/> is <see langword="null"/>. | ||
/// </exception> | ||
public static ILoggerFactory ToLoggerFactory(this IMessageSink messageSink) | ||
{ | ||
#if NET | ||
ArgumentNullException.ThrowIfNull(messageSink); | ||
#else | ||
if (messageSink == null) | ||
{ | ||
throw new ArgumentNullException(nameof(messageSink)); | ||
} | ||
#endif | ||
|
||
return new LoggerFactory().AddXUnit(messageSink); | ||
} | ||
|
||
/// <summary> | ||
/// Returns an <see cref="ILogger{T}"/> that logs to the message sink. | ||
/// </summary> | ||
/// <typeparam name="T">The type of the logger to create.</typeparam> | ||
/// <param name="messageSink">The <see cref="IMessageSink"/> to create the logger from.</param> | ||
/// <returns> | ||
/// An <see cref="ILogger{T}"/> that writes messages to the message sink. | ||
/// </returns> | ||
/// <exception cref="ArgumentNullException"> | ||
/// <paramref name="messageSink"/> is <see langword="null"/>. | ||
/// </exception> | ||
public static ILogger<T> ToLogger<T>(this IMessageSink messageSink) | ||
=> messageSink.ToLoggerFactory().CreateLogger<T>(); | ||
} | ||
// Copyright (c) Martin Costello, 2018. All rights reserved. | ||
// Licensed under the Apache 2.0 license. See the LICENSE file in the project root for full license information. | ||
|
||
using System.ComponentModel; | ||
using Microsoft.Extensions.Logging; | ||
|
||
#if XUNIT_V3 | ||
namespace Xunit; | ||
#else | ||
#pragma warning disable IDE0130 | ||
namespace Xunit.Abstractions; | ||
#endif | ||
|
||
/// <summary> | ||
/// A class containing extension methods for the <see cref="IMessageSink"/> interface. This class cannot be inherited. | ||
/// </summary> | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public static class IMessageSinkExtensions | ||
{ | ||
/// <summary> | ||
/// Returns an <see cref="ILoggerFactory"/> that logs to the message sink. | ||
/// </summary> | ||
/// <param name="messageSink">The <see cref="IMessageSink"/> to create the logger factory from.</param> | ||
/// <returns> | ||
/// An <see cref="ILoggerFactory"/> that writes messages to the message sink. | ||
/// </returns> | ||
/// <exception cref="ArgumentNullException"> | ||
/// <paramref name="messageSink"/> is <see langword="null"/>. | ||
/// </exception> | ||
public static ILoggerFactory ToLoggerFactory(this IMessageSink messageSink) | ||
{ | ||
#if NET | ||
ArgumentNullException.ThrowIfNull(messageSink); | ||
#else | ||
if (messageSink == null) | ||
{ | ||
throw new ArgumentNullException(nameof(messageSink)); | ||
} | ||
#endif | ||
|
||
return new LoggerFactory().AddXUnit(messageSink); | ||
} | ||
|
||
/// <summary> | ||
/// Returns an <see cref="ILogger{T}"/> that logs to the message sink. | ||
/// </summary> | ||
/// <typeparam name="T">The type of the logger to create.</typeparam> | ||
/// <param name="messageSink">The <see cref="IMessageSink"/> to create the logger from.</param> | ||
/// <returns> | ||
/// An <see cref="ILogger{T}"/> that writes messages to the message sink. | ||
/// </returns> | ||
/// <exception cref="ArgumentNullException"> | ||
/// <paramref name="messageSink"/> is <see langword="null"/>. | ||
/// </exception> | ||
public static ILogger<T> ToLogger<T>(this IMessageSink messageSink) | ||
=> messageSink.ToLoggerFactory().CreateLogger<T>(); | ||
} |
File renamed without changes.
File renamed without changes.
44 changes: 22 additions & 22 deletions
44
src/Logging.XUnit/MessageSinkAccessor.cs → src/Shared/MessageSinkAccessor.cs
This file contains 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,22 +1,22 @@ | ||
// Copyright (c) Martin Costello, 2018. All rights reserved. | ||
// Licensed under the Apache 2.0 license. See the LICENSE file in the project root for full license information. | ||
|
||
namespace MartinCostello.Logging.XUnit; | ||
|
||
/// <summary> | ||
/// A class representing the default implementation of <see cref="IMessageSinkAccessor"/>. This class cannot be inherited. | ||
/// </summary> | ||
/// <remarks> | ||
/// Initializes a new instance of the <see cref="MessageSinkAccessor"/> class. | ||
/// </remarks> | ||
/// <param name="messageSink">The <see cref="IMessageSink"/> to use.</param> | ||
/// <exception cref="ArgumentNullException"> | ||
/// <paramref name="messageSink"/> is <see langword="null"/>. | ||
/// </exception> | ||
internal sealed class MessageSinkAccessor(IMessageSink messageSink) : IMessageSinkAccessor | ||
{ | ||
/// <summary> | ||
/// Gets or sets the current <see cref="IMessageSink"/>. | ||
/// </summary> | ||
public IMessageSink? MessageSink { get; set; } = messageSink ?? throw new ArgumentNullException(nameof(messageSink)); | ||
} | ||
// Copyright (c) Martin Costello, 2018. All rights reserved. | ||
// Licensed under the Apache 2.0 license. See the LICENSE file in the project root for full license information. | ||
|
||
namespace MartinCostello.Logging.XUnit; | ||
|
||
/// <summary> | ||
/// A class representing the default implementation of <see cref="IMessageSinkAccessor"/>. This class cannot be inherited. | ||
/// </summary> | ||
/// <remarks> | ||
/// Initializes a new instance of the <see cref="MessageSinkAccessor"/> class. | ||
/// </remarks> | ||
/// <param name="messageSink">The <see cref="IMessageSink"/> to use.</param> | ||
/// <exception cref="ArgumentNullException"> | ||
/// <paramref name="messageSink"/> is <see langword="null"/>. | ||
/// </exception> | ||
internal sealed class MessageSinkAccessor(IMessageSink messageSink) : IMessageSinkAccessor | ||
{ | ||
/// <summary> | ||
/// Gets or sets the current <see cref="IMessageSink"/>. | ||
/// </summary> | ||
public IMessageSink? MessageSink { get; set; } = messageSink ?? throw new ArgumentNullException(nameof(messageSink)); | ||
} |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.