Webority.Analyzers
0.45.4
See the version list below for details.
dotnet add package Webority.Analyzers --version 0.45.4
NuGet\Install-Package Webority.Analyzers -Version 0.45.4
<PackageReference Include="Webority.Analyzers" Version="0.45.4"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="Webority.Analyzers" Version="0.45.4" />
<PackageReference Include="Webority.Analyzers"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add Webority.Analyzers --version 0.45.4
#r "nuget: Webority.Analyzers, 0.45.4"
#:package Webority.Analyzers@0.45.4
#addin nuget:?package=Webority.Analyzers&version=0.45.4
#tool nuget:?package=Webority.Analyzers&version=0.45.4
Webority.Analyzers
The Webority fleet's banned-API rules at build time: one list of banned types, members and namespaces, each with the rule it breaks, enforced by the banned API analyzer (RS0030) in every project of a repo that references this package, plus a file-precise, shrink-only baseline for hits a repo already has.
Adopt
This package arrives through the Webority.Build SDK, which references it in every project. A repo adds an
msbuild-sdks entry for Webority.Build to global.json, imports Sdk.props as the first line of
Directory.Build.props and Sdk.targets as the last line of Directory.Build.targets, both with
Sdk="Webority.Build". The repository README describes the migration from a direct reference.
Baseline
.webority/baselines/rule-baseline.txt at the repo root (the folder holding .webority/settings.json), one
line per file and symbol:
<repo-relative path>;<symbol ID>;<count>;<baseline|boundary>;<reason>
At most count hits of the symbol in the file are suppressed (WBA0005), the first in source order;
every other hit still fails the build. A method is written without its parameter list and covers every
overload. A line that cannot be read is reported as WBA1001.
The null-forgiving operator has its own baseline line: WBA5003 in place of a symbol ID, with baseline
as its kind only. Its count is exact: it must equal the number of x!, null! and default! uses in that
file. A count above the hits fails the build (WBA5003), and a boundary line with WBA5003 is refused
(WBA1001). WBA5004 takes no baseline line.
Rules
- WBA5003 (error): a null-forgiving operator in hand-written code or a Razor view or component beyond the file's baseline count, or a baseline count above the file's hits.
- WBA5004 (error): a switch-off of a nullable check: a
NoWarn,WarningsNotAsErrorsorTreatWarningsAsErrorssetting that lowers a nullable warning, an editorconfig severity below error for one, a#pragma warning disablethat names one or the nullable group, and aSuppressMessagenaming one. WBA5001 to WBA5004 are nullable rules too. A lowered WBA5004 is reported under WBA5003. - WBA6006 (warning): an aggregate root maps no row version, so two saves of the same record overwrite each other; map
builder.Property<byte[]>("RowVersion").IsRowVersion()on it or[Timestamp]on the root. - WBA6007 (warning): a DbContext maps entities and marks none of them
[AggregateRoot], so WBA6006 checks nothing; put[AggregateRoot]on each entity the API loads and saves as a whole. - WBA9002 (warning): an id is declared as a plain number.
- WBA9003 (warning): a switch over an enum does not name every member, or its catch-all does not throw; name each member in its own case or arm, and make a catch-all arm throw.
- WBA2003 (warning): a money amount is declared as a plain number.
- WBA8009 (warning): a wire type carries an internal id.
- WBA8010 (warning): a product declares its own copy of a library type; delete it and use the package type the message names.
- WBA8011 (warning): an API head keeps a type in a
DataObjectorDTOsfolder; move it toDataObjects/Request,DataObjects/ResponseorDataObjects/Mapper. - WBA8015 (warning): an entity has no constructor EF Core can bind; rename the parameter after its property, or add a private parameterless constructor.
- WBA8016 (warning): a date or time property does not state its kind and zone in its name; rename it with its column and wire field.
- WBA8017 (warning): an endpoint states no access rule; put
[Authorize]on the narrowest covering place, or[AllowAnonymous]on an action that is public on purpose. - WBA8018 (error): a typed attribute of a
Webority.Ui.Razortag helper has a value its enum does not have; the message lists the allowed values. It fires only beside the compiler's CS0117. - WBA8019 (warning): an entity type configuration is never applied, because nothing creates, names or scans it in a project with its own
DbContext; apply it inOnModelCreatingor delete it. - WBA8021 (warning): a tag helper reads HttpContext.Request inside Process or ProcessAsync; move the read into a private method that returns only the value it needs.
- WBA8022 (error):
Failure.Ofornew BusinessRuleValidationExceptionis called withFailureCodes.ValidationFailed, which throws when it runs; build the failure withFailure.Validation(field, message). - WBA4005 (warning): parallel work over a collection has no cap (Task.WhenAll over a Select, or Parallel.ForEachAsync without MaxDegreeOfParallelism).
- WBA6008 (warning): a method saves twice with no transaction open, so a failed second save leaves the first committed; run the saves in one transaction inside the execution strategy.
- WBA6009 (warning): a query includes two collection navigations with no split choice.
- WBA6010 (warning): a database call runs once per loop item; load the set once before the loop instead. Deliberate per-item units of work (own try/catch around a save, tracker clear per pass, outside call then save, keyset pages, chunk-counter saves) stay quiet, and so does a
fororforeachloop marked// per-item commit: <reason>on the line above it. - WBA6011 (warning): a filter, sort or page runs in memory on a list already loaded from the database; move it into the query before the list read.
- WBA6012 (warning): a web project, Functions app or
*.Applicationassembly reads a list with no row limit. - WBA6013 (warning): a read-only request loads tracked entities; add AsNoTracking() or project with Select.
- WBA6014 (warning): a Skip or Take on a query with no OrderBy before it.
- WBA6015 (warning): fires on
ids.Contains(x.Id)with a captured list inside an EF Core query, which EF Core 10 and later send as one SQL parameter per item; wrap the list inEF.Parameter(ids). - WBA6016 (warning): fires on
??over a column inside a queryWhereorOrderBy, which stops the index; store the value in one non-null column and filter on that. - WBA6017 (warning): fires on
GroupBy(...).Select(g => g.OrderBy(...).First())inside a query, which runs a correlated subquery per group; select the rows with no newer sibling instead. - WBA6018 (warning): fires on a query over an entity marked
[AppendOnly](Webority.Domain.AppendOnlyAttribute) with no date filter and no row limit; filter on a date column or addTake(n). - WBA6019 (warning): fires on
CountAsync() > 0,Count() == 0and the like over a query; useAnyAsyncorAny(a code fix does it). - WBA6020 (warning): fires on a second total (Count, Sum, Any and the rest) over the same DbSet and filter in one method; compute both in one grouped query.
- WBA6021 (warning): fires on an entity list read with no
Selectin a method that saves nothing; project the columns the caller uses, or mark// whole rows: <reason>. - WBA6022 (warning): fires on a second read of the same row (same DbSet and filter) with no save between; reuse the first result, or mark
// reload: <reason>. - WBA6023 (warning): fires on EF
AddorAddAsynconce per loop item; build the rows first and callAddRangeonce. - WBA7006 (warning): a concrete controller states no security realm, or two; mark its base with [SecurityRealm], or the controller with [NoSecurityRealm("why")].
- WBA7007 (warning): a public action of an operator controller states no permission; add [HasPermission] or [NoPermissionRequired("why")].
- WBA7008 (warning): a value printed as raw HTML (Html.Raw or new HtmlString) that is not a constant, a sanitised value or serialised JSON.
- WBA7009 (warning): an upload handler with no size ceiling; add [RequestSizeLimit] or [RequestFormLimits] matched to the largest real file.
- WBA7010 (warning): an [Idempotent] endpoint whose request size limit is above what it buffers, or whose MaxBodyBytes is outside 1,024 bytes to 512 MB, which stops the host at start-up; set [Idempotent(MaxBodyBytes = N)] to cover the limit.
- WBA7011 (error): [Idempotent], [RequestSizeLimit], [DisableRequestSizeLimit] or [RequestFormLimits] on a Razor Pages handler method, where Razor Pages never applies it; put it on the PageModel class, or move the handler to a controller.
- WBA8023 (warning): a Razor template that injects a DbContext; load the data in the page model instead.
- WBA1101 (warning): A type switch over our own base type has a discard arm.
- WBA1102 (warning): in-memory data is copied into a MemoryStream.
- WBA1103 (warning): A JSON body is sent as StringContent.
- WBA1104 (warning): A number or date is formatted with the current culture.
- WBA1105 (warning): groups are built only to count them.
- WBA1106 (warning): an inline array also sets a struct size.
- WBA1107 (warning): A JSON element is turned back into text to be read again.
- WBA1108 (warning): A JsonDocument is never disposed.
- WBA1109 (warning): A TimeSpan is built from a fractional literal.
- WBA1110 (warning): A closed hierarchy lists its derived types by hand.
- WBA1111 (warning): A list is sorted to take one end.
- WBA1112 (warning): A blank check trims the string first.
- WBA1113 (warning): metric tags are passed as an array.
- WBA1114 (warning): data is compressed into a MemoryStream to be sent.
- WBA1115 (warning): A string is built inside StringBuilder.Append.
- WBA1116 (warning): A string is copied to a char array only to read it.
- WBA1117 (warning): A JSON response is read as a string first.
- WBA1118 (warning): groups are built only to take their first item.
- WBA1119 (warning): base64url is built by hand.
- WBA1120 (warning): an object goes through JSON text to become another object.
- WBA1121 (warning): an exception is logged as text.
- WBA1122 (warning): JSON is serialised to a string and then to bytes.
- WBA1123 (warning): web JSON options are built by hand.
- WBA1124 (warning): JSON is parsed into a JsonElement through the serialiser.
- WBA1125 (warning): A JSON converter reads only ValueSpan.
- WBA1126 (warning): the escape character is written as a code.
- WBA1127 (warning): A decimal is made from a double literal.
- WBA1128 (warning): A constant string is encoded at run time.
- WBA3007 (warning): an options validator is registered but never attached.
- WBA3008 (warning): an HttpClient is registered with no resilience handler.
- WBA3009 (warning): A service provider is built during registration.
- WBA4006 (warning): A TimeProvider is not passed on.
- WBA4007 (warning): finished tasks are found with WhenAny in a loop.
- WBA4008 (warning): A TaskCompletionSource runs its continuations inline.
- WBA4009 (warning): A duration is measured with the wall clock.
- WBA6024 (warning): A bulk update does not stamp the audit column; mark a deliberate audit-neutral write with
// audit-neutral: <reason>above its statement. - WBA6025 (warning): A SQL Server context does not state its compatibility level.
- WBA7012 (warning): the client address is read from a header by hand.
- WBA7013 (warning): every page is authorised through the root folder.
- WBA7014 (warning): A cookie is readable by page scripts.
- WBA8024 (warning): A request or response body is JSON-handled by hand.
- Fix a switch-off by turning
TreatWarningsAsErrorson and removing the lowering, then fixing the code it hides.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.CodeAnalysis.BannedApiAnalyzers (>= 5.6.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.47.0 | 0 | 11/23/2026 |
| 0.46.0 | 0 | 11/23/2026 |
| 0.45.4 | 39 | 11/22/2026 |
| 0.45.3 | 46 | 11/22/2026 |
| 0.45.2 | 47 | 11/22/2026 |
| 0.45.1 | 53 | 11/22/2026 |
| 0.45.0 | 54 | 11/22/2026 |
| 0.44.0 | 53 | 11/22/2026 |
| 0.43.0 | 48 | 11/22/2026 |
| 0.42.0 | 56 | 11/22/2026 |
| 0.41.5 | 59 | 11/21/2026 |
| 0.41.4 | 51 | 11/21/2026 |
| 0.41.3 | 44 | 11/21/2026 |
| 0.41.2 | 51 | 11/21/2026 |
| 0.41.1 | 54 | 11/21/2026 |
| 0.41.0 | 57 | 11/21/2026 |
| 0.40.0 | 60 | 11/21/2026 |
| 0.39.3 | 78 | 11/19/2026 |
| 0.39.2 | 56 | 11/19/2026 |
| 0.39.1 | 52 | 11/19/2026 |