Skip to content

Move some core type into internal & migrate to slnx + Check unit test #881

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

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions BreakingChanges.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Obsolete api is removed
* CompatArg is marked as obsolete
* Nullability is enabled for public api for .NET 8+. Workaround: you can disable nullability `<Nullable>disable</Nullable>` on project if you don't want to use it. more info https://learn.microsoft.com/en-us/dotnet/csharp/nullable-references
* Move some core type into NSubstitute.Internal namespace. Types from internal namespace could be removed\changed without notification in next version. Try to avoid using them directly.

5.0.0 Release
================
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* [NEW] Added .NET 9 to test matrix
* [UPDATE] Migrate documentation to docfx platform. https://github.com/dotnet/docfx
* [UPDATE][BREAKING] Nullability is enabled for public api for .NET Core TFMs
* [UPDATE][BREAKING] Move some core type into NSubstitute.Internal namespace. Types from internal namespace could be removed\changed without notification in next version. Try to avoid using them directly.

### 5.3.0 (October 2024)

Expand Down
60 changes: 0 additions & 60 deletions NSubstitute.sln

This file was deleted.

20 changes: 20 additions & 0 deletions NSubstitute.slnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Solution>
<Folder Name="/build/">
<File Path="build/build.fs" />
<File Path="build/ExtractDocs.fs" />
</Folder>
<Folder Name="/Solution Items/">
<File Path=".editorconfig" />
<File Path="BreakingChanges.md" />
<File Path="CHANGELOG.md" />
<File Path="Directory.Build.props" />
<File Path="README.md" />
</Folder>
<Folder Name="/src/">
<Project Path="src/NSubstitute/NSubstitute.csproj" />
</Folder>
<Folder Name="/tests/">
<Project Path="tests/NSubstitute.Acceptance.Specs/NSubstitute.Acceptance.Specs.csproj" />
<Project Path="tests/NSubstitute.Benchmarks/NSubstitute.Benchmarks.csproj" />
</Folder>
</Solution>
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
NSubstitute
========
[![Build, Test, and Format verification](https://github.com/nsubstitute/NSubstitute/actions/workflows/test.yml/badge.svg)](https://github.com/nsubstitute/NSubstitute/actions/workflows/test.yml)
[![Build, Test, and Format verification](https://github.com/nsubstitute/NSubstitute/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/nsubstitute/NSubstitute/actions/workflows/test.yml)
[![Nuget](https://img.shields.io/nuget/v/NSubstitute.svg)](https://www.nuget.org/packages/NSubstitute)

Visit the [NSubstitute website](https://nsubstitute.github.io) for more information.
Expand Down
1 change: 0 additions & 1 deletion build/ExtractDocs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ using System.Collections.Generic;
using System.ComponentModel;
using NSubstitute.Extensions;
using NSubstitute.Compatibility;
using NSubstitute.ExceptionExtensions;

namespace NSubstitute.Samples {
public class Tests_%s {
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/2010-05-02-throwing-exceptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ICalculator calculator;
```
-->

The `Throws` and `ThrowsAsync` helpers in the `NSubstitute.ExceptionExtensions` namespace can be used to throw exceptions when a member is called.
The `Throws` and `ThrowsAsync` helpers in the `NSubstitute.Extensions` namespace can be used to throw exceptions when a member is called.

```csharp
//For non-voids:
Expand Down
1 change: 1 addition & 0 deletions src/NSubstitute/Arg.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NSubstitute.Core.Arguments;
using NSubstitute.Internal.Core.Arguments;
using System.Linq.Expressions;

namespace NSubstitute;
Expand Down
1 change: 1 addition & 0 deletions src/NSubstitute/Core/Arguments/ArgumentMatcher.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NSubstitute.Exceptions;
using NSubstitute.Internal.Core.Arguments;

namespace NSubstitute.Core.Arguments;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using NSubstitute.Internal.Core;
using System.Reflection;

namespace NSubstitute.Core.Arguments;
Expand Down
2 changes: 1 addition & 1 deletion src/NSubstitute/Core/CallInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Diagnostics.CodeAnalysis;
using NSubstitute.Exceptions;
using System.Diagnostics.CodeAnalysis;

namespace NSubstitute.Core;

Expand Down
2 changes: 1 addition & 1 deletion src/NSubstitute/Core/DependencyInjection/NSubContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private void SetRegistration(Type type, Registration registration)
}
}

private class Registration(Func<NSubContainer.Scope, object> factory, NSubLifetime lifetime)
private class Registration(Func<Scope, object> factory, NSubLifetime lifetime)
{
private object? _singletonValue;
public NSubLifetime Lifetime { get; } = lifetime;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using NSubstitute.Core.Arguments;
using NSubstitute.Proxies.CastleDynamicProxy;
using NSubstitute.Routing;
using NSubstitute.Routing.AutoValues;
using NSubstitute.Internal.Core;
using NSubstitute.Internal.Core.Arguments;
using NSubstitute.Internal.Proxies.CastleDynamicProxy;
using NSubstitute.Internal.Routing;
using NSubstitute.Internal.Routing.AutoValues;

namespace NSubstitute.Core.DependencyInjection;

Expand Down
1 change: 1 addition & 0 deletions src/NSubstitute/Core/ICall.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Reflection;
using NSubstitute.Core.Arguments;
using NSubstitute.Internal.Core;

namespace NSubstitute.Core;

Expand Down
2 changes: 2 additions & 0 deletions src/NSubstitute/Core/ICallRouter.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using NSubstitute.Internal.Core;

namespace NSubstitute.Core;

public interface ICallRouter
Expand Down
2 changes: 1 addition & 1 deletion src/NSubstitute/Core/ICallSpecification.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Reflection;
using NSubstitute.Core.Arguments;
using NSubstitute.Internal.Core.Arguments;

namespace NSubstitute.Core;

Expand Down
2 changes: 2 additions & 0 deletions src/NSubstitute/Core/ICallSpecificationFactory.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using NSubstitute.Internal.Core;

namespace NSubstitute.Core;

public interface ICallSpecificationFactory
Expand Down
2 changes: 2 additions & 0 deletions src/NSubstitute/Core/IConfigureCall.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using NSubstitute.Internal.Core;

namespace NSubstitute.Core;

public interface IConfigureCall
Expand Down
2 changes: 1 addition & 1 deletion src/NSubstitute/Core/IDescribeNonMatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace NSubstitute.Core;

/// <summary>
/// A type that can describe how an argument does not match a required condition.
/// Use in conjunction with <see cref="NSubstitute.Core.Arguments.IArgumentMatcher"/> to provide information about
/// Use in conjunction with <see cref="Arguments.IArgumentMatcher"/> to provide information about
/// non-matches.
/// </summary>
public interface IDescribeNonMatches
Expand Down
2 changes: 1 addition & 1 deletion src/NSubstitute/Core/IDescribeSpecification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace NSubstitute.Core;

/// <summary>
/// A type that can describe the required conditions to meet a specification.
/// Use in conjunction with <see cref="NSubstitute.Core.Arguments.IArgumentMatcher"/> to provide information about
/// Use in conjunction with <see cref="Arguments.IArgumentMatcher"/> to provide information about
/// what it requires to match an argument.
/// </summary>
public interface IDescribeSpecification
Expand Down
4 changes: 3 additions & 1 deletion src/NSubstitute/Core/IGetCallSpec.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace NSubstitute.Core;
using NSubstitute.Internal.Core;

namespace NSubstitute.Core;

public interface IGetCallSpec
{
Expand Down
4 changes: 3 additions & 1 deletion src/NSubstitute/Core/IPendingSpecification.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace NSubstitute.Core;
using NSubstitute.Internal.Core;

namespace NSubstitute.Core;

public interface IPendingSpecification
{
Expand Down
2 changes: 2 additions & 0 deletions src/NSubstitute/Core/IQueryResults.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using NSubstitute.Internal.Core;

namespace NSubstitute.Core;

public interface IQueryResults
Expand Down
2 changes: 1 addition & 1 deletion src/NSubstitute/Core/IReceivedCallsExceptionThrower.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using NSubstitute.ReceivedExtensions;
using NSubstitute.Extensions;

namespace NSubstitute.Core;

Expand Down
3 changes: 2 additions & 1 deletion src/NSubstitute/Core/IReturn.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Concurrent;
using System.Reflection;
using NSubstitute.Exceptions;
using NSubstitute.Internal.Core;

namespace NSubstitute.Core;

Expand Down Expand Up @@ -38,7 +39,7 @@ public class ReturnValueFromFunc<T>(Func<CallInfo, T?>? funcToReturnValue) : IRe
private static Func<CallInfo, T?> ReturnNull()
{
if (typeof(T).GetTypeInfo().IsValueType) throw new CannotReturnNullForValueType(typeof(T));
return x => default(T);
return x => default;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/NSubstitute/Core/ISubstituteState.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using NSubstitute.Routing.AutoValues;
using NSubstitute.Internal.Routing.AutoValues;

namespace NSubstitute.Core;

Expand Down
2 changes: 1 addition & 1 deletion src/NSubstitute/Core/ISubstitutionContext.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using NSubstitute.Routing;
using NSubstitute.Internal.Routing;

namespace NSubstitute.Core;

Expand Down
3 changes: 2 additions & 1 deletion src/NSubstitute/Core/IThreadLocalContext.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using NSubstitute.Core.Arguments;
using NSubstitute.Routing;
using NSubstitute.Internal.Core;
using NSubstitute.Internal.Routing;

namespace NSubstitute.Core;

Expand Down
2 changes: 1 addition & 1 deletion src/NSubstitute/Core/SubstitutionContext.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using NSubstitute.Core.DependencyInjection;
using NSubstitute.Routing;
using NSubstitute.Internal.Routing;

namespace NSubstitute.Core;

Expand Down
3 changes: 2 additions & 1 deletion src/NSubstitute/Exceptions/AmbiguousArgumentsException.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System.Collections;
using System.Reflection;
using System.Text;
using NSubstitute.Core;
using NSubstitute.Core.Arguments;
using NSubstitute.Internal.Core;
using NSubstitute.Internal.Core.Arguments;
using static System.Environment;

namespace NSubstitute.Exceptions;
Expand Down
6 changes: 3 additions & 3 deletions src/NSubstitute/Extensions/ClearExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using NSubstitute.Core;
using NSubstitute.Exceptions;
using NSubstitute.Exceptions;
using NSubstitute.Core;

namespace NSubstitute.ClearExtensions;
namespace NSubstitute.Extensions;

public static class ClearExtensions
{
Expand Down
4 changes: 2 additions & 2 deletions src/NSubstitute/Extensions/ConfigurationExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using NSubstitute.Core;
using NSubstitute.Exceptions;
using NSubstitute.Exceptions;
using NSubstitute.Core;

namespace NSubstitute.Extensions;

Expand Down
3 changes: 2 additions & 1 deletion src/NSubstitute/Extensions/ExceptionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using NSubstitute.Core;
using NSubstitute.Internal.Core;
using System.Reflection;

namespace NSubstitute.ExceptionExtensions;
namespace NSubstitute.Extensions;

public static class ExceptionExtensions
{
Expand Down
3 changes: 2 additions & 1 deletion src/NSubstitute/Extensions/ProtectedExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using System.Reflection;
using NSubstitute.Internal.Core;
using NSubstitute.Exceptions;
using NSubstitute.Core;
using NSubstitute.Core.Arguments;
using NSubstitute.Exceptions;

// Disable nullability for client API, so it does not affect clients.
#nullable disable annotations
Expand Down
5 changes: 3 additions & 2 deletions src/NSubstitute/Extensions/ReceivedExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using NSubstitute.Core;
using NSubstitute.Exceptions;
using NSubstitute.Internal.Core;

namespace NSubstitute.ReceivedExtensions;
namespace NSubstitute.Extensions;

public static class ReceivedExtensions
{
Expand Down Expand Up @@ -143,7 +144,7 @@ public RangeQuantity(int minInclusive, int maxInclusive)
this.maxInclusive = maxInclusive;
}
public override string Describe(string singularNoun, string pluralNoun) =>
$"between {minInclusive} and {maxInclusive} (inclusive) {((maxInclusive == 1) ? singularNoun : pluralNoun)}";
$"between {minInclusive} and {maxInclusive} (inclusive) {(maxInclusive == 1 ? singularNoun : pluralNoun)}";

public override bool Matches<T>(IEnumerable<T> items)
{
Expand Down
4 changes: 2 additions & 2 deletions src/NSubstitute/Extensions/ReturnsExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using NSubstitute.Core;
using NSubstitute.Internal.Core;


namespace NSubstitute.ReturnsExtensions;
namespace NSubstitute.Extensions;

public static class ReturnsExtensions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using NSubstitute.Core.Arguments;
using NSubstitute.Core;
using NSubstitute.Core.Arguments;

namespace NSubstitute.Core;
namespace NSubstitute.Internal.Core;

public class ArgumentSpecificationDequeue(Func<IList<IArgumentSpecification>> dequeueAllQueuedArgSpecs) : IArgumentSpecificationDequeue
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace NSubstitute.Core.Arguments;
using NSubstitute.Core.Arguments;

namespace NSubstitute.Internal.Core.Arguments;

public class AnyArgumentMatcher(Type typeArgMustBeCompatibleWith) : IArgumentMatcher
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace NSubstitute.Core.Arguments;
using NSubstitute.Core.Arguments;

namespace NSubstitute.Internal.Core.Arguments;

public class ArgumentFormatter : IArgumentFormatter
{
Expand Down
Loading
Loading