From 48b44dbb92378fededff434fa1dddf3d90a4ac99 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Tue, 23 Jul 2019 08:09:16 -0700 Subject: [PATCH] Add clarifying comment to HttpMethods.cs (#12441) To help prevent well-meaning (but not actually desirable) changes like https://github.com/aspnet/AspNetCore/pull/12439 --- src/Http/Http.Abstractions/src/HttpMethods.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Http/Http.Abstractions/src/HttpMethods.cs b/src/Http/Http.Abstractions/src/HttpMethods.cs index 1ccee896e7..05a5f2e834 100644 --- a/src/Http/Http.Abstractions/src/HttpMethods.cs +++ b/src/Http/Http.Abstractions/src/HttpMethods.cs @@ -7,6 +7,14 @@ namespace Microsoft.AspNetCore.Http { public static class HttpMethods { + // We are intentionally using 'static readonly' here instead of 'const'. + // 'const' values would be embedded in to each assembly that used them + // and each consuming assembly would have a different 'string' instance. + // Using .'static readonly' means that all consumers get thee exact same + // 'string' instance, which means the 'ReferenceEquals' checks below work + // and allow us to optimize comparisons when these constants are used. + + // Please do NOT change these to 'const' public static readonly string Connect = "CONNECT"; public static readonly string Delete = "DELETE"; public static readonly string Get = "GET";