I'm trying to fix another VCL bug; this time in Vcl.Printers.pas
.
For now we are doing this by copying the buggy VCL source files to another folder in the Delphi library path, and applying fixes to those files. We applied the fix to TPrinter.SetPrinter
.
But there are six methods in the file that are decorated with attributes:
[PrintingPermission(SecurityAction.LinkDemand, Level=PrintingPermissionLevel.AllPrinting)]
procedure TPrinter.Abort;
begin
...
[PrintingPermission(SecurityAction.LinkDemand, Level=PrintingPermissionLevel.AllPrinting)]
procedure TPrinter.EndDoc;
begin
...
[PrintingPermission(SecurityAction.LinkDemand, Level=PrintingPermissionLevel.AllPrinting)]
procedure TPrinter.NewPage;
begin
...
[PrintingPermission(SecurityAction.LinkDemand, Level=PrintingPermissionLevel.AllPrinting)]
{$IF DEFINED(CLR)}
procedure TPrinter.SetPrinter(ADevice, ADriver, APort: string; ADeviceMode: IntPtr);
{$ELSE}
procedure TPrinter.SetPrinter(ADevice, ADriver, APort: PChar; ADeviceMode: THandle);
{$ENDIF}
var
...
[PrintingPermission(SecurityAction.LinkDemand, Level=PrintingPermissionLevel.AllPrinting)]
function SetPrinter(NewPrinter: TPrinter): TPrinter;
begin
...
Each of these methods causes a warning:
- [dcc32 Warning] Vcl.Printers.pas(968): W1025 Unsupported language feature: 'custom attribute'
- [dcc32 Warning] Vcl.Printers.pas(978): W1025 Unsupported language feature: 'custom attribute'
- [dcc32 Warning] Vcl.Printers.pas(1015): W1025 Unsupported language feature: 'custom attribute'
- [dcc32 Warning] Vcl.Printers.pas(1026): W1025 Unsupported language feature: 'custom attribute'
- [dcc32 Warning] Vcl.Printers.pas(1080): W1025 Unsupported language feature: 'custom attribute'
- [dcc32 Warning] Vcl.Printers.pas(1599): W1025 Unsupported language feature: 'custom attribute'
I could just remove the attributes. Or presumably there is a way to suppress the warnings. But i assume attributes added by Embarcadero have some purpose.
- What is the way to make the language support the feature custom attributes?
- Why is it not a warning in the VCL source?
- Why is VCL source allowed to use it when i'm not?
- What are these attributes doing?
- Who reads these attribues?
- Are there issues with removing them?
- If there are no issues with removing them, why are they there?
I'm really asking:
How do i make it work?
But i'd also love to know:
Why is it not working?
And the why makes it a much more useful question, but the fix it would be good.
Bonus Chatter
Yes, we eventually plan to think about the possibility of investigating the use of detours. Although presumably the detoured method should still have the attribute (otherwise why would the attribute exist?)