Skip to content

Commit e524e35

Browse files
committed
C#: Check accessor declaration for publicness
1 parent 0cc74a2 commit e524e35

File tree

5 files changed

+12
-4
lines changed

5 files changed

+12
-4
lines changed

csharp/ql/src/utils/modeleditor/AutomodelVsCode.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ private predicate isUninteresting(DotNet::Declaration c) {
2727
*/
2828
class CallableMethod extends DotNet::Declaration {
2929
CallableMethod() {
30-
this.(Modifiable).isEffectivelyPublic() and
30+
[this.(Modifiable), this.(Accessor).getDeclaration()].isEffectivelyPublic() and
3131
not isUninteresting(this)
3232
}
3333

csharp/ql/test/utils/modeleditor/FetchApplicationModeMethods.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
| PublicClass.cs:19:33:19:50 | call to method ReadLine | System.Console#ReadLine() | true | supported | System.Console | 7.0.0.0 | neutral | type | source | classification |
66
| PublicClass.cs:19:33:19:50 | call to method ReadLine | System.Console#ReadLine() | true | supported | System.Console | 7.0.0.0 | source | type | source | classification |
77
| PublicClass.cs:24:9:24:30 | call to method WriteLine | System.Console#WriteLine(System.String) | true | supported | System.Console | 7.0.0.0 | neutral | type | source | classification |
8-
| PublicInterface.cs:11:9:11:30 | call to method WriteLine | System.Console#WriteLine(System.String) | true | supported | System.Console | 7.0.0.0 | neutral | type | source | classification |
8+
| PublicInterface.cs:13:9:13:30 | call to method WriteLine | System.Console#WriteLine(System.String) | true | supported | System.Console | 7.0.0.0 | neutral | type | source | classification |
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
| PublicClass.cs:7:17:7:21 | stuff | GitHub.CodeQL.PublicClass#stuff(System.String) | false | supported | PublicClass.cs | library | | type | unknown | classification |
22
| PublicClass.cs:12:24:12:34 | staticStuff | GitHub.CodeQL.PublicClass#staticStuff(System.String) | false | supported | PublicClass.cs | library | | type | unknown | classification |
33
| PublicClass.cs:17:20:17:33 | nonPublicStuff | GitHub.CodeQL.PublicClass#nonPublicStuff(System.String) | false | supported | PublicClass.cs | library | | type | unknown | classification |
4+
| PublicClass.cs:27:45:27:47 | get_PublicProperty | GitHub.CodeQL.PublicClass#get_PublicProperty() | false | supported | PublicClass.cs | library | | type | unknown | classification |
5+
| PublicClass.cs:27:50:27:52 | set_PublicProperty | GitHub.CodeQL.PublicClass#set_PublicProperty(System.String) | false | supported | PublicClass.cs | library | | type | unknown | classification |
46
| PublicInterface.cs:7:10:7:14 | stuff | GitHub.CodeQL.PublicInterface#stuff(System.String) | false | supported | PublicInterface.cs | library | | type | unknown | classification |
5-
| PublicInterface.cs:9:17:9:27 | staticStuff | GitHub.CodeQL.PublicInterface#staticStuff(System.String) | false | supported | PublicInterface.cs | library | | type | unknown | classification |
7+
| PublicInterface.cs:9:29:9:31 | get_PublicProperty | GitHub.CodeQL.PublicInterface#get_PublicProperty() | false | supported | PublicInterface.cs | library | | type | unknown | classification |
8+
| PublicInterface.cs:9:34:9:36 | set_PublicProperty | GitHub.CodeQL.PublicInterface#set_PublicProperty(System.String) | false | supported | PublicInterface.cs | library | | type | unknown | classification |
9+
| PublicInterface.cs:11:17:11:27 | staticStuff | GitHub.CodeQL.PublicInterface#staticStuff(System.String) | false | supported | PublicInterface.cs | library | | type | unknown | classification |

csharp/ql/test/utils/modeleditor/PublicClass.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace GitHub.CodeQL;
44

5-
public class PublicClass
5+
public class PublicClass : PublicInterface
66
{
77
public void stuff(String arg)
88
{
@@ -23,4 +23,6 @@ internal void internalStuff(String arg)
2323
{
2424
Console.WriteLine(arg);
2525
}
26+
27+
string PublicInterface.PublicProperty { get; set; }
2628
}

csharp/ql/test/utils/modeleditor/PublicInterface.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ public interface PublicInterface
66
{
77
void stuff(String arg);
88

9+
string PublicProperty { get; set; }
10+
911
static void staticStuff(String arg)
1012
{
1113
Console.WriteLine(arg);

0 commit comments

Comments
 (0)