Skip to content

Commit 405c008

Browse files
committed
Fix conversion operator stubbing + reduce skipped ctor noise in stubs
1 parent e4b02e3 commit 405c008

File tree

106 files changed

+464
-1078
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+464
-1078
lines changed

csharp/ql/src/Stubs/Stubs.qll

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -744,11 +744,9 @@ private string stubMember(Member m, Assembly assembly) {
744744
stubParameters(m) + ")" + stubTypeParametersConstraints(m) + stubImplementation(m) + ";\n"
745745
else result = " // Stub generator skipped method: " + m.getName() + "\n"
746746
else
747-
if m instanceof Operator
747+
if m instanceof Operator and not m instanceof ConversionOperator
748748
then
749-
if
750-
not m.getDeclaringType() instanceof Enum and
751-
not m instanceof ConversionOperator
749+
if not m.getDeclaringType() instanceof Enum
752750
then
753751
result =
754752
" " + stubModifiers(m) + stubClassName(m.(Operator).getReturnType()) + " operator " +
@@ -774,17 +772,17 @@ private string stubMember(Member m, Assembly assembly) {
774772
else
775773
if m instanceof Constructor
776774
then
777-
if
778-
not m.getDeclaringType() instanceof Enum and
779-
(
775+
if m.getDeclaringType() instanceof Enum
776+
then result = ""
777+
else
778+
if
780779
not m.getDeclaringType() instanceof StructEx or
781780
m.(Constructor).getNumberOfParameters() > 0
782-
)
783-
then
784-
result =
785-
" " + stubModifiers(m) + m.getName() + "(" + stubParameters(m) + ")" +
786-
stubConstructorInitializer(m) + " => throw null;\n"
787-
else result = " // Stub generator skipped constructor \n"
781+
then
782+
result =
783+
" " + stubModifiers(m) + m.getName() + "(" + stubParameters(m) + ")" +
784+
stubConstructorInitializer(m) + " => throw null;\n"
785+
else result = " // Stub generator skipped constructor \n"
788786
else
789787
if m instanceof Indexer
790788
then

csharp/ql/test/resources/stubs/frameworks/Microsoft.AspNetCore.App/Microsoft.AspNetCore.Components.Web.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,6 @@ public class NavLink : Microsoft.AspNetCore.Components.ComponentBase, System.IDi
268268
public enum NavLinkMatch
269269
{
270270
All,
271-
// Stub generator skipped constructor
272271
Prefix,
273272
}
274273

csharp/ql/test/resources/stubs/frameworks/Microsoft.AspNetCore.App/Microsoft.AspNetCore.Components.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ public struct MarkupString
325325
// Stub generator skipped constructor
326326
public override string ToString() => throw null;
327327
public string Value { get => throw null; }
328-
// Stub generator skipped operator: explicit conversion
328+
public static explicit operator Microsoft.AspNetCore.Components.MarkupString(string value) => throw null;
329329
}
330330

331331
// Generated from `Microsoft.AspNetCore.Components.NavigationException` in `Microsoft.AspNetCore.Components, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
@@ -528,7 +528,6 @@ public enum RenderTreeEditType
528528
PrependFrame,
529529
RemoveAttribute,
530530
RemoveFrame,
531-
// Stub generator skipped constructor
532531
SetAttribute,
533532
StepIn,
534533
StepOut,
@@ -575,7 +574,6 @@ public enum RenderTreeFrameType
575574
Markup,
576575
None,
577576
Region,
578-
// Stub generator skipped constructor
579577
Text,
580578
}
581579

csharp/ql/test/resources/stubs/frameworks/Microsoft.AspNetCore.App/Microsoft.AspNetCore.Connections.Abstractions.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ public class FileHandleEndPoint : System.Net.EndPoint
134134
public enum FileHandleType
135135
{
136136
Auto,
137-
// Stub generator skipped constructor
138137
Pipe,
139138
Tcp,
140139
}
@@ -173,7 +172,6 @@ public enum TransferFormat
173172
{
174173
Binary,
175174
Text,
176-
// Stub generator skipped constructor
177175
}
178176

