Generic defined in unit breaking debug information

拥有回忆 提交于 2019-12-05 10:43:18

Have you ensured that all lines of the unit in question end in CR LF? The debugger can't handle just CR or LF while the editor can. Something like Notepad++, TextPad, etc can show you if there is a mixture. Loading it up in [Windows] NotePad and re-saving it can resolve it.

In the end, the only solution that I could find that worked was to move the generic list out of the Unit.

Update 2011-08-03 To better flesh out my solution:

I had my generic list base class defined in my Domain unit with my base TDomainObject class and a non-generic version.

To fix the problem, I moved the generic into a second Domain.Generics unit which resolved the problem for me.

So:

unit Domain;

interface 

type
  TDomainObject = class
    //blah de blah
  end;

  TDomainObjectList = class (TDomainObject)
    //more stuff
  end;

  TDomainListEnumerator = class
    //etc
  end;

And:

unit Domain.Generics;

interface

type

  TDomainObjectList<T: TDomainObject> = class (TDomainObjectList)
    //stuff
  public
    property Items[AIndex: integer]: T read GetItem write SetItem;

    type
      TEnumerator = class (TDomainListEnumerator)
      public
        function GetCurrent: T;
        property Current: T read GetCurrent;
      end;

  public
    function GetEnumerator: TEnumerator;

  end;
Jeroen Wiert Pluimers

Often this is the internal/external compile state getting out of sync.

First step is to get rid of the .dcu files for your project, then restart Delphi, then do a full build. If the problem persists, then check out Nick's answer.

--jeroen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!