Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom XAML Analysis is not working for Microsoft Visual Studio Professional 2019 Version 16.11.5 #503

Closed
YakupIpek21 opened this issue Feb 8, 2022 · 10 comments
Assignees
Labels
bug Something isn't working NuGet Related to functionality distributed through a NuGet package XAML-Analysis Relates to XAML Analysis functionality
Milestone

Comments

@YakupIpek21
Copy link

Describe the bug

After having generated the projects with the Custom Analyzer Project-Template I follow the instructions as in Step 4. Reference the analyzer in your project, however no warning is displayed.

To Reproduce

  1. Reference the project containing the analyzer in a wpf project with a xaml page or window.

Expected behavior

Warning to be displayed in Visual Studio.

Note
RapidXaml.BuildAnalysis Nuget generates warnings as expected

@YakupIpek21 YakupIpek21 added the bug Something isn't working label Feb 8, 2022
@mrlacey mrlacey self-assigned this Feb 8, 2022
@mrlacey
Copy link
Owner

mrlacey commented Feb 8, 2022

can you share what you've done?

@YakupIpek21
Copy link
Author

YakupIpek21 commented Feb 8, 2022

Thank you for the quick response.

  1. By using the project template (Custom Rapid Xaml Analyzer) I have created the projects
    image

  2. I have updated the auto-generated cs-file as follows:
    public string TargetType() => "AnyOf:TextBlock,TextBox";
    (I havent made any changes to the Analyze-Method, hence when the IsEnabled-Attribute is missing for a TextBlock or TextBox a warning should be displayed)

  3. In the same solution I have created a wpf project and referenced the project containing the custom analyzer (I have also tried by creating a nuget package and referencing it)

  4. I have added a xaml-page with a TextBlock without an IsEnabled-Attribute, however there is no warning displayed

My Visual Studio 2019 version is: Microsoft Visual Studio Professional 2019 Version 16.11.5

@mrlacey mrlacey added NuGet Related to functionality distributed through a NuGet package XAML-Analysis Relates to XAML Analysis functionality labels Feb 8, 2022
@mrlacey mrlacey added this to the ASAP milestone Feb 8, 2022
@mrlacey
Copy link
Owner

mrlacey commented Feb 8, 2022

Two things:

  1. Make sure that custom analysis is enabled in the options:

image

  1. I can recreate the issue when using ANYOF:Textblock,TextBox. However things work as expected if I just specify a single element type; e.g. public string TargetType() => "TextBlock";

I'll continue looking into why the "ANYOF:" version isn't working as expected.

@YakupIpek21
Copy link
Author

Single element type works.

Looking forward to the fixed version.

Thank you very much.

@YakupIpek21
Copy link
Author

YakupIpek21 commented Feb 9, 2022

Regarding the working scenario with the single type, I'd like to know if it also works when the project containing the custom analyzer is added as a nuget package as it seems to fail in my case. I've enabled custom analysis in the options.

Note: it works when the project is added as a project reference

Update: it works now, I am not sure why it took so long to trigger the custom analysis

@mrlacey
Copy link
Owner

mrlacey commented Feb 9, 2022

Regarding the working scenario with the single type, I'd like to know if it also works when the project containing the custom analyzer is added as a nuget package as it seems to fail in my case. I've enabled custom analysis in the options.

Note: it works when the project is added as a project reference

Update: it works now, I am not sure why it took so long to trigger the custom analysis

I've found that Visual Studio's caching of referenced assemblies can sometimes be a bit too aggressive and can lead to this problem.
Unfortunately, while testing new custom analyzers, I often find I need to forcibly delete the contents of the bin and obj directories to get this to work correctly. Sometimes it's even necessary to restart VS. 😞

@mrlacey
Copy link
Owner

mrlacey commented Feb 9, 2022

Single element type works.

Yes, the logic for handling the "ANYOF:" prefix wasn't right.
"ANYCONTAINING" and "AnyOrChildrenContaining:" do work though. Although, I recognize this doesn't help you right now.

mrlacey added a commit that referenced this issue Feb 9, 2022
…ssors

especially any using the "ANYOF:" prefix

for #503
@mrlacey
Copy link
Owner

mrlacey commented Feb 9, 2022

I've just released version 0.13.2 of the Analysis extension to the marketplace and have confirmed that this fixes the issue you were seeing.

I'll now update the BuildAnalysis library too (for #505)

@YakupIpek21
Copy link
Author

Great, thanks a lot 👍

@mrlacey
Copy link
Owner

mrlacey commented Feb 9, 2022

If you have any problems, comments, or suggestions please raise another issue.
If you love it, please leave a rating/review or consider sponsorship 😄

@mrlacey mrlacey closed this as completed Feb 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working NuGet Related to functionality distributed through a NuGet package XAML-Analysis Relates to XAML Analysis functionality
Projects
None yet
Development

No branches or pull requests

2 participants