179177
// Generated from `Microsoft.AspNetCore.Connections.UriEndPoint` in `Microsoft.AspNetCore.Connections.Abstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`

csharp/ql/test/resources/stubs/frameworks/Microsoft.AspNetCore.App/Microsoft.AspNetCore.CookiePolicy.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ public class DeleteCookieContext
6767
public enum HttpOnlyPolicy
6868
{
6969
Always,
70-
// Stub generator skipped constructor
7170
None,
7271
}
7372

csharp/ql/test/resources/stubs/frameworks/Microsoft.AspNetCore.App/Microsoft.AspNetCore.Cryptography.KeyDerivation.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ public enum KeyDerivationPrf
2020
HMACSHA1,
2121
HMACSHA256,
2222
HMACSHA512,
23-
// Stub generator skipped constructor
2423
}
2524

2625
}

csharp/ql/test/resources/stubs/frameworks/Microsoft.AspNetCore.App/Microsoft.AspNetCore.DataProtection.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ public enum EncryptionAlgorithm
118118
AES_192_GCM,
119119
AES_256_CBC,
120120
AES_256_GCM,
121-
// Stub generator skipped constructor
122121
}
123122

124123
// Generated from `Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.IAuthenticatedEncryptor` in `Microsoft.AspNetCore.DataProtection, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
@@ -146,7 +145,6 @@ public enum ValidationAlgorithm
146145
{
147146
HMACSHA256,
148147
HMACSHA512,
149-
// Stub generator skipped constructor
150148
}
151149

152150
namespace ConfigurationModel
@@ -458,7 +456,6 @@ public class CertificateXmlEncryptor : Microsoft.AspNetCore.DataProtection.XmlEn
458456
[System.Flags]
459457
public enum DpapiNGProtectionDescriptorFlags
460458
{
461-
// Stub generator skipped constructor
462459
MachineKey,
463460
NamedDescriptor,
464461
None,

csharp/ql/test/resources/stubs/frameworks/Microsoft.AspNetCore.App/Microsoft.AspNetCore.Http.Abstractions.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ public class CookieBuilder
176176
public enum CookieSecurePolicy
177177
{
178178
Always,
179-
// Stub generator skipped constructor
180179
None,
181180
SameAsRequest,
182181
}
@@ -445,8 +444,8 @@ public struct PathString : System.IEquatable<Microsoft.AspNetCore.Http.PathStrin
445444
public override string ToString() => throw null;
446445
public string ToUriComponent() => throw null;
447446
public string Value { get => throw null; }
448-
// Stub generator skipped operator: implicit conversion
449-
// Stub generator skipped operator: implicit conversion
447+
public static implicit operator string(Microsoft.AspNetCore.Http.PathString path) => throw null;
448+
public static implicit operator Microsoft.AspNetCore.Http.PathString(string s) => throw null;
450449
}
451450

452451
// Generated from `Microsoft.AspNetCore.Http.QueryString` in `Microsoft.AspNetCore.Http.Abstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`

csharp/ql/test/resources/stubs/frameworks/Microsoft.AspNetCore.App/Microsoft.AspNetCore.Http.Connections.Common.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ public class AvailableTransport
2020
[System.Flags]
2121
public enum HttpTransportType
2222
{
23-
// Stub generator skipped constructor
2423
LongPolling,
2524
None,
2625
ServerSentEvents,

csharp/ql/test/resources/stubs/frameworks/Microsoft.AspNetCore.App/Microsoft.AspNetCore.Http.Features.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ public enum SameSiteMode
108108
{
109109
Lax,
110110
None,
111-
// Stub generator skipped constructor
112111
Strict,
113112
Unspecified,
114113
}
@@ -165,7 +164,6 @@ public enum HttpsCompressionMode
165164
Compress,
166165
Default,
167166
DoNotCompress,
168-
// Stub generator skipped constructor
169167
}
170168

171169
// Generated from `Microsoft.AspNetCore.Http.Features.IFeatureCollection` in `Microsoft.AspNetCore.Http.Features, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`

0 commit comments

Comments
 (0)