diff --git a/src/Generators/Microsoft.Gen.Logging/Emission/Emitter.Method.cs b/src/Generators/Microsoft.Gen.Logging/Emission/Emitter.Method.cs index 004dd47be2e..286a419f209 100644 --- a/src/Generators/Microsoft.Gen.Logging/Emission/Emitter.Method.cs +++ b/src/Generators/Microsoft.Gen.Logging/Emission/Emitter.Method.cs @@ -155,8 +155,8 @@ static int GetNonRandomizedHashCode(string s) result = (c ^ result) * Mult; } - const uint NegativeMask = 0x7FFFFFFF; - return (int)(result & NegativeMask); // Ensure the result is non-negative + int ret = (int)result; + return ret == int.MinValue ? 0 : Math.Abs(ret); // Ensure the result is non-negative } static bool ShouldStringifyParameter(LoggingMethodParameter p)