Daniel GrunwaldDaniel Grunwald

My feedback

  1. 215 votes
    Vote
    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      You have left! (?) (thinking…)
      8 comments  ·  Visual Studio IDE » Languages - C#  ·  Flag idea as inappropriate…  ·  Admin →
      Daniel GrunwaldDaniel Grunwald commented  · 

      The problem is that such complex attribute values cannot be directly represented in IL. A solution to that could be to compile such an attribute into a *method* that constructs the attribute instance as runtime. Then C# could support arbitrary expressions in attributes just by compiling them into that method.

      Of course, this also requires changes to the metadata format and System.Reflection to support such method-based attributes.

    • 187 votes
      Vote
      Sign in
      Check!
      (thinking…)
      Reset
      or sign in with
      • facebook
      • google
        Password icon
        I agree to the terms of service
        Signed in as (Sign out)
        You have left! (?) (thinking…)
        19 comments  ·  Visual Studio IDE » Languages - C#  ·  Flag idea as inappropriate…  ·  Admin →
        Daniel GrunwaldDaniel Grunwald commented  · 

        I think this is a great idea; but it should allow only the following interfaces:
        IEnumerable[T]
        IReadOnlyCollection[T]
        IReadOnlyList[T]

        These three are implemented by arrays, so the compiler can just pass in a simple array at the call site. And they don't allow the method to pass any modifications back to the caller.

        The current workaround is to use two overloads - one that accepts the interface type, and one that accepts arrays only so that it can use params.

      Feedback and Knowledge Base