Class QueryGuardOrigin
- Namespace
- QueryGuard
- Assembly
- QueryGuard.Core.dll
Where a query was executed from: the source file and line, parsed out of a captured stack trace.
public sealed class QueryGuardOrigin
- Inheritance
-
QueryGuardOrigin
- Inherited Members
Remarks
A captured trace is text, which is fine for printing and useless for anything that needs the file and the line as separate values: SARIF wants a URI and an integer, not a sentence. This turns the first application frame into those two values, or reports that it could not.
Frames arrive in the shape the runtime writes them:
at Sample.Api.CompanyEndpoints.List(AppDbContext db) in C:\repo\src\CompanyEndpoints.cs:line 89
A frame without the in … :line N suffix carries no location, which happens whenever the build
has no debug symbols. That is a normal state, not an error: the query still has an origin, there is
just nothing to point at. Callers are expected to omit the location rather than invent one, because a
wrong line number in an annotation is worse than no annotation.
It lives in this assembly rather than next to a consumer because both the test assertion and the reporters need it, and the frame format is a property of what was captured.
Properties
- Callable
Gets the method the query was executed from, without the file or line.
- FilePath
Gets the source file path exactly as the trace recorded it, which is absolute on most builds.
- Line
Gets the one-based line number.
Methods
- ToString()
Returns a string that represents the current object.
- TryParse(string?, out QueryGuardOrigin?)
Parses the first frame that carries a source location.