Skip to content

Default Arguments Using default and [AllowNull] #279

@JasonBock

Description

@JasonBock

Describe the bug
When a method has a default argument that uses [AllowNull], Rocks passes that into an Argument, which causes a CS8604 error

To Reproduce

var code =
  """
  using Rocks;
  using System.Diagnostics.CodeAnalysis;

  #nullable enable

  public interface IGraphType { }

  public class ConnectionBuilder<TSourceType>
  {
    public virtual ConnectionBuilder<TSourceType> Argument<TArgumentGraphType, TArgumentType>(string name, string? description,
      [AllowNull] TArgumentType defaultValue = default!)
        where TArgumentGraphType : IGraphType => new();
  }

  public static class Test
  {
    public static void Go() => Rock.Create<ConnectionBuilder<object>>();
  }
  """;

Expected behavior
The mock is created with no issues.

Additional context
This was found on GraphQL.Builders.ConnectionBuilder<>

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions