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

Automatic triggering of custom analyzer #505

Open
YakupIpek21 opened this issue Feb 9, 2022 · 8 comments
Open

Automatic triggering of custom analyzer #505

YakupIpek21 opened this issue Feb 9, 2022 · 8 comments
Assignees
Labels
question Further information is requested
Milestone

Comments

@YakupIpek21
Copy link

Question
Is there a way to automatically trigger the custom analyzer when a project containing a xaml is built?
Not only when the file is saved.

Desired Behaviour
So any project referencing a custom analyzer should automatically analyze its existing Xaml files.

@YakupIpek21 YakupIpek21 added the question Further information is requested label Feb 9, 2022
@mrlacey
Copy link
Owner

mrlacey commented Feb 9, 2022

Yes, add this NuGet package to the project.

It adds a build step that runs the analysis.
The intention is to allow you to have XAML analysis of a project even if the extension is not installed. (Such as on a build server 😉)

Note that the currently available version also suffers from the issue identified in #503 and so a new version of the RapidXaml.BuildAnalysis package is also needed.

@YakupIpek21
Copy link
Author

I see, thank you very much for the explanation

@mrlacey
Copy link
Owner

mrlacey commented Feb 9, 2022

Version 0.13.0 of this NuGet package is now available and fixes the issue noted in #503
Example:
image

PLEASE NOTE. This currently only works with projects that use the old internal structure. It does not yet work with SDK-style projects (As you'll get if you create a project targeting .NET5 or 6.
The changes to support SDK style projects is being tracked separately in #408

@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
@YakupIpek21
Copy link
Author

After having added the RapidXaml.BuildAnalysis nuget package to the project which contains the xaml files, it does not produce any warnings when the project is built in VisualStudio 19

Expected Behaviour
When building a project which contains xaml files, the analysis should be triggered and warnings should be displayed

To reproduce

  1. Generate a custom analyzer
    image

  2. Add the project as a reference to the project containing xaml files (let's denote it as project A)

  3. Add the RapidXaml.BuildAnalysis nuget package (Version 0.13.0) to the project A

  4. In project A add a TextBlock Tag without the IsEnabled Attribute, save the file

  5. Enable in the options the Enable Custom Analysis menu

  6. When a warning is shown then restart VS19, so that no warning is shown, now build project A

  7. In my case no warning is shown in VS19

@mrlacey
Copy link
Owner

mrlacey commented Feb 11, 2022

After having added the RapidXaml.BuildAnalysis nuget package to the project which contains the xaml files, it does not produce any warnings when the project is built in VisualStudio 19

What type of project are you using?
Can you share a complete reproduction project, not just a partial description.

Also, please note, from above:

PLEASE NOTE. This currently only works with projects that use the old internal structure. It does not yet work with SDK-style projects (As you'll get if you create a project targeting .NET5 or 6.)
The changes to support SDK style projects is being tracked separately in #408

@mrlacey mrlacey reopened this Feb 11, 2022
@YakupIpek21
Copy link
Author

YakupIpek21 commented Feb 11, 2022

Yes sure. The following reproduction steps refer to Visual Studio 2019 Version 16.11.5

  1. Via the Custom Rapid XAML Analyzer project template I am creating a custom analyzer with the following content
    image
  2. In the same solution I am creating a WPF-App with the target framework .Net Core 3.1
  3. The analyzer from step 1 is added as a reference to the WPF-app
  4. The RapidXaml.BuildAnalysis nuget package (Version 0.13.0) is added via the nuget manager to the WPF-app
  5. The menu entry Enable Custom Analysis is enabled
  6. In the WPF-app MainWindow.xaml file I added a TextBlock tag within the Grid tag and saved the xaml file
  7. I restart VS19, since in step 6 the analyzer is triggered through the saving
  8. I close all tabs in VS19 and build the WPF-app
  9. When I check for the warnings nothing is displayed
  10. When I open the MainWindow.xaml the warning is shown (not always)

Expected Behaviour
When building the project in Visual Studio 2019 the warnings should be displayed in the Error List Window without needing to open or saving the xaml file in Visual Studio 2019.

@mrlacey
Copy link
Owner

mrlacey commented Feb 11, 2022

Unfortunately, WPF with .Net Core 3.1 also uses an SDK style project format and so the BuildAnalysis doesn't know which files to check. This is why it is not reporting anything.

I'll look to prioritize supporting this. (Very few people have been using RXT with WPF projects and so this is a good opportunity to improve this experience.)

@mrlacey mrlacey added this to the 1.0 milestone Nov 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants