Skip to content

Commit 0c0e1d0

Browse files
authored
Merge pull request #19456 from 5idg5/5idg5-update-cs-stubs
Add new stubs definitions to System.Web
2 parents d3282a9 + eb4711e commit 0c0e1d0

File tree

11 files changed

+74
-17
lines changed

11 files changed

+74
-17
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
semmle-extractor-options: /nostdlib /noconfig
22
semmle-extractor-options: --load-sources-from-project:${testdir}/../../resources/stubs/_frameworks/Microsoft.NETCore.App/Microsoft.NETCore.App.csproj
3-
semmle-extractor-options: ${testdir}/../../resources/stubs/System.Web.cs
3+
semmle-extractor-options: ${testdir}/../../resources/stubs/System.Web.cs
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
semmle-extractor-options: /nostdlib /noconfig
2-
semmle-extractor-options: --load-sources-from-project:${testdir}/../../../../resources/stubs/_frameworks/Microsoft.NETCore.App/Microsoft.NETCore.App.csproj
2+
semmle-extractor-options: --load-sources-from-project:${testdir}/../../../../resources/stubs/_frameworks/Microsoft.AspNetCore.App/Microsoft.AspNetCore.App.csproj
33
semmle-extractor-options: ${testdir}/../../../../resources/stubs/System.Web.cs
4+
semmle-extractor-options: ${testdir}/../../../../resources/stubs/System.Web.Http.cs
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
semmle-extractor-options: /nostdlib /noconfig
2-
semmle-extractor-options: --load-sources-from-project:${testdir}/../../../resources/stubs/Newtonsoft.Json/13.0.3/Newtonsoft.Json.csproj
3-
semmle-extractor-options: ${testdir}/../../../resources/stubs/System.Web.cs
2+
semmle-extractor-options: --load-sources-from-project:${testdir}/../../../resources/stubs/_frameworks/Microsoft.NETCore.App/Microsoft.NETCore.App.csproj
3+
semmle-extractor-options: ${testdir}/../../../resources/stubs/System.Web.cs
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
semmle-extractor-options: /nostdlib /noconfig
2-
semmle-extractor-options: --load-sources-from-project:${testdir}/../../../resources/stubs/_frameworks/Microsoft.NETCore.App/Microsoft.NETCore.App.csproj
32
semmle-extractor-options: --load-sources-from-project:../../../resources/stubs/_frameworks/Microsoft.AspNetCore.App/Microsoft.AspNetCore.App.csproj
43
semmle-extractor-options: ${testdir}/../../../resources/stubs/System.Web.cs
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
semmle-extractor-options: /nostdlib /noconfig
22
semmle-extractor-options: --load-sources-from-project:${testdir}/../../../../../resources/stubs/_frameworks/Microsoft.NETCore.App/Microsoft.NETCore.App.csproj
3-
semmle-extractor-options: ${testdir}/../../../../../resources/stubs/System.Web.cs
3+
semmle-extractor-options: ${testdir}/../../../../../resources/stubs/System.Web.cs
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
semmle-extractor-options: /nostdlib /noconfig
2-
semmle-extractor-options: --load-sources-from-project:${testdir}/../../../../resources/stubs/_frameworks/Microsoft.NETCore.App/Microsoft.NETCore.App.csproj
32
semmle-extractor-options: --load-sources-from-project:${testdir}/../../../../resources/stubs/_frameworks/Microsoft.AspNetCore.App/Microsoft.AspNetCore.App.csproj
43
semmle-extractor-options: ${testdir}/../../../../resources/stubs/System.Web.cs
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
semmle-extractor-options: ${testdir}/../../../resources/stubs/System.Web.cs /r:System.Collections.Specialized.dll /r:System.Xml.ReaderWriter.dll /r:System.Private.Xml.dll /r:System.Runtime.Extensions.dll
1+
semmle-extractor-options: ${testdir}/../../../resources/stubs/System.Web.cs
2+
semmle-extractor-options: /r:System.Collections.Specialized.dll /r:System.Xml.ReaderWriter.dll /r:System.Private.Xml.dll /r:System.Runtime.Extensions.dll
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
semmle-extractor-options: /nostdlib /noconfig
22
semmle-extractor-options: --load-sources-from-project:${testdir}/../../../../resources/stubs/_frameworks/Microsoft.NETCore.App/Microsoft.NETCore.App.csproj
3-
semmle-extractor-options: ${testdir}/../../../../resources/stubs/System.Web.cs
3+
semmle-extractor-options: ${testdir}/../../../../resources/stubs/System.Web.cs

csharp/ql/test/resources/stubs/System.Net.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public class StringContent
4949
{
5050
public StringContent(string s) { }
5151
}
52+
5253
}
5354

5455
namespace System.Net.Mail
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace System.Web.Http
2+
{
3+
public class ApiController
4+
{
5+
public Microsoft.AspNetCore.Http.HttpContext Context => null;
6+
public virtual Microsoft.AspNetCore.Mvc.RedirectResult Redirect(Uri location) => null;
7+
public virtual Microsoft.AspNetCore.Mvc.RedirectResult Redirect(string location) => null;
8+
public virtual ResponseMessageResult ResponseMessage(System.Net.Http.HttpResponseMessage response) => null;
9+
public virtual Microsoft.AspNetCore.Mvc.RedirectToRouteResult RedirectToRoute(string routeName, object routeValues) => null;
10+
public Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; set; }
11+
}
12+
13+
public class ResponseMessageResult { }
14+
}

csharp/ql/test/resources/stubs/System.Web.cs

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ public class HttpRequestBase
1919
public class HttpResponseBase
2020
{
2121
public void Write(object obj) { }
22+
public virtual void AppendHeader(string name, string value) { }
23+
public virtual void Redirect(string url) { }
24+
public virtual void RedirectPermanent(string url) { }
25+
public virtual int StatusCode { get; set; }
26+
public virtual void AddHeader(string name, string value) { }
27+
public virtual void End() { }
28+
public virtual string RedirectLocation { get; set; }
29+
public virtual NameValueCollection Headers => null;
30+
2231
}
2332

2433
public class HttpContextBase
@@ -51,26 +60,40 @@ public class HttpApplication : IHttpHandler
5160
}
5261
}
5362

54-
namespace System.Web.Http
55-
{
56-
public class ApiController
57-
{
58-
}
59-
}
60-
6163
namespace System.Web.Mvc
6264
{
6365
public class Controller
6466
{
6567
public ViewResult View() => null;
68+
public HttpRequestBase Request => null;
69+
public HttpResponseBase Response => null;
70+
protected internal virtual RedirectResult RedirectPermanent(string url) => null;
71+
protected internal RedirectToRouteResult RedirectToRoute(string routeName) => null;
72+
public UrlHelper Url { get; set; }
73+
protected internal virtual RedirectResult Redirect(string url) => null;
6674
}
6775

6876
public class MvcHtmlString : HtmlString
6977
{
7078
public MvcHtmlString(string s) : base(s) { }
7179
}
80+
81+
public class RoutePrefixAttribute : Attribute
82+
{
83+
public virtual string Prefix { get; private set; }
84+
public RoutePrefixAttribute(string prefix) { }
85+
}
86+
87+
public sealed class RouteAttribute : Attribute
88+
{
89+
90+
public RouteAttribute(string template) { }
91+
}
92+
93+
public class RedirectToRouteResult : ActionResult { }
7294
}
7395

96+
7497
namespace System.Web.UI
7598
{
7699
public class Control
@@ -81,6 +104,7 @@ public class Page
81104
{
82105
public System.Security.Principal.IPrincipal User { get; }
83106
public System.Web.HttpRequest Request { get; }
107+
public HttpResponse Response => null;
84108
}
85109

86110
interface IPostBackDataHandler
@@ -153,6 +177,7 @@ public class HttpRequest
153177
public UnvalidatedRequestValues Unvalidated { get; }
154178
public string RawUrl { get; set; }
155179
public HttpCookieCollection Cookies => null;
180+
public bool IsAuthenticated { get; set; }
156181
}
157182

158183
public class HttpRequestWrapper : System.Web.HttpRequestBase
@@ -169,6 +194,13 @@ public void WriteFile(string s) { }
169194
public void AddHeader(string name, string value) { }
170195
public void Redirect(string url) { }
171196
public void AppendHeader(string name, string value) { }
197+
public void End() { }
198+
public string RedirectLocation { get; set; }
199+
public int StatusCode { get; set; }
200+
public void RedirectPermanent(string url) { }
201+
public virtual NameValueCollection Headers { get; set; }
202+
203+
172204
}
173205

174206
public class HttpContext : IServiceProvider
@@ -177,6 +209,7 @@ public class HttpContext : IServiceProvider
177209
public HttpResponse Response => null;
178210
public SessionState.HttpSessionState Session => null;
179211
public HttpServerUtility Server => null;
212+
public static HttpContext Current => null;
180213
}
181214

182215
public class HttpCookie
@@ -301,6 +334,15 @@ public class UrlHelper
301334
public UrlHelper(Routing.RequestContext requestContext) { }
302335
public virtual bool IsLocalUrl(string url) => false;
303336
}
337+
338+
public class RedirectResult : ActionResult
339+
{
340+
public bool Permanent { get; set; }
341+
public string Url => null;
342+
343+
public RedirectResult(string url) : this(url, permanent: false) { }
344+
public RedirectResult(string url, bool permanent) { }
345+
}
304346
}
305347

306348
namespace System.Web.Routing
@@ -390,7 +432,7 @@ public class JavaScriptSerializer
390432
public JavaScriptSerializer() => throw null;
391433
public JavaScriptSerializer(System.Web.Script.Serialization.JavaScriptTypeResolver resolver) => throw null;
392434
public object DeserializeObject(string input) => throw null;
393-
public T Deserialize<T> (string input) => throw null;
435+
public T Deserialize<T>(string input) => throw null;
394436
public object Deserialize(string input, Type targetType) => throw null;
395437
}
396438

0 commit comments

Comments
 (0)