-
Notifications
You must be signed in to change notification settings - Fork 36
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
Add ReSharper settings for coding guidelines. #115
Conversation
Thanks for this @luboshl. The only one I'm hesitant to adopt would be no. 4. Would it be possible to adjust this rule to allow for explicit variable types when the type is not apparent? I believe in R# this is called "use var when evident" and appears to be the current default. |
I updated our C# Coding Guidelines to reflect the usage of |
Just FYI: https://github.com/DotNetAnalyzers/StyleCopAnalyzers is a very promising project for those who want to enforce code style rules without forcing all developers to have R#. VS2015 users will see warnings/errors straight in the IDE whilst all others may just run a command-line script prior to commit/push. The same CLI command can eventually be activated on a CI server (once TI gets one). |
Good find. There is an R# extension for StyleCop. So maybe we can define the rules in StyleCop and then use them from R# via the extension? |
Not sure how well JetBrains integrates with Roslyn... At least that's what I found on their web page |
That’s funny .. But does it relate to StyleCop? If not, that’s OK — jokes are allowed. :-) |
Here we shouldn't confuse classical StyleCop and its complete remake StyleCopAnalyzers entirely based on Roslyn. The R# plugin you referred is probably only about StyleCop, which I honestly never used. The obvious advantage of StyleCopAnalyzers is that one doesn't have to install anything, because it's just a standard NuGet package for VS2015. One possible disadvantage might be that we probably can't share the config with R# because of JetBrains' attitude to Roslyn. |
I see now .. yes, this is much better than the R# settings. Let’s use it. |
Love your optimism, Tony! 😄 Well, it's a bit easier to say than to actually implement it (from the purely organizational viewpoint). If we want to enforce coding rules, then we certainly should immediately make our existing code compliant, which may result in a massive commit affecting lots of codelines. Therefore we must at least wait until all pending PRs are merged. Another unclear point is VS2013 (and below) support. I would expect SCA doesn't do anything there (at least no harm), but a few tests definitely won't hurt. Thus I would cautiously rephrase your
as let's consider this alternative. 😇 |
Oh yes, better to not break existing code. Maybe something to consider for the new TE Express project for targeting EF7 (now called CORE 1.0) I'm wondering if there is even a need for an R# settings file, since it seems like the rules mentioned above are already the defaults? |
Question to @luboshl as I'm still not using R#... 😊 |
Yes, it is. Because if I have local settings conflicting these rules and there are no solution settings, my settings apply. For example name style for local fields. Default is "_camleCalse". I have "camelCase" in my local settings (This computer in Seetings Layers), so it overrides the default. If there is no rule for solution, my rules apply. If there are rules for the solution, they override rules in This computer layer. So rules for the solution should be set, although they are the same as default. |
Thanks Lubos, I get it now. :) So is there any problem for non-R# users to have these R# settings? |
@tonysneed, do you realy want to prefer this?
What if you change return value of Personally I like |
No, non-R# users just ingore the setting file. Only R# uses it. |
R# settings is just help for users with R#. It's not a constraint for them nor for non-R# users. |
Can you change the rule for |
Yes, I can. But:
var context = TestsHelper.CreateNorthwindDbContext(CreateNorthwindDbOptions);
foreach (var item in items) // used in ApplyChanges
var trackingState = item.TrackingState; // used in ApplyChanges whe shoul use NorthwindDbContext context = TestsHelper.CreateNorthwindDbContext(CreateNorthwindDbOptions);
foreach (ITrackable item in items) // used in ApplyChanges
TrackingState trackingState = item.TrackingState; // used in ApplyChanges I think that's not what you mean, is it? |
Here are the default settings which I think you can incorporate this PR: <wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeStyle/CSharpVarKeywordUsage/ForBuiltInTypes/@EntryValue">UseVarWhenEvident</s:String>
<s:String x:Key="/Default/CodeStyle/CSharpVarKeywordUsage/ForOtherTypes/@EntryValue">UseVarWhenEvident</s:String>
<s:String x:Key="/Default/CodeStyle/CSharpVarKeywordUsage/ForSimpleTypes/@EntryValue">UseVarWhenEvident</s:String></wpf:ResourceDictionary> |
I believe these mean that, when the type is not evident, allow |
Looks good to me.
|
Ok, done. |
I tested it and it's looking good! |
👍 |
Added team-shared solution level settings for ReSharper. These settings meet some of coding guidelines that are adjustable in R#. Inspection severity for these rules is set to Warning.
(@tonysneed - I cannot found your coding guidelines referencing Coding Guidelines for ASP.NET int GitHub. Where is the reference?)
These coding guidelines was applied: