Jonathan GilbertJonathan Gilbert

My feedback

  1. 28 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…)
      2 comments  ·  Visual Studio IDE » Debugging and Diagnostics  ·  Flag idea as inappropriate…  ·  Admin →
      Jonathan GilbertJonathan Gilbert commented  · 

      Here's an example: Suppose you have code like this:

      static int Main()
      {
        var globalConfiguration = LoadGlobalConfiguration();
        var localConfigukration = LoadLocalConfiguration();

      var configuration = ApplyConfigurationOverrides(globalConfiguration, localConfiguration);

        RunService(configuration);
      }

      Now, suppose in my debug run I need to completely override the configuration. Currently, I could create an entry in the Watch window like this:

        configuration = new Configuration() { GronkulatorEnabled = true, LogSinks = LogSinks.Console, LogLevel = LogLevel.Diagnostic }

      Then, I put a breakpoint on the LoadGlobalConfiguration line, and on every test run, it stops on that line, and I use "Set Next Statement" to move execution to the RunService line and click the "Refresh" button in the watch window. This, then, overrides the configuration with my debugging configuration each time. This is a lot of work, though, and the more complicated code is, the easier it is to miss a step and invalidate a debug run.

      With my proposed feature, you could select the three "var" lines of the method, right-click and select "Add Debug Shunt". A dialog would pop up, with a code snippet editor, and with a hint stating that variables "globalConfiguration", "localConfiguration" and "configuration" must be assigned by the end of the code block. In that code snippet editor, I could then type:

        globalConfiguration = null;
        localConfiguration = null;
        configuration = new Configuration() { GronkulatorEnabled = true, LogSinks = LogSinks.Console, LogLevel = LogLevel.Diagnostic };

      With this shunt added, simply hitting "Start Debug" would automatically replace the effect of the three "var" lines with the lines in the code snippet. The ultimate effect would be the same as if I had used "Edit and Continue" to replace those lines of code with my shunt code, except without any permanent effect outside of debug sessions.

      Jonathan GilbertJonathan Gilbert shared this idea  · 
    • 7 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…)
        3 comments  ·  Visual Studio IDE » IDE and Editor  ·  Flag idea as inappropriate…  ·  Admin →
        Jonathan GilbertJonathan Gilbert supported this idea  · 
        Jonathan GilbertJonathan Gilbert commented  · 

        (I want this too :-) )

        Jonathan GilbertJonathan Gilbert commented  · 

        switch (foo)
        {
          case "bar":
            Run();
            break;
          case "qux":
          {
            var fred = ReadInput();

            var wilma = Process(fred);

            ShowOutput(wilma);

            continue;
          }
          case "eenp":
          {
            var fred = ImportGarply();

            Gronkulate(fred);

            goto case "qux";
          }

          default:
            throw new ArgumentException(nameof(foo));
        }

      • 5,308 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…)
          92 comments  ·  Visual Studio IDE » Languages - C#  ·  Flag idea as inappropriate…  ·  Admin →
          Jonathan GilbertJonathan Gilbert commented  · 

          I think this would have to be implemented as a core runtime feature. In the same way that IL opcodes were added to assist with the new Nullable<T> type in .NET 2.0, what we'd need is a NotNullable<T> struct whose behaviour was special-cased in the CLR.

          This type would have the following properties:

          * It does *not* have a default constructor. Code that attempts to initialize the struct in this way is malformed IL.
          * NotNullable<T> converts to T transparently at the machine code level.
          * Converting T to NotNullable<T> performs a check that the reference is not null. This *could* be done in the C# code implementing NotNullable<T> itself, though we would definitely want the check & conversion to be inlined.
          * To provide support for languages that do not expose any syntactic sugar for it, a public property Value would allow the reference to be extracted as type T.
          * The JIT could omit null reference checks when accessing members of an instance of T via NotNullable<T>, because no valid IL can produce a NotNullable<T> that is a null reference.

          This could then be exposed in languages like C# and VB.NET using a modifier character such as an exclamation point. It would probably make sense for C# to require an explicit cast of T to T!, in keeping with its policy of explicitly showing behaviour. This conversion could, of course, throw a NullReferenceException (in any language).

          Because of the constraint on validity of IL with regards to default initialization of this new struct, compilers targeting the new CLR version would at a minimum need to detect this usage and refuse to compile default(NotNullable<T>) or new NotNullable<T>(). That would be the only change required to be barebones functional with the new type.

        • 3,192 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…)
            34 comments  ·  Visual Studio IDE » Languages - C#  ·  Flag idea as inappropriate…  ·  Admin →
            Jonathan GilbertJonathan Gilbert supported this idea  · 
          • 345 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…)
              6 comments  ·  Visual Studio IDE » Languages - C#  ·  Flag idea as inappropriate…  ·  Admin →
              Jonathan GilbertJonathan Gilbert supported this idea  · 
            • 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 →
                Jonathan GilbertJonathan Gilbert supported this idea  · 
              • 387 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…)
                  12 comments  ·  Visual Studio IDE » .NET  ·  Flag idea as inappropriate…  ·  Admin →

                Feedback and Knowledge Base