Fix missing APIs in source-build builds and enabled public api analyzer to catch regressions#66588
Open
BrennanConroy wants to merge 1 commit intomainfrom
Open
Fix missing APIs in source-build builds and enabled public api analyzer to catch regressions#66588BrennanConroy wants to merge 1 commit intomainfrom
BrennanConroy wants to merge 1 commit intomainfrom
Conversation
…er to catch regressions
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds source-build stub implementations for IIS/HttpSys so their public APIs remain present in source-only builds, and enables the public API analyzer during source-build to catch future API-surface regressions.
Changes:
- Added source-build stub types for
Microsoft.AspNetCore.Server.IISandMicrosoft.AspNetCore.Server.HttpSys. - Updated IIS/HttpSys project files to compile only the stub file when
DotNetBuildSourceOnly=true. - Moved
Microsoft.CodeAnalysis.PublicApiAnalyzersinto the source-build dependency set and enabled it during source-only builds.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
src/Servers/IIS/IIS/src/SourceBuildStubs.cs |
Adds IIS public API stubs for source-build outputs. |
src/Servers/HttpSys/src/SourceBuildStubs.cs |
Adds HttpSys public API stubs for source-build outputs. |
src/Servers/HttpSys/src/Microsoft.AspNetCore.Server.HttpSys.csproj |
Switches source-only builds to compile the HttpSys stub file instead of real sources. |
eng/targets/CSharp.Common.targets |
Enables PublicApiAnalyzers even in source-only builds. |
eng/Dependencies.props |
Moves Microsoft.CodeAnalysis.PublicApiAnalyzers into the source-build dependency list. |
Comment on lines
+804
to
+820
| [SupportedOSPlatform("windows")] | ||
| public static IWebHostBuilder UseHttpSys(this IWebHostBuilder hostBuilder) => hostBuilder; | ||
|
|
||
| /// <summary> | ||
| /// Specify Http.sys as the server to be used by the web host. | ||
| /// </summary> | ||
| /// <param name="hostBuilder"> | ||
| /// The Microsoft.AspNetCore.Hosting.IWebHostBuilder to configure. | ||
| /// </param> | ||
| /// <param name="options"> | ||
| /// A callback to configure Http.sys options. | ||
| /// </param> | ||
| /// <returns> | ||
| /// A reference to the <see cref="IWebHostBuilder" /> parameter object. | ||
| /// </returns> | ||
| [SupportedOSPlatform("windows")] | ||
| public static IWebHostBuilder UseHttpSys(this IWebHostBuilder hostBuilder, Action<HttpSysOptions> options) => hostBuilder; |
Comment on lines
+687
to
+772
| public string? RequestQueueName { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// This indicates whether the server is responsible for creating and configuring the request queue, | ||
| /// or if it should attach to an existing queue. | ||
| /// The default is <c>RequestQueueMode.Create</c>. | ||
| /// </summary> | ||
| public RequestQueueMode RequestQueueMode { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Indicates how client certificates should be populated. The default is to allow a certificate without renegotiation. | ||
| /// </summary> | ||
| public ClientCertificateMethod ClientCertificateMethod { get; set; } = ClientCertificateMethod.AllowCertificate; | ||
|
|
||
| /// <summary> | ||
| /// The maximum number of concurrent accepts. | ||
| /// </summary> | ||
| public int MaxAccepts { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Attempt kernel-mode caching for responses with eligible headers. | ||
| /// The default is <c>true</c>. | ||
| /// </summary> | ||
| public bool EnableResponseCaching { get; set; } = true; | ||
|
|
||
| /// <summary> | ||
| /// The url prefixes to register with Http.Sys. | ||
| /// </summary> | ||
| public UrlPrefixCollection UrlPrefixes { get; } = new UrlPrefixCollection(); | ||
|
|
||
| /// <summary> | ||
| /// Http.Sys authentication settings. | ||
| /// </summary> | ||
| public AuthenticationManager Authentication { get; } = new AuthenticationManager(); | ||
|
|
||
| /// <summary> | ||
| /// Exposes the Http.Sys timeout configurations. | ||
| /// </summary> | ||
| public TimeoutManager Timeouts { get; } = new TimeoutManager(); | ||
|
|
||
| /// <summary> | ||
| /// Gets or Sets if response body writes that fail due to client disconnects should throw exceptions or | ||
| /// complete normally. The default is <c>false</c>. | ||
| /// </summary> | ||
| public bool ThrowWriteExceptions { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Enable buffering of response data in the Kernel. The default value is <c>false</c>. | ||
| /// </summary> | ||
| public bool EnableKernelResponseBuffering { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the maximum number of concurrent connections to accept. Set <c>-1</c> for infinite. | ||
| /// Set to <c>null</c> to use the registry's machine-wide setting. | ||
| /// The default value is <c>null</c>. | ||
| /// </summary> | ||
| public long? MaxConnections { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the maximum number of requests that will be queued up in Http.Sys. | ||
| /// The default is 1000. | ||
| /// </summary> | ||
| public long RequestQueueLimit { get; set; } = 1000; | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the security descriptor for the request queue. | ||
| /// </summary> | ||
| public GenericSecurityDescriptor? RequestQueueSecurityDescriptor { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the maximum allowed size of any request body in bytes. | ||
| /// When set to null, the maximum request body size is unlimited. | ||
| /// The default is set to 30,000,000 bytes, which is approximately 28.6MB. | ||
| /// </summary> | ||
| public long? MaxRequestBodySize { get; set; } = 30000000; | ||
|
|
||
| /// <summary> | ||
| /// Control whether synchronous input/output is allowed for the HttpContext.Request.Body and HttpContext.Response.Body. | ||
| /// The default is <c>false</c>. | ||
| /// </summary> | ||
| public bool AllowSynchronousIO { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets a value that controls how http.sys reacts when rejecting requests due to throttling conditions. | ||
| /// </summary> | ||
| public Http503VerbosityLevel Http503Verbosity { get; set; } |
Comment on lines
+59
to
+63
| /// <summary> | ||
| /// Gets or sets the maximum allowed size of any request body in bytes. | ||
| /// When set to null, the maximum request length will not be restricted in ASP.NET Core. | ||
| /// </summary> | ||
| public long? MaxRequestBodySize { get; set; } = 30000000; |
| /// May return null or empty if the variable does not exist or is not set. | ||
| /// </returns> | ||
| [Obsolete("This is obsolete and will be removed in a future version. Use HttpContextServerVariableExtensions.GetServerVariable instead.")] | ||
| public static string? GetIISServerVariable(this HttpContext context, string variableName) => null; |
Comment on lines
+619
to
+666
| /// <inheritdoc /> | ||
| public int Count => 0; | ||
|
|
||
| /// <summary> | ||
| /// Gets a value that determines if this collection is readOnly. | ||
| /// </summary> | ||
| public bool IsReadOnly => false; | ||
|
|
||
| /// <summary> | ||
| /// Creates a <see cref="UrlPrefix"/> from the given string, and adds it to this collection. | ||
| /// </summary> | ||
| /// <param name="prefix">The string representing the <see cref="UrlPrefix"/> to add to this collection.</param> | ||
| public void Add(string prefix) | ||
| { | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Adds a <see cref="UrlPrefix"/> to this collection. | ||
| /// </summary> | ||
| /// <param name="item">The prefix to add to this collection.</param> | ||
| public void Add(UrlPrefix item) | ||
| { | ||
| } | ||
|
|
||
| /// <inheritdoc /> | ||
| public void Clear() | ||
| { | ||
| } | ||
|
|
||
| /// <inheritdoc /> | ||
| public bool Contains(UrlPrefix item) => false; | ||
|
|
||
| /// <inheritdoc /> | ||
| public void CopyTo(UrlPrefix[] array, int arrayIndex) | ||
| { | ||
| } | ||
|
|
||
| /// <inheritdoc /> | ||
| public bool Remove(string prefix) => false; | ||
|
|
||
| /// <inheritdoc /> | ||
| public bool Remove(UrlPrefix item) => false; | ||
|
|
||
| /// <summary> | ||
| /// Returns an enumerator that iterates through this collection. | ||
| /// </summary> | ||
| /// <returns>An enumerator for the collection.</returns> | ||
| public IEnumerator<UrlPrefix> GetEnumerator() => ((IEnumerable<UrlPrefix>)Array.Empty<UrlPrefix>()).GetEnumerator(); |
Comment on lines
+468
to
+500
| /// <summary> | ||
| /// The time, in seconds, allowed for the request entity body to arrive. The default timer is 2 minutes. | ||
| /// </summary> | ||
| public TimeSpan EntityBody { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// The time, in seconds, allowed for the HTTP Server API to drain the entity body on a Keep-Alive connection. | ||
| /// The default timer is 2 minutes. | ||
| /// </summary> | ||
| public TimeSpan DrainEntityBody { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// The time, in seconds, allowed for the request to remain in the request queue before the application picks | ||
| /// it up. The default timer is 2 minutes. | ||
| /// </summary> | ||
| public TimeSpan RequestQueue { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// The time, in seconds, allowed for an idle connection. The default timer is 2 minutes. | ||
| /// </summary> | ||
| public TimeSpan IdleConnection { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// The time, in seconds, allowed for the HTTP Server API to parse the request header. The default timer is | ||
| /// 2 minutes. | ||
| /// </summary> | ||
| public TimeSpan HeaderWait { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// The minimum send rate, in bytes-per-second, for the response. The default response send rate is 150 | ||
| /// bytes-per-second. | ||
| /// </summary> | ||
| public long MinSendBytesPerSecond { get; set; } |
Youssef1313
reviewed
May 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #65931
Fixes #59166
Fixes #63782
dotnet build /p:DotNetBuildSourceOnly=truenow shows errors if APIs are missing (>150 errors before the stubs were added)Microsoft.CodeAnalysis.PublicApiAnalyzersis being added to our normal package references, meaning it's now included as part of source-build. We already have other CodeAnalysis packages in this same bucket, so hopefully this will be fine.Can remove suppressions from https://github.com/dotnet/dotnet/blob/main/test/Microsoft.DotNet.SourceBuild.Tests/assets/SdkContentTests/ApiDiff.suppression once this gets to the VMR.