How do WPF Markup extensions extend compilation errors?

Some markup extensions cause compilation errors. For example, StaticExtension (x: Static) throws a compilation error if the reference class is not found. Does anyone know a mechanism for this? Is it baked in the XAML compiler or is such a function available for custom markup extensions?

EDIT: The following shows that I need to learn the IVsErrorList interface, but I cannot immediately see how this can help someone with a white markup extension that generates a compile-time error. Any examples?

+3
source share
2 answers

Extending the BAML Compilation Process to Report Additional Errors

. , , , ProvideValue , ProvideValue , XAML , .

, x:Static , BAML. BAML , , XAML x:Static, , , . , StaticExtension. Extension .

, BAML, . BAML , XAML, , , .

, Microsoft.WinFX.targets . XAML , , . BAML. , , .

.targets

.targets, , , SafeImports , Visual Studio Expression Blend , . . , . . (, , , ). , .targets , .

IVsErrorList Visual Studio ( , , Expression Blend ).

, , Log.LogErrror Log.LogWarning , :

public class CheckForErrorsInMyMarkupExtension : Task
{
  ... parameters here ...

  public override Execute()
  {
    ... code to load XAML and scan it for markup extension errors ...
    ... when you discover an error ...
      Log.LogError("I saw an error");
  }
}
+5

API VisualStudio, MEF ( VS2010) VSIntegration .

IVsErrorList, OutputTaskItemString IVsOutputWindowPane. - , django.

, XAML- - , XAML

0

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


All Articles