Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
248 views
in Technique[技术] by (71.8m points)

c# - Inherited Properties not visible in Debugger - Blazor

Im working on a Blazor app and I implemented some classes that have inheritance. When I create a Derived Class object it works fine and I can access and set all the values that it inherited from the Base Class, but when I hit a breakpoint and use the debugger to inspect the object, it only shows the properties that are in the derived class.

Whats happening?

Classes:

public class Event {
  public int Id { get; set; }
  [Required]
  public string Title { get; set; }
  [Required]
  public DateTime Start { get; set; }
  [Required]
  public DateTime End { get; set; }
}

public class Shift :Event{
  //[Required]
  public ShiftRepeat Repeat { get; set; }
  //[Required]
  public List<Break> Breaks { get; set; }
  public Shift ShallowCopy() {
    return (Shift)this.MemberwiseClone();
  }
}

Element Debugger is inspecting

      var n = new Shift() {
        Id = 1,
        Title = "Shift 1",
        Start = new DateTime(2021, 1, 18, 8, 0, 0),
        End = new DateTime(2021, 1, 18, 16, 0, 0),
        Repeat = ShiftRepeat.Daily,
        Breaks = new List<Break>() {
          new Break() {
            Id = 1,
            Title = "Lunch",
            Start = new DateTime(2021, 1, 18, 12, 0, 0),
            End = new DateTime(2021, 1, 18, 12, 30, 0)
          }
        }
      };

Debugger inspection One Drive File Download

question from:https://stackoverflow.com/questions/65850088/inherited-properties-not-visible-in-debugger-blazor

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Actually, I can see the inherited properties during debugging.

enter image description here

Maybe try the following suggestions:

1) disable any installed third party extensions under Extensions-->Manage Extensions

2) reset all vs settings under Tools-->Import and Export Settings-->Reset all settings

3) close VS, delete .vs hidden folder under the solution folder, bin and obj folder and then restart your project

4) run devnev /safemode under Developer Command prompt for VS to start a pure VS and then test your project under that instance.

5) or you could try to create a new blazor app and then test your code under that new proejct.

6) update your VS if there is a new release version or repair VS under vs_installer


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...