5

Decompilation of MarkupExtension class looks like this:

[TypeForwardedFrom("WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")] public abstract class MarkupExtension { [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] protected MarkupExtension() { } public abstract object ProvideValue(IServiceProvider serviceProvider); } 

As you can see, it could have been implemented as an interface, but instead it's a class. Why did the WPF team designed it this way? Moreover, in Silverlight it is an interface.

3
  • You are right in this case it has no benefit because the MarkupExtension class here has no state of functionality implemented. Commented Sep 18, 2013 at 12:14
  • 1
    Why is this question on hold? It just has one good answer (even if factually wrong it is not opinion-based), and one bad (o-b). The question itself is not about one's opinion, but about the reason for particular design decision. Commented Sep 19, 2013 at 8:56
  • @downvoter care to explain? Commented Sep 19, 2013 at 10:17

1 Answer 1

0

In .NET you've NGEN ( Native generator ), which lets you to compile IL code into machine code which is suitable for the specific machine that is running your application. ( You can not use this tool to compile your IL code to machine code for all computers, this tool has dependency on CPU, OS and ... ]. Your application's performance will be boosted too much because of this tool.

The attribute [TargetedPatchingOptOut] which is used in WPF (.NET) version code, is for NGEN tool, and this attribute is here to be used on top of constructor, so the interface is not suitable here.

In Silverlight you've no NGEN, you've no attribute named [TargetedPatchingOptOut]

Good luck

Sign up to request clarification or add additional context in comments.

3 Comments

Incorrect and irrelevant. This attribute is used to inline code to make targeted patching impossible. In case of empty code blocks, it effectively removes all the code. A constructor from .NET framework with this attribute becomes nothing.
@Athari I'm not going to say that your idea is wrong, but could you please provide me a link ?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.