Vcl.Printers.pas(888):W1025不支持的语言功能:'custom attribute' [英] Vcl.Printers.pas(888): W1025 Unsupported language feature: 'custom attribute'

查看:329
本文介绍了Vcl.Printers.pas(888):W1025不支持的语言功能:'custom attribute'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在修复另一个VCL错误;这一次在 Vcl.Printers.pas 中。



现在我们通过将错误的VCL源文件复制到Delphi库路径中的另一个文件夹,并将修补程序应用于这些文件。我们将修复程序应用于 TPrinter.SetPrinter



但是,文件中有六种方法是用属性装饰的:

  [PrintingPermission(SecurityAction.LinkDemand,Level = PrintingPermissionLevel.AllPrinting)] 
程序TPrinter.Abort;
开始
...

 

  [PrintingPermission(SecurityAction.LinkDemand,Level = PrintingPermissionLevel.AllPrinting)] 
procedure TPrinter.EndDoc;
开始
...

 

  [PrintingPermission(SecurityAction.LinkDemand,Level = PrintingPermissionLevel.AllPrinting)] 
procedure TPrinter.NewPage;
开始
...

 

  [PrintingPermission(SecurityAction.LinkDemand,Level = PrintingPermissionLevel.AllPrinting)] 
{$ IF DEFINED(CLR)}
程序TPrinter。 SetPrinter(ADevice,ADriver,APort:string; ADeviceMode:IntPtr);
{$ ELSE}
程序TPrinter.SetPrinter(ADevice,ADriver,APort:PChar; ADeviceMode:THandle);
{$ ENDIF}
var
...

;

  [PrintingPermission(SecurityAction.LinkDemand,Level = PrintingPermissionLevel.AllPrinting)] 
函数SetPrinter(NewPrinter:TPrinter) :TPrinter;
开始
...

这些方法中的每一个都会导致警告: / p>


  • [dcc32 Warning] Vcl.Printers.pas(968):W1025不支持的语言功能:'custom attribute'

  • [dcc32 Warning] Vcl.Printers.pas(978):W1025不支持的语言功能:'custom attribute'

  • [dcc32 Warning] Vcl.Printers.pas(1015) W1025不支持的语言功能:自定义属性

  • [dcc32警告] Vcl.Printers.pas(1026):W1025不支持的语言功能:'custom attribute'

  • [dcc32 Warning] Vcl.Printers.pas(1080):W1025不支持的语言功能:'custom attribute'

  • [dcc32 Warning] Vcl.Printers.pas(1599):W1025不支持的语言功能:'自定义属性'



我可以删除属性。或者可能有办法抑制警告。但是我假设Embarcadero添加的属性有一些目的。




  • 使语言支持的方式是功能自定义属性

  • 为什么在VCL源中不是警告?

  • 为什么不允许使用VCL源?

  • 这些属性在做什么?

  • 谁读这些作品?

  • 删除它们有问题吗?

  • 如果删除它们没有问题,为什么他们在那里



我真的在问:


我如何让它工作?


但我也很想知道:


为什么不起作用?


为什么使它成为一个更有用的问题,但修正会很好。



Bonus Chatter



,我们最终计划思考调查使用绕行的可能性。虽然大概是迂回的方法还应该有属性(否则为什么属性存在?)

解决方案

错误信息有点误导我会尝试为你翻译。当编译器说:


不支持的语言功能:'custom attribute'


真正的意思是:


找不到从 TCustomAttribute派生的类,与您指定的属性名称相匹配。







这些由.net框架定义的 PrintingPermission 属性对Delphi .NET编译器有意义。 Embarcadero仍然使用它来构建IDE的部分。因此,保留条件代码切换 CLR 定义的存在。当这个VCL单元由Delphi .net编译器编译时,编译器可以看到.net框架类 System.Drawing.Printing.PrintingPermissionAttribute



几乎没有什么可以获得你试图处理VCL单位的警告。这不是你的代码,修改VCL单元的目标是尽可能快地进出。您应该致力于使最小的更改成为可能。



所以,忽略警告。禁止您修改的VCL单元的警告和提示。您编译的任何VCL单元顶部的东西 {$ W - } ,然后继续。或者如果你不能让自己变得如此恶心,你可以使用 {$ WARN UNSUPPORTED_CONSTRUCT OFF}






依次回答您的问题:


使语言支持的方式是什么功能自定义属性?


这不是一个语言限制。只是这些属性仅在定位到.net时才被定义。


为什么VCL源不是一个警告?

至少是为.net以外的目标编译


为什么不允许使用VCL源?


您将被允许使用它们如果您使用.net编译器也是如此。


这些属性在做什么?


System.Drawing.Printing.PrintingPermissionAttribute


谁读这些作品?


.net框架。我想。


是否有解决问题?


它不会影响Windows编译器生成的输出。它将增加您的版本控制系统的差异。


如果删除它们没有问题,为什么会这样? / p>

因为它们在.net上使用。


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?)

解决方案

The error message is a little misleading. I'll try to translate for you. When the compiler says:

Unsupported language feature: 'custom attribute'

what it really means is:

Cannot find a class, derived from TCustomAttribute, that matches the attribute name that you specified.


These PrintingPermission attributes, which are defined by the .net framework, have meaning for the Delphi .net compiler. Which is still used by Embarcadero to build portions of the IDE. Hence the retention of the conditional code which switches on the presence of the CLR define. When this VCL unit is compiled by the Delphi .net compiler, the compiler can see the .net framework class System.Drawing.Printing.PrintingPermissionAttribute.

There's little to be gained by you trying to deal with warnings in VCL units. It's not your code, and your goal when modifying a VCL unit is to get in and out as quickly as possible. You should be aiming to make the smallest change possible.

So, ignore the warnings. Suppress warnings and hints for the VCL units that you modify. Stuff {$W-} at the top of any VCL units you compile, and move on. Or if you just cannot bring yourself to be quite so draconian, you could use {$WARN UNSUPPORTED_CONSTRUCT OFF}.


Taking your questions in turn:

What is the way to make the language support the feature custom attributes?

It's not a language limitation. It's just that these attributes are only defined when targeting .net.

Why is it not a warning in the VCL source?

It is, at least when compiling for a target other than .net.

Why is VCL source allowed to use it when i'm not?

You would be allowed to use them too if you use the .net compiler.

What are these attributes doing?

System.Drawing.Printing.PrintingPermissionAttribute

Who reads these attribues?

The .net framework. I guess.

Are there issues with removing them?

It won't affect the output produced by the Windows compilers. It will increase the volume of differences in your revision control system.

If there are no issues with removing them, why are they there?

Because they are used on .net.

这篇关于Vcl.Printers.pas(888):W1025不支持的语言功能:'custom attribute'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