== Why is this an issue?

The use of ``++[DefaultValue]++`` with ``++[Optional]++`` has no more effect than ``++[Optional]++`` alone. That's because ``++[DefaultValue]++`` doesn't actually do anything; it merely indicates the intent for the value. More than likely, ``++[DefaultValue]++`` was used in confusion instead of ``++[DefaultParameterValue]++``.


=== Noncompliant code example

[source,csharp]
----
class MyClass
{
    public void DoStuff([Optional][DefaultValue(4)]int i, int j = 5)  // Noncompliant
    {
        Console.WriteLine(i);
    }

    public static void Main()
    {
        new MyClass().DoStuff(); // prints 0
    }
}
----


=== Compliant solution

[source,csharp]
----
class MyClass
{
    public void DoStuff([Optional][DefaultParameterValue(4)]int i, int j = 5) 
    {
        Console.WriteLine(i);
    }

    public static void Main()
    {
        new MyClass().DoStuff(); // prints 4
    }
}
----


ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

=== Message

Use "[DefaultParameterValue]" instead.


=== Highlighting

``++[DefaultValue]++``


'''
== Comments And Links
(visible only on this page)

=== on 8 Dec 2015, 09:55:38 Tamas Vajk wrote:
\[~ann.campbell.2] LGTM, but I'm not 100% happy with the title. ``++[DefaultValue]++`` can be used with ``++[Optional]++``, you might build your own tooling around it, and read the value specified in ``++[DefaultValue]++``. So we should probably not say that you shouldn't use it. But I have no better ideas than the current one.



=== on 8 Dec 2015, 15:05:14 Ann Campbell wrote:
\[~tamas.vajk] I struggled with this title myself, and I recognize that ``++[DefaultValue]++`` + ``++[Optional]++`` is a valid usage. But the best alternate title gets into intent, which I don't want to do: '[DefaultValue]" should not be used with "[Optional]" when "[DefaultParamterValue]" was intended'


And if you're building tooling around ``++[DefaultValue]++`` then you'll turn this rule off.

endif::env-github,rspecator-view[]
