Open Piedone opened 3 years ago
@Piedone is there any analyzers developed yet? If not is there a repo or project that I can start prototype the localizer analyzer
Not yet, we'd start in this project, so please fork it.
Sure
mark
Here's a proposition for a valuable analyzer:
Verify that an exception defined in a catch
clause is used at the correct position in _logger.LogError()
:
_logger.LogError("message", ex)
should trigger a violationex
to the beginning: _logger.LogError(ex, "message")
.Tutorial on writing an analyzer: https://www.meziantou.net/roslyn-analyzers-how-to.htm.
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 explicitIAuthorizationService
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 suggestIContentManager.GetAsync(IEnumerable<string> contentItemIds, bool latest = false)
instead.IClock
instead ofDateTime.UtcNow
.IStringLocalizer<MyClass>
orIHtmlLocalizer<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: https://github.com/OrchardCMS/OrchardCore/pull/10987Sdk
attribute beingMicrosoft.NET.Sdk.Razor
in the csproj's<Project>
element if Razor templates are being used._prefixedWithUnderscoreCamelCased
except forT
andH
. We can modify SX1309 for this. The alternative would be to put all localizers into properties instead and enable SX1309.Jira issue