-
Notifications
You must be signed in to change notification settings - Fork 268
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
Enable nullability for public api #856
Open
Romfos
wants to merge
9
commits into
nsubstitute:main
Choose a base branch
from
Romfos:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2fc9241
Adopt records for some classes
Romfos b990b77
Obsolete Arg.Compat
Romfos 1a1f964
Enable nullability for public api
Romfos 9d46068
Update changelogs
Romfos 94b64cb
Disable compat warnings for ArgumentMatchingCompat
Romfos 28bd6b6
Remove unsuable files
Romfos 7f63a73
Update changelog
Romfos 382ccc3
Added workaraund for nullability
Romfos 922e883
Update editorconfig
Romfos 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
* [UPDATE] Mark as obsolete api CompatArg with pre c# 7.0 support | ||
* [NEW] Added .NET 9 to test matrix | ||
* [UPDATE] Migrate documentation to docfx platform. https://github.com/dotnet/docfx | ||
* [UPDATE] Nullability is enabled for public api for .NET Core TFMs | ||
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. nitpick: this should be |
||
|
||
### 5.3.0 (October 2024) | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
using System.Linq.Expressions; | ||
|
||
// Disable nullability for client API, so it does not affect clients. | ||
#nullable disable annotations | ||
#pragma warning disable CS0419 | ||
|
||
namespace NSubstitute; | ||
|
||
public static partial class Arg | ||
{ | ||
/// <summary> | ||
/// Alternate version of <see cref="Arg"/> matchers for compatibility with pre-C#7 compilers | ||
/// which do not support <c>ref</c> return types. Do not use unless you are unable to use <see cref="Arg"/>. | ||
/// | ||
/// For more information see <see href="https://nsubstitute.github.io/help/compat-args">Compatibility Argument | ||
/// Matchers</see> in the NSubstitute documentation. | ||
/// </summary> | ||
[Obsolete("This api is deprecated and will be removed in future versions of product.")] | ||
public static class Compat | ||
{ | ||
/// <summary> | ||
/// Match any argument value compatible with type <typeparamref name="T"/>. | ||
/// This is provided for compatibility with older compilers -- | ||
/// if possible use <see cref="Arg.Any{T}" /> instead. | ||
/// </summary> | ||
public static T Any<T>() => Arg.Any<T>(); | ||
|
||
/// <summary> | ||
/// Match argument that is equal to <paramref name="value"/>. | ||
/// This is provided for compatibility with older compilers -- | ||
/// if possible use <see cref="Arg.Is{T}(T)" /> instead. | ||
/// </summary> | ||
public static T Is<T>(T value) => Arg.Is(value); | ||
|
||
/// <summary> | ||
/// Match argument that satisfies <paramref name="predicate"/>. | ||
/// If the <paramref name="predicate"/> throws an exception for an argument it will be treated as non-matching. | ||
/// This is provided for compatibility with older compilers -- | ||
/// if possible use <see cref="Arg.Is{T}(Expression{Predicate{T}})" /> instead. | ||
/// </summary> | ||
public static T Is<T>(Expression<Predicate<T>> predicate) => Arg.Is(predicate); | ||
|
||
/// <summary> | ||
/// Match argument that satisfies <paramref name="predicate"/>. | ||
/// If the <paramref name="predicate"/> throws an exception for an argument it will be treated as non-matching. | ||
/// This is provided for compatibility with older compilers -- | ||
/// if possible use <see cref="Arg.Is{T}(Expression{Predicate{T}})" /> instead. | ||
/// </summary> | ||
public static AnyType Is<T>(Expression<Predicate<object>> predicate) where T : AnyType => Arg.Is<T>(predicate); | ||
|
||
/// <summary> | ||
/// Invoke any <see cref="Action"/> argument whenever a matching call is made to the substitute. | ||
/// This is provided for compatibility with older compilers -- | ||
/// if possible use <see cref="Arg.Invoke" /> instead. | ||
/// </summary> | ||
public static Action Invoke() => Arg.Invoke(); | ||
|
||
/// <summary> | ||
/// Invoke any <see cref="Action<T>"/> argument with specified argument whenever a matching call is made to the substitute. | ||
/// This is provided for compatibility with older compilers -- | ||
/// if possible use <see cref="Arg.Invoke{T}" /> instead. | ||
/// </summary> | ||
public static Action<T> Invoke<T>(T arg) => Arg.Invoke(arg); | ||
|
||
/// <summary> | ||
/// Invoke any <see cref="Action<T1,T2>"/> argument with specified arguments whenever a matching call is made to the substitute. | ||
/// This is provided for compatibility with older compilers -- | ||
/// if possible use <see cref="Arg.Invoke{T1,T2}" /> instead. | ||
/// </summary> | ||
public static Action<T1, T2> Invoke<T1, T2>(T1 arg1, T2 arg2) => Arg.Invoke(arg1, arg2); | ||
|
||
/// <summary> | ||
/// Invoke any <see cref="Action<T1,T2,T3>"/> argument with specified arguments whenever a matching call is made to the substitute. | ||
/// This is provided for compatibility with older compilers -- | ||
/// if possible use <see cref="Arg.Invoke{T1,T2,T3}" /> instead. | ||
/// </summary> | ||
public static Action<T1, T2, T3> Invoke<T1, T2, T3>(T1 arg1, T2 arg2, T3 arg3) => Arg.Invoke(arg1, arg2, arg3); | ||
|
||
/// <summary> | ||
/// Invoke any <see cref="Action<T1,T2,T3,T4>"/> argument with specified arguments whenever a matching call is made to the substitute. | ||
/// This is provided for compatibility with older compilers -- | ||
/// if possible use <see cref="Arg.Invoke{T1,T2,T3,T4}" /> instead. | ||
/// </summary> | ||
public static Action<T1, T2, T3, T4> Invoke<T1, T2, T3, T4>(T1 arg1, T2 arg2, T3 arg3, T4 arg4) => Arg.Invoke(arg1, arg2, arg3, arg4); | ||
|
||
/// <summary> | ||
/// Invoke any <typeparamref name="TDelegate"/> argument with specified arguments whenever a matching call is made to the substitute. | ||
/// This is provided for compatibility with older compilers -- | ||
/// if possible use <see cref="Arg.InvokeDelegate{TDelegate}" /> instead. | ||
/// </summary> | ||
/// <param name="arguments">Arguments to pass to delegate.</param> | ||
public static TDelegate InvokeDelegate<TDelegate>(params object[] arguments) => Arg.InvokeDelegate<TDelegate>(arguments); | ||
|
||
/// <summary> | ||
/// Capture any argument compatible with type <typeparamref name="T"/> and use it to call the <paramref name="useArgument"/> function | ||
/// whenever a matching call is made to the substitute. | ||
/// This is provided for compatibility with older compilers -- | ||
/// if possible use <see cref="Arg.Do{T}" /> instead. | ||
/// </summary> | ||
public static T Do<T>(Action<T> useArgument) => Arg.Do<T>(useArgument); | ||
|
||
/// <summary> | ||
/// Capture any argument compatible with type <typeparamref name="T"/> and use it to call the <paramref name="useArgument"/> function | ||
/// whenever a matching call is made to the substitute. | ||
/// </summary> | ||
public static AnyType Do<T>(Action<object> useArgument) where T : AnyType => Arg.Do<T>(useArgument); | ||
} | ||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: would be good to add explanations for how to work around this for people that update to 6.x and find themselves getting nullability errors.