-
Notifications
You must be signed in to change notification settings - Fork 4
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
Preserve the parameter order when doing the null checks #7
Comments
Potential Bug: What if the implement of the Interface is a structure? |
It is already covered with this, isn't it? |
@AdamSpeight2008 if you are talking about the below situation, it's safe AFAIK. var bar = new FooBar(new Foo());
public class FooBar
{
public FooBar(IFoo foo)
{
if (foo == null)
{
throw new ArgumentNullException(nameof(foo));
}
}
}
public interface IFoo
{
}
public struct Foo : IFoo
{
} |
I'm gonna have a look at this, as I think I have Idea how to implements. (I'll Branch the build) |
This is also applicable for VB implementation. @AdamSpeight2008 can you take a look at VB implementation for this, too? |
This is the basic idea was thinking of implementing. Dim Guards As New List( )( Parameters.Count )
For Each ExistingGuard In ExistingGuards
Dim Index = FindParameterIndexOfGuard( ExistingGuard )
If Index.HasValue Then Guards( Index.Value ) = ExistingGuard
Next
' Remove Existing Guards
' Add new Parameter Guard
Dim NewGuard = CreateSingleLineIfGuard( parameter )
Dim Index = FindParameterIndexOfGuard( NewGuard )
If Index.HasValue Then Guards( Index.Value )
For Each Guard In Guards
' Insert Guard in method
Next I'll try and get a working prototype later one. |
I lean towards this instead:
|
Implemented for VB.net |
Current implementation doesn't preserve the parameter order for the added if statements:
The text was updated successfully, but these errors were encountered: