Implementing color swatch support for XAML in VS Code runs into some limitations. VS Code does not seem to support streaming progress for the documentColor request.
Colors in XAML documents are based on syntax (i.e. #AARRGGBB) as well as semantic information (e.g. {StaticResource MyColor}).
The second issue is quite a big problem for us since there is no refresh support in the LSP spec for when color information needs to be refreshed (for when the semantic information becomes available or when the MyColor value in a different document gets updated for example).
Similar to recently added refresh support for folding ranges in the proposed 3.18 spec we would like to add refresh support for document colors. The support needs to take into consideration following scenarios:
VS Code startup scenario. Refreshing active XAML document after LSP server gets fully initialized and XAML file is associated with a project (as opposite to being a loose XAML file). For example, if MainPage.xaml is active document when starting VS Code then it takes few seconds for LSP to recognize that it is part of MyApp.csproj and initialize Microsoft.CodeAnalysis.Compilation. In this case we need to refresh active document.
Editing ResourceDictionaries. Editing color values in App.xaml or Colors.xaml - (e.g. <Color x:Key='MyColor'>#123455</Color>) will affect color swatches in MainPage.xaml (e.g. <Button BackgroundColor='{StaticResource MyColor}'/>). In this case we need to refresh all but current document. More specifically, we want to avoid refreshing current document because it already gets refreshed as user types
Implementing color swatch support for XAML in VS Code runs into some limitations. VS Code does not seem to support streaming progress for the documentColor request.
#AARRGGBB
) as well as semantic information (e.g.{StaticResource MyColor}
).Similar to recently added refresh support for folding ranges in the proposed 3.18 spec we would like to add refresh support for document colors. The support needs to take into consideration following scenarios:
Microsoft.CodeAnalysis.Compilation
. In this case we need to refresh active document.<Color x:Key='MyColor'>#123455</Color>
) will affect color swatches in MainPage.xaml (e.g.<Button BackgroundColor='{StaticResource MyColor}'/>
). In this case we need to refresh all but current document. More specifically, we want to avoid refreshing current document because it already gets refreshed as user types