Skip to content

Commit 5ab3384

Browse files
committed
Support when a property is specified by a string literal instead of a nameof expression
In earlier versions of the Razor generator, a string literal was used instead of a `nameof` expression in order to indicate the name of the property being modified. This means we need to look up the property by name instead of using a more explicit access.
1 parent ca14c57 commit 5ab3384

File tree

1 file changed

+8
-2
lines changed
  • csharp/ql/lib/semmle/code/csharp/frameworks/microsoft/aspnetcore

1 file changed

+8
-2
lines changed

csharp/ql/lib/semmle/code/csharp/frameworks/microsoft/aspnetcore/Components.qll

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,14 @@ private module JumpNodes {
159159
*/
160160
Property getParameterProperty() {
161161
result.getAnAttribute() instanceof MicrosoftAspNetCoreComponentsParameterAttribute and
162-
exists(NameOfExpr ne | ne = this.getArgument(1) |
163-
result.getAnAccess() = ne.getAccess().(MemberAccess)
162+
(
163+
exists(NameOfExpr ne | ne = this.getArgument(1) |
164+
result.getAnAccess() = ne.getAccess().(MemberAccess)
165+
)
166+
or
167+
exists(string propertyName | propertyName = this.getArgument(1).(StringLiteral).getValue() |
168+
result.hasName(propertyName)
169+
)
164170
)
165171
}
166172

0 commit comments

Comments
 (0)