lombiq / .net-analyzers Goto Github PK
View Code? Open in Web Editor NEW.NET code analyzers and code convention settings for Lombiq projects.
License: BSD 3-Clause "New" or "Revised" License
.NET code analyzers and code convention settings for Lombiq projects.
License: BSD 3-Clause "New" or "Revised" License
There have been quite a few releases of the packages we use, so update all of them to the latest released versions. Fix the new analyzer violations in OSOCE.
This currently only shows false alarms in our code bases. See: dotnet/roslyn#48876
Microsoft.CodeAnalysis.BannedApiAnalyzers
, see docs here, can be used to ban selected classed, methods, properties, or else.
This is our follow-up issue once dotnet/roslyn#55526 is fixed.
In Git repositories, it's common to use LF
(\n
, "Unix-style") line endings for better cross-platform compatibility (see Lombiq/Open-Source-Orchard-Core-Extensions#65). The problem is that with .cs files, if we have LF
line endings instead of CRLF
(\r\n
, "Windows-style") then roslyn will emit several false-positive IDE0055 warnings. There is a workaround of making only the .cs files CRLF
as described in the above-linked issue. We have applied it to this repo and its submodules during OSOE-49.
Once the analyzer is fixed, the *.cs text eol=crlf
rule should be removed from all .gitattributes files and then all .cs files should be renormalized to LF
using the same steps described in the issue description of OSOE-91.
Enable nullable reference types centrally and migrate OSOCE.
<Nullable>
configs and remove them.See e.g. this most recent example: Lombiq/Helpful-Libraries#261. I also started an investigation there.
Configure S103 to use our conventional line length config.
See: https://github.com/Lombiq/.NET-Analyzers#upgrading-to-a-new-version-of-the-net-sdk
<Features>strict</Features>
see this post.AnalysisLevel
.LangVersion
.Note that this also requires all projects using .NET Analyzers to be upgraded as well.
There's a task/net-6-upgrade
branch already (from here: #36); start from that and merge the new PR to dev
.
This has happened a couple of times, but very rarely. Restarting the workflow fixes the problem.
An example is here, however it's not related to that issue (compilation failed in Lombiq.SetupExtensions.csproj which doesn't use nodejs) and I've seen it appear in other branches too, it's just the latest one at the time of writing. I've checked the attached binlog but didn't see anything significant in it.
Check out Meziantou.Analyzer and see if it's something we should use. See the duplicate rules with NetAnalyzers here.
This needs to be tested on multiple bigger solutions.
...in Build.props. This shouldn't be needed (since it make the app be built with the compiler in the package, not in the SDK) but is necessary to work around dotnet/sdk#23972.
This is only suitable once .editorconfig has everything ruleset files provide already:
<EditorConfigFiles>
could help us, see this blog post. An alternative would be dotnet/roslyn#19028 (comment)..globalconfig
, but that's only for analyzer configs, not edit configuration like charset or guidelines. See dotnet/roslyn#47707.Tasks:
<developmentDependency>true</developmentDependency>
in the nuspec template. The analyzer packages we use do this. Check the generated <PackageReference>
after a new install and change the docs, including release notes, and consuming projects if necessary.Been using Lombiq.Analyzers as a submodule for a while but recently every analysis error is being thrown including ones disabled in the rules file like as if they don't exist.
If I disable below it makes no difference.
<Project>
<ItemGroup>
<Analyzer Remove="@(Analyzer)" />
</ItemGroup>
</Project>
Or via the command line using /p:RunCodeAnalysis=false
- no difference.
It still is fine in our build pipeline however if I bring down the source code into a new computer - same issue.
Typical error example are:
error CA1707: Remove the underscores from member name Kast.ConnectCard.Constants.FeatureIds.Kast_ConnectCard_OnUs
I copied Lombiq's open source project and copied the configuration from there but this made no difference.
Let's develop custom analyzers. This is not that easy, and we'd need to publish them on NuGet since analyzers can't be used directly from the source.
Some ideas:
[Admin]
) or with an explicit IAuthorizationService
call.ISession
queries. While not always, usually there should be some kind of filtering instead of a full table retrieval.IContentManager.GetAsync(string id)
calls in a loop and suggest IContentManager.GetAsync(IEnumerable<string> contentItemIds, bool latest = false)
instead.IClock
instead of DateTime.UtcNow
.IStringLocalizer<MyClass>
or IHtmlLocalizer<MyClass>
. The type parameter mustn't be omitted or have a different type than the current type. This would actually be generally interesting for ASP.NET Core MVC apps. Came up here too: OrchardCMS/OrchardCore#10987Sdk
attribute being Microsoft.NET.Sdk.Razor
in the csproj's <Project>
element if Razor templates are being used._prefixedWithUnderscoreCamelCased
except for T
and H
. We can modify SX1309 for this. The alternative would be to put all localizers into properties instead and enable SX1309.The instructions cover adding this to your solution using a submodule method but do not cover how to utilise this from the NuGet package.
Could we have some clarification on this.
Currently, the rules in .editorconfig are not checked during build, only in the IDE. Running these during build will be available in the .NET 5 SDK (even if the app doesn't target .NET 5). We should then enable this.
See here. This is basically approval testing for public APIs.
Only useful for projects with an important published interface, like Helpful Libraries, especially libraries. So maybe we shouldn't add the analyzer package, just some common config and then you may add the analyzer to your own project only. However, the only available configuration is a single line.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.