-
I updated to CSLA 5.2 and today 5.3 and I get many errors from analyzer
But I only see analyzer numbers 1 to 10 in the list, so I cannot disable it. Version and Platform |
Beta Was this translation helpful? Give feedback.
Replies: 19 comments 1 reply
-
Have you closed and reopened VS? |
Beta Was this translation helpful? Give feedback.
-
Yes, I first noticed this when I did a branch where I upgraded from 4.6.x to 5.2. I ended up just deleting the csla analyzers from the References/Analyzers section in all projects. I do have ruleset files in the projects from when I had previously changed some of the CSLA analyzer rules to type none. I wonder if that might have an effect on rules showing up versus when there is no preexisting ruleset file. Shooting in the dark there. |
Beta Was this translation helpful? Give feedback.
-
@JasonBock ??? |
Beta Was this translation helpful? Give feedback.
-
I don't know why CSLA0011 would not show up in the list. I just created a project and referenced the Csla package and this is what I see: |
Beta Was this translation helpful? Give feedback.
-
Side question: Are you automatically disabling all of the CSLA analyzers? I really hope you're not ;) |
Beta Was this translation helpful? Give feedback.
-
@JasonBock - No, previously ~4.6.x I had only selected the couple that did not apply in our scenario, changing them to not block us with errors. But when I could no longer see the new rules throwing errors, the only way around it was to delete all the analyzers entirely which obviously is worrisome. Also, WOW I guess I'm not seeing any of the rules above 10. Hmmm this is weird. |
Beta Was this translation helpful? Give feedback.
-
Which ones were they? I'm curious to know what they are and why they would block you. |
Beta Was this translation helpful? Give feedback.
-
@JasonBock I have to delete the CSLA Nuget reference from one of my business layer projects and then put it back in to get the analyzers back. Consequently I will delete the ruleset file first as well to see if that not being there makes them show up properly. Will comment with results shortly. FYI - upon deleting the CSLA 5.3 Nuget reference from the project I noticed this in the Output window -> Package Manager Attempting to gather dependency information for package 'Csla.5.3.0' with respect to project 'Business Layer\xxxx.Common.BL', targeting '.NETFramework,Version=v4.7.2'
Removed package 'Csla.5.3.0' from 'packages.config' |
Beta Was this translation helpful? Give feedback.
-
The .ps file is automatically generated for an analyzer project....well, that's what happened with analyzer projects when this was created. Not sure if that's even needed anymore. It may be easier in the long run to look at different ways to reference the analyzers from CSLA but I'll defer that to @rockfordlhotka. When you say "ruleset" file are you talking ".ruleset" or ".editorconfig"? The latter is what should be used now for analyzer configuration. |
Beta Was this translation helpful? Give feedback.
-
@JasonBock @rockfordlhotka Success...
So I'm going to assume it was the presence of that pre-existing ruleset file, which as you say Jason is perhaps an older outdated way of handling customizing the analyzer behaviors. I will answer your question in the next separate comment about what error analyzer rules we are disabling and why (at the risk of airing my dirty laundry :-) |
Beta Was this translation helpful? Give feedback.
-
@JasonBock Per your question...we change the following 3 analyzer rules to not throw an error...reasons below each are listed. We change them to none or warning. CSLA0003 - CSLA business objects must have a public constructor with no arguments CSLA0008 - Managed backing fields must be public, static and read-only CSLA0011 - CSLA business objects should not be created outside of a ObjectFactory instance. Does that help answer your question? |
Beta Was this translation helpful? Give feedback.
-
Now that I've removed the old .ruleset file...and then go to change the analyzer rule to warning from error...I see VS adds a new .editorconfig as you indicated. SWEET! One per solution instead of one in each project. I'm washing those old .ruleset files right out of my hair. Thanks guys! I think this was an issue with me needed to stay up with modern methods rather than a bug with CSLA analyzers. Honestly this was the first I heard of that .editorconfig. Ugh so much to know. |
Beta Was this translation helpful? Give feedback.
-
@swegele thanks for the comments about disabling analyzers. Here's my response: CSLA0003 - Public, no argument constructors are necessary for serialization. I understand your point, but this analyzer is trying to prevent issues that may happen in distributed scenarios. Now, one thought that came to mind is that your C# code may not have any constructors, in which case I believe the C# compiler will add a public no-argument constructor in. This may be something that I haven't considered, so I'll put in an issue to track that. (As a side note, the docs on the analyzers may need updates to explain these in more detail.) All of the analyzers I run by @rockfordlhotka before I do any significant work, because I want to make sure they're enforcing rules and conventions that should (or should not) be done in CSLA, and that they're applicable for any developer using CSLA. He can add more clarity around why these analyzers are there. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
@JasonBock @rockfordlhotka I'd welcome a little more feedback and your thoughts. CSLA003 & CSLA011- Each of our business objects have a default (no-parameter) PRIVATE constructor. The only time it is ever called is within that object by itself in it's own encapsulated static factory method. Are you saying this is a problem? Rocky you are talking about serialize/deserializing? CSLA008 - Can you define "properly" a little more. NONE of our managed backing PropertyInfo fields are public and we are working fine for many years. What am I missing? Thanks guys for the guidance...hopefully what you say might help others too. |
Beta Was this translation helpful? Give feedback.
-
CSLA003 & CSLA011 - CSLA008 - most of the modern data binding or UI helper functionality in |
Beta Was this translation helpful? Give feedback.
-
Okie Dokie...gotta go do some housekeeping in my code then :-) |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
@JasonBock Second pass not so quick. I spent 6 hours yesterday (cutting / pasting) through the ~600 places where the ctors were private instead of public. No way I could see to automate that. Then it was on to ~150 Command objects where the private ctors had parameters. Had to add a public default ctor to those. It was almost midnight and I've got that done but my eyes are ready to fall out of their sockets and I look like dracula! Next up...replace, mostly in the child objects, where I did manual creation with ctor setting this.IsNew or this.IsOld etc, and instead now have the DataPortal.Create do the work. I think that is also gonna take a day or two. Question: If I call DataPortal.Create or CreateChild, does there HAVE TO BE a corresponding minimum method (new style) like below?
or
I know the RunLocal is optional. But I'd swear it used to be that if you called a DataPortal.Create that it would work even if you didn't have a default instance of the old style method: |
Beta Was this translation helpful? Give feedback.
@JasonBock @rockfordlhotka Success...
So I'm going to assume it was the presence of that pre-existing ruleset file, which as you say Jason is perhaps an older outdated way of handling customizing the analyzer behaviors.
I will answer your question in the next separate comment about what error analyzer rules we are disabling and why (at the risk of airing my dirty laundry :-)