如何避免内联? [英] how to avoid inlining?

查看:83
本文介绍了如何避免内联?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些看起来像这样的代码:


[DefaultValue(CornerStyle.Rounded)]

public CornerStyle RectCornerMode

{

get {return this [" RectCornerMode"]。GetValue< CornerStyle>(); }

set {this [" RectCornerMode"]。SetValue< CornerStyle>(value); }

}
这个[字符串]中的
我得到了装饰调用方法的属性,并使用

来计算默认值。 br />
现在似乎有时候(在构建发布模式时)属性是通过

传递,调用方法直接调用[string]和GetValue,因此

忽略了装饰属性......


有没有办法避免这种内联?

有什么建议吗?

I have some code which looks like that:

[DefaultValue(CornerStyle.Rounded)]
public CornerStyle RectCornerMode
{
get { return this["RectCornerMode"].GetValue<CornerStyle>(); }
set { this["RectCornerMode"].SetValue<CornerStyle>(value); }
}
in this[string] I get the attribute decorating the calling method, and used
it to compute a default value.
now it seems that sometimes (when build in release mode) the property is by
passed and the calling method call this[string] and GetValue directly, thus
ignoring the decorating attribute....

is there a way to avoid this inlining?
any suggestion?

推荐答案

找到它:MethodImplAttribute。

无论如何我想到了更好的解决方案......


-

问候,

Lloyd Dupont

NovaMind软件

思维导图最佳
www.nova-mind.com

劳埃德杜邦 < net.galador@ldwrote in message

news:ut ************** @ TK2MSFTNGP06.phx.gbl ...
found it: MethodImplAttribute.
Anyway I thought of a better solution...

--
Regards,
Lloyd Dupont
NovaMind Software
Mind Mapping at its best
www.nova-mind.com
"Lloyd Dupont" <net.galador@ldwrote in message
news:ut**************@TK2MSFTNGP06.phx.gbl...

>我有一些代码如下:


[DefaultValue(CornerStyle.Rounded)]

public CornerStyle RectCornerMode

{

get {return this [" RectCornerMode"]。GetValue< CornerStyle>(); }

set {this [" RectCornerMode"]。SetValue< CornerStyle>(value); }

}


这个[string]我得到了装饰调用方法的属性,并且

用它来计算一个默认值。

现在似乎有时(当在发布模式下构建时)属性是通过传递来调用
并且调用方法直接调用此[string]和GetValue,

因此忽略了装饰属性....


有没有办法避免这种内联?

任何建议?
>I have some code which looks like that:

[DefaultValue(CornerStyle.Rounded)]
public CornerStyle RectCornerMode
{
get { return this["RectCornerMode"].GetValue<CornerStyle>(); }
set { this["RectCornerMode"].SetValue<CornerStyle>(value); }
}
in this[string] I get the attribute decorating the calling method, and
used it to compute a default value.
now it seems that sometimes (when build in release mode) the property is
by passed and the calling method call this[string] and GetValue directly,
thus ignoring the decorating attribute....

is there a way to avoid this inlining?
any suggestion?


将其设为虚拟。 JIT无法内联虚拟电话(不太确定这是否为你提供更好的解决方案)


Lloyd Dupont < net.galador@ldwrote in message

news:%2 ***************** @ TK2MSFTNGP03.phx.gbl ...
Make it virtual. JIT can''t inline virtual calls (not quite sure if this is
"better solution" for you)

"Lloyd Dupont" <net.galador@ldwrote in message
news:%2*****************@TK2MSFTNGP03.phx.gbl...

找到它:MethodImplAttribute。

无论如何我想到了更好的解决方案...


-

问候,

Lloyd Dupont

NovaMind软件

最佳思维导图
www.nova-mind.com

" Lloyd Dupont" < net.galador@ldwrote in message

news:ut ************** @ TK2MSFTNGP06.phx.gbl ...
found it: MethodImplAttribute.
Anyway I thought of a better solution...

--
Regards,
Lloyd Dupont
NovaMind Software
Mind Mapping at its best
www.nova-mind.com
"Lloyd Dupont" <net.galador@ldwrote in message
news:ut**************@TK2MSFTNGP06.phx.gbl...

>>我有一些看起来像这样的代码:

[DefaultValue(CornerStyle.Rounded)]
public CornerStyle RectCornerMode
{
get {return this [" RectCornerMode"]。GetValue< CornerStyle>(); }
设置{this [" RectCornerMode"]。SetValue< CornerStyle>(value);这个[字符串]中的
我得到了装饰调用方法的属性,并且用它来计算默认值。
现在看来有时候(当在发布模式下构建时)该属性被传递,并且调用方法直接调用此[string]和GetValue,
因此忽略了装饰属性....

有没有办法避免这种内联?
任何建议?
>>I have some code which looks like that:

[DefaultValue(CornerStyle.Rounded)]
public CornerStyle RectCornerMode
{
get { return this["RectCornerMode"].GetValue<CornerStyle>(); }
set { this["RectCornerMode"].SetValue<CornerStyle>(value); }
}
in this[string] I get the attribute decorating the calling method, and
used it to compute a default value.
now it seems that sometimes (when build in release mode) the property is
by passed and the calling method call this[string] and GetValue directly,
thus ignoring the decorating attribute....

is there a way to avoid this inlining?
any suggestion?




>将其设为虚拟。 JIT不能内联虚拟呼叫(不太确定这是否是更好的解决方案)
>Make it virtual. JIT can''t inline virtual calls (not quite sure if this is
"better solution" for you)



对我来说听起来像是一个可怕的解决方案。让一个虚拟成员只需要实现这种副作用就好了。你应该只在有意义的情况下创建一个虚拟的
成员,并且你已经准备好了处理你的代码可能被覆盖并且可能永远不会<的
br />
运行。


如果实际支持CLR的未来版本(或某些其他运行时实现),您的代码将会中断内联虚拟

方法。

Mattias


-

Mattias Sj?gren [C#MVP ] mattias @ mvps.org
http://www.msjogren.net/dotnet / | http://www.dotnetinterop.com

请回复到新闻组。

Sounds like a horrible solution to me. Making a member virtual just to
achieve this side effect just seems wrong. You should only make a
member virtual when it makes sense to do so and you''re prepared to
handle the fact that your code may be overridden and perhaps never
run.

Plus your code would break if a future version of the CLR (or some
other runtime implementation) actually supported inlining virtual
methods.
Mattias

--
Mattias Sj?gren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.


这篇关于如何避免内联?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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