TargetedPatchingOptOut and other abstract method attributes

Since attributes such as TargetedPatchingOptOut are not processed inside the framework, are attributes distributed to inherited classes during optimization?

For instance:

public abstract class TestBase
{
    [TargetedPatchingOptOut("Optimize across boundaries")]
    public abstract void TestFunc();
}

public class Test : TestBase
{
    // Is re-defining attributes like these necessary?
    public override void TestFunc()
    {
        throw new NotImplementedException();
    }
}

Also does the JIT compiler (always / always) look for inherited attributes?

Note. . Although the specific functionality above can be easily understood by studying the JIT instructions on WinDbg using several (tedious) extravagant methods, I appreciate any ideas about how it is implemented, since it is not impossible for a JIT compiler to behave very differently for different attributes, not knowing its exact implementation .

Update:

, TargetedPatchingOptOut JIT, infact NGen. @Hans Passant.

, , , AttributeUsage.

+4
1

, AttributeUsageAttribute.Inherited. :

[AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor, 
     AllowMultiple = false, Inherited = false)]
public sealed class TargetedPatchingOptOutAttribute : Attribute {
    // etc...
}

, , Type.GetCustomAttribute(), inherit, .

, . [TargetedPatchingOptOut] . Ngen.exe . , , , , , Microsoft .

+3

Source: https://habr.com/ru/post/1539560/


All Articles