I am using a TDictionary
of <string, string>
. But for some reason, the linker decides that I do not want to get items out of it.
I have the following code:
function TSheet.GetFieldName(Field: string; Default: string): string;
begin
Result := Default;
if FFieldNames[Field] = '' then
Result := Field
else
Result := FFieldNames[Field];
end;
FFieldNames
is a TDictionary<string, string>
. On line 2 (if FFieldNames[Field] = '' then
), it throws a 'File not found' exception. Adding FFieldNames[Field]
to my watch tells me that Function to be called, {System.Generics.Collections}TDictionary.GetItem, was eliminated by linker.
Someone asked here on a similar issue on how to avoid the linker eliminating functions during debugging. From this I gathered, that the compiler/linker assumes that I am not using it. Someone suggested - during conversation - that I should try using it more.
So I created the following code:
FFieldNames.Add(Name, S);
V := FFieldNames.Items[Name];
Where S
, Name
and V
are strings. This is from the code where FFieldNames
is filled with data. V
's only purpose is to obtain the just inserted S
; it does nothing else.
Strangely, while the debugger tells me the same thing (i.e. GetItem
being eliminated), V
does get set to the expected value. But it does not in my TSheet.GetFieldName
function. :|
What am I missing?