-
Notifications
You must be signed in to change notification settings - Fork 22
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
Refresh repo build authoring and sync with microsoft/vs-validation #40
Conversation
…lidation. This drops support for the two portable libraries as Visual Studio complained that they weren't valid TFMs.
Also, is there a benefit to supporting .NET Standard 1.0 and 1.3 instead of just supporting .NET Standard 1.0? Likewise, the support for .NET 2.0, 4.0, and 4.5. It seems like supporting .NET 2.0, .NET Standard 1.0, and .NET 5 would cover all of the bases. |
…that was inadvertently dropped.
… Requires in favor of calling PrivateErrorHelpers.Format directly, XML comment updates.
Should the simpler methods, like |
Yes |
Would it just be the simpler methods (which I know is a totally subjective thing!) or all of them? I'll add the attribute and submit another commit to the PR. Hmmm... |
I would put it on any that ms.vs.validation had it on, since we had perf evidence to suggest putting it on those. |
I'll take a look at what's in ms.vs.validation, although from what I remember, there weren't any methods which had it. There are some which have So, change the target frameworks to be:
|
…odImpl and TargetedPatchingOptOut attributes.
Ah, I had |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for porting all these changes. How would you feel about porting the tests too? I certainly don't want to abuse your willingness to help here, so I'll take your PR either way.
I do have a few smaller changes we should fix up before merging though.
I can drop the AggressiveInlining, although it probably doesn't hurt to have them there as well. As for. NET Standard 1.3 support, I don't have a preference either way. Ultimately, it's your choice as the repo owner, but it does make sense to me to drop it. It also makes porting the tests over much easier. I'd actually started to and gave up because too much didn't work without shims or hacks on Net Standard 1.3. Im happy to help out on this. I was about to port everything into my own validation library, as part of rewriting my project to support. NET 5 and nullable reference types, and then decided it was a better use of my effort to pull it into your library and drop it from mine. (There are a few additional methods I think would be helpful to include from mine before I drop it, but I want to do that as a separate PR. This one is a much bigger impact and should stay focused. |
Great. Let's drop netstandard1.3 then. |
Added serialization constructor and serializable attribute to InternalErrorException. Pinned language version to C#8. Fixed the namespace on ExceptionExtensions. Added a missing #define DEBUG on the Report class. Added unit tests.
All of the changes have been checked in. For the unit tests, the
So that's why it's wrapped in an If I remove the |
Should we leave the two obsolete methods in |
…nabled the exception serialization test on .NET Standard 2.1.
…n't work on netcoreapp3.1 yet.
…ression and instead override the behavior of the Fail method on a DefaultTraceListener. This allows the tests to run properly on all platforms.
I think I understand this better now. These really have nothing to do with whether or not the method returns a value, just whether or not it completes. (They're somewhat poorly named in that case, in my opinion.) |
…ur in the consuming code.
We didn't do anything special for it, so `netstandard2.0` is adequate.
Thanks for helping to bring this up to speed. Since this is the first significant change to this repo in quite some time, I took opportunity to apply my Library.Template to it so it works and behaves according to all my other current repos, which adds a bunch of benefits. |
You're welcome! That's a lot of changes for the Library.Template stuff! The file reformatting (mostly making things alphabetical) was just to keep the order consistent, keep overloaded versions of methods together, and whatnot. Some of the actual code changes were made based on SonarLint warnings for correctness, performance, or maintainability (like single iteration for loops). Personally, it feels like it would be more beneficial to back-port those changes into ms.vs.validation rather than the other way around. Just curious, is there a reason you prefer using explicit types rather than As for netstandard2.1, I added it specifically because ms.vs.validation had it. I guess since that's the first TFM which only targets .NET Core and has the broadest API surface area of all of the .NET Standards, it made sense to include it. |
Also, I just synced up my fork, but I'm getting the following error (for both projects) when I try to open the solution:
Am I missing something on my local machine? If I rename |
I've never heard of that. Interesting. Sorry I reverted all those as some of those sound like goodness. Perhaps if we can make the change to vs-validation (first), we can then copy the changes over to this repo.
Yes, I favor
Oh! I wonder why... I don't see any reason for it there either. I think I'll remove it from there too.
netstandard2.0 covers the most runtimes (that are still supported by MS), so if a codebase doesn't require anything beyond that, I prefer to target that. And when the codebase does require |
Check out the CONTRIBUTING.md file that I also added to the repo. It explains about the SDK dependency and how |
I'm ok with that. I can submit a PR, if that's easier. More info on SonarLint is at https://www.sonarlint.org/visualstudio/. There is a VS plugin, as well. It has some really good rules. I'm good either way with LOL. Yea, I thought it was strange that you said you removed netstandard2.0 when it was in ms.vs.validation. :)
I'll take a look at it. I didn't even think about looking there, tbh. |
If sonarlint comes as a nuget package I can install in my repos, I'd probably be sold. But analyzers that ship as VSIX's I'm much less of a fan of, since they'll add noise to repos I can't freely change and they aren't enforced by PR builds when others contribute to the repos I do control. |
Oh! I guess it does come as a nuget package: https://www.nuget.org/packages/SonarAnalyzer.CSharp/ Yay. I'll try it out. |
Hmmm... disappointing results. Every single warning it produces in the Validation project is either a duplicate of an existing CA rule or simply a false positive or otherwise suggests a change I wouldn't want to make. |
Oh. That is disappointing. I hadn't used the nuget package, just the vsix extension. |
Do you suppose the results are different between the nuget package and vsix? |
It sounds like they are. A good example is this: When I load the solution and build, I get these warnings from SonarLint on the
It sounds like you weren't getting those? |
I was getting those. But they were all useless. S1751 was pointing at a foreach loop whose only purpose was to see if at least one element was in the collection, so the code was correct. |
This is saying that the Validation/src/Validation/Requires.cs Lines 29 to 38 in 2378284
Validation/src/Validation/Requires.cs Lines 113 to 121 in 2378284
The only difference here is in the type constraint
Would it not be better, though, to write this a different way and test to see if the enumerator can move forward? Wouldn't that be fewer allocations and branching/conditional testing overall? bool hasElements = false;
foreach (object value in values)
{
hasElements = true;
break;
}
if (!hasElements)
{
throw new ArgumentException(Format(Strings.Argument_EmptyArray, parameterName), parameterName);
} would become using IEnumerator<T> enumerator = values.GetEnumerator();
if (!enumerator.MoveNext())
{
throw new ArgumentException(Format(Strings.Argument_EmptyArray, parameterName), parameterName);
}
Do you want me to fix that in my other PR? |
I see the two as equivalent. You said "fewer allocations" but what allocation are you saving? |
So, I took a look at both versions in JustDecompile and looked at the IL. For the original version, the IL is
For the version using
There are fewer entries in |
It's not the IL. When we talk about JIT inlining you have to look at the native code disassembly, or look at the ETW events emitted by the JIT. But the even more sure way is to use perfview so we can measure the actual application we care about and see if the |
Yes, the Granted, I may also be being a bit pedantic on this, so I'm good either way on this one. |
Ah sorry, I got my threads crossed. Ya, interesting stuff about avoiding the loop. Sounds like a change would be an improvement. |
No worries. I'll make the changes and submit a PR. Should I make them here and in vs-validation as well? |
Sure. Thanks. |
Brings the code more in-line with what's in Microsoft.VisualStudio.Validation. This drops support for the two portable libraries as Visual Studio complained that they weren't valid TFMs. This would resolve #38.