From 01215bb74b8a2bc4a89983d5a9035f0b04367762 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 17 Nov 2020 16:42:03 -0800 Subject: [PATCH 01/19] Fix building host lineup packages. (#44839) * Fix building host lineup packages. Signed-off-by: Jeremy Koritzinsky * Update src/installer/pkg/projects/host-packages.proj Co-authored-by: Viktor Hofer Co-authored-by: Viktor Hofer --- src/installer/pkg/projects/host-packages.proj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/installer/pkg/projects/host-packages.proj b/src/installer/pkg/projects/host-packages.proj index 86981092e730e..ca72703065391 100644 --- a/src/installer/pkg/projects/host-packages.proj +++ b/src/installer/pkg/projects/host-packages.proj @@ -5,7 +5,7 @@ - + From 6f29f0be4f699d6aacde916e3ce15ff0f90c48ea Mon Sep 17 00:00:00 2001 From: monojenkins Date: Tue, 17 Nov 2020 20:38:57 -0500 Subject: [PATCH 02/19] [wasm] Use the functions in emscripten/stack.h to compute stack bounds. (#44819) Co-authored-by: vargaz --- src/mono/mono/utils/mono-threads-wasm.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/mono/mono/utils/mono-threads-wasm.c b/src/mono/mono/utils/mono-threads-wasm.c index 33f4688fac645..dc792e8158e00 100644 --- a/src/mono/mono/utils/mono-threads-wasm.c +++ b/src/mono/mono/utils/mono-threads-wasm.c @@ -10,6 +10,7 @@ #include #include +#include #include #define round_down(addr, val) ((void*)((addr) & ~((val) - 1))) @@ -18,19 +19,14 @@ EMSCRIPTEN_KEEPALIVE static int wasm_get_stack_base (void) { - // Return the bottom limit of the stack - return EM_ASM_INT ({ - return STACK_MAX; - }); + return emscripten_stack_get_end (); } EMSCRIPTEN_KEEPALIVE static int wasm_get_stack_size (void) { - return EM_ASM_INT ({ - return TOTAL_STACK; - }); + return (guint8*)emscripten_stack_get_base () - (guint8*)emscripten_stack_get_end (); } int From 181d6468420b10ee62cf3d9b27a22434992a6c21 Mon Sep 17 00:00:00 2001 From: Bruce Forstall Date: Tue, 17 Nov 2020 18:02:00 -0800 Subject: [PATCH 03/19] Trigger SuperPMI collection pipeline if JIT-EE GUID changes (#44846) Changing the JIT-EE GUID invalidates previous SuperPMI collections, necessitating a re-collection. As a proxy for determining whether the JIT-EE GUID has changed, just trigger anytime the corinfo.h file changes. --- eng/pipelines/coreclr/superpmi.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/eng/pipelines/coreclr/superpmi.yml b/eng/pipelines/coreclr/superpmi.yml index 3ae264540b1f9..6535309297f4b 100644 --- a/eng/pipelines/coreclr/superpmi.yml +++ b/eng/pipelines/coreclr/superpmi.yml @@ -1,4 +1,17 @@ -trigger: none +# This job definition automates the SuperPMI collection process. + +# Trigger this job if the JIT-EE GUID changes, which invalidates previous SuperPMI +# collections. As a proxy for determining if the JIT-EE GUID has changed, we just +# trigger if the file containing the GUID definition changes, which almost always +# corresponds to the GUID itself changing. +trigger: + batch: true + branches: + include: + - master + paths: + include: + - src/coreclr/src/inc/corinfo.h pr: none From 7d7ef2ce8527c782357ba2608ed0b211662628bf Mon Sep 17 00:00:00 2001 From: Smit Patel Date: Tue, 17 Nov 2020 18:25:01 -0800 Subject: [PATCH 04/19] Update nullability on some LINQ expression methods (#44844) - MethodCallExpression can take nullable instance when static method - LambdaExpression.Update does not return null in any case Resolves #44821 Resolves #44822 --- .../System.Linq.Expressions/ref/System.Linq.Expressions.cs | 4 ++-- .../src/System/Linq/Expressions/LambdaExpression.cs | 2 +- .../src/System/Linq/Expressions/MethodCallExpression.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libraries/System.Linq.Expressions/ref/System.Linq.Expressions.cs b/src/libraries/System.Linq.Expressions/ref/System.Linq.Expressions.cs index 09923d433d67e..bf467f927d4fa 100644 --- a/src/libraries/System.Linq.Expressions/ref/System.Linq.Expressions.cs +++ b/src/libraries/System.Linq.Expressions/ref/System.Linq.Expressions.cs @@ -834,7 +834,7 @@ internal Expression() { } public new TDelegate Compile() { throw null; } public new TDelegate Compile(bool preferInterpretation) { throw null; } public new TDelegate Compile(System.Runtime.CompilerServices.DebugInfoGenerator debugInfoGenerator) { throw null; } - public System.Linq.Expressions.Expression? Update(System.Linq.Expressions.Expression body, System.Collections.Generic.IEnumerable? parameters) { throw null; } + public System.Linq.Expressions.Expression Update(System.Linq.Expressions.Expression body, System.Collections.Generic.IEnumerable? parameters) { throw null; } } public sealed partial class GotoExpression : System.Linq.Expressions.Expression { @@ -1008,7 +1008,7 @@ internal MethodCallExpression() { } public sealed override System.Type Type { get { throw null; } } protected internal override System.Linq.Expressions.Expression Accept(System.Linq.Expressions.ExpressionVisitor visitor) { throw null; } System.Linq.Expressions.Expression System.Linq.Expressions.IArgumentProvider.GetArgument(int index) { throw null; } - public System.Linq.Expressions.MethodCallExpression Update(System.Linq.Expressions.Expression @object, System.Collections.Generic.IEnumerable? arguments) { throw null; } + public System.Linq.Expressions.MethodCallExpression Update(System.Linq.Expressions.Expression? @object, System.Collections.Generic.IEnumerable? arguments) { throw null; } } public partial class NewArrayExpression : System.Linq.Expressions.Expression { diff --git a/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/LambdaExpression.cs b/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/LambdaExpression.cs index 30ccac84af718..8f50c40fd7d3a 100644 --- a/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/LambdaExpression.cs +++ b/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/LambdaExpression.cs @@ -219,7 +219,7 @@ internal Expression(Expression body) /// The property of the result. /// The property of the result. /// This expression if no children changed, or an expression with the updated children. - public Expression? Update(Expression body, IEnumerable? parameters) + public Expression Update(Expression body, IEnumerable? parameters) { if (body == Body) { diff --git a/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/MethodCallExpression.cs b/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/MethodCallExpression.cs index 9217c5efbf98c..05155a1646c8a 100644 --- a/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/MethodCallExpression.cs +++ b/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/MethodCallExpression.cs @@ -59,7 +59,7 @@ internal MethodCallExpression(MethodInfo method) /// The property of the result. /// The property of the result. /// This expression if no children changed, or an expression with the updated children. - public MethodCallExpression Update(Expression @object, IEnumerable? arguments) + public MethodCallExpression Update(Expression? @object, IEnumerable? arguments) { if (@object == Object) { From 08ee531ba508f8ea93e30e644229bb786535eae7 Mon Sep 17 00:00:00 2001 From: Egor Chesakov Date: Tue, 17 Nov 2020 20:05:37 -0800 Subject: [PATCH 05/19] Make $(TargetOS) lowercase windows in eng/coredistools.target (#44845) * Make $(TargetOS) lowercase windows in eng/coredistools.target * Make $(TargetOS) lowercase windows in src/tests/Common/Directory.Build.targets --- eng/coredistools.targets | 2 +- src/tests/Common/Directory.Build.targets | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/coredistools.targets b/eng/coredistools.targets index 4c99911187384..0da9d1cc59b7a 100644 --- a/eng/coredistools.targets +++ b/eng/coredistools.targets @@ -8,7 +8,7 @@ - $(PkgMicrosoft_NETCore_CoreDisTools)\runtimes\win-$(TargetArchitecture)\native\coredistools.dll + $(PkgMicrosoft_NETCore_CoreDisTools)\runtimes\win-$(TargetArchitecture)\native\coredistools.dll $(PkgMicrosoft_NETCore_CoreDisTools)\runtimes\linux-$(TargetArchitecture)\native\libcoredistools.so $(PkgMicrosoft_NETCore_CoreDisTools)\runtimes\osx-$(TargetArchitecture)\native\libcoredistools.dylib diff --git a/src/tests/Common/Directory.Build.targets b/src/tests/Common/Directory.Build.targets index a52f83e839fc1..46ce59e8378f3 100644 --- a/src/tests/Common/Directory.Build.targets +++ b/src/tests/Common/Directory.Build.targets @@ -12,7 +12,7 @@ false - true + true true false true From 0d122b12ec1266d376817728f538837f513b8674 Mon Sep 17 00:00:00 2001 From: Maryam Ariyan Date: Tue, 17 Nov 2020 20:33:27 -0800 Subject: [PATCH 06/19] Fix NRE when default value is null and ServiceCallSite is not found (#44675) * Fix NRE when default value is null and ServiceCallSite is not found --- .../src/ServiceLookup/ConstantCallSite.cs | 6 ++-- .../tests/DI.Tests/CallSiteTests.cs | 31 +++++++++++++++++++ .../ServiceProviderCompilationTest.cs | 1 + 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceLookup/ConstantCallSite.cs b/src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceLookup/ConstantCallSite.cs index acc1d967f7380..bd09485c617f6 100644 --- a/src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceLookup/ConstantCallSite.cs +++ b/src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceLookup/ConstantCallSite.cs @@ -7,10 +7,12 @@ namespace Microsoft.Extensions.DependencyInjection.ServiceLookup { internal class ConstantCallSite : ServiceCallSite { + private readonly Type _serviceType; internal object DefaultValue { get; } public ConstantCallSite(Type serviceType, object defaultValue): base(ResultCache.None) { + _serviceType = serviceType ?? throw new ArgumentNullException(nameof(serviceType)); if (defaultValue != null && !serviceType.IsInstanceOfType(defaultValue)) { throw new ArgumentException(SR.Format(SR.ConstantCantBeConvertedToServiceType, defaultValue.GetType(), serviceType)); @@ -19,8 +21,8 @@ public ConstantCallSite(Type serviceType, object defaultValue): base(ResultCache DefaultValue = defaultValue; } - public override Type ServiceType => DefaultValue.GetType(); - public override Type ImplementationType => DefaultValue.GetType(); + public override Type ServiceType => DefaultValue?.GetType() ?? _serviceType; + public override Type ImplementationType => DefaultValue?.GetType() ?? _serviceType; public override CallSiteKind Kind { get; } = CallSiteKind.Constant; } } diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.Tests/CallSiteTests.cs b/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.Tests/CallSiteTests.cs index 3dc3cec6c6473..c83e27790b637 100644 --- a/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.Tests/CallSiteTests.cs +++ b/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.Tests/CallSiteTests.cs @@ -264,6 +264,37 @@ public void DoesNotThrowWhenServiceIsUsedAsEnumerableAndNotInOneCallSite() Assert.NotNull(compileCallSite); } + [Theory] + [InlineData(ServiceProviderMode.Default)] + [InlineData(ServiceProviderMode.Dynamic)] + [InlineData(ServiceProviderMode.Runtime)] + [InlineData(ServiceProviderMode.Expressions)] + [InlineData(ServiceProviderMode.ILEmit)] + private void NoServiceCallsite_DefaultValueNull_DoesNotThrow(ServiceProviderMode mode) + { + var descriptors = new ServiceCollection(); + descriptors.AddTransient(); + + var provider = descriptors.BuildServiceProvider(mode); + ServiceF instance = ActivatorUtilities.CreateInstance(provider); + + Assert.NotNull(instance); + } + + private interface IServiceG + { + } + + private class ServiceG + { + public ServiceG(IServiceG service = null) { } + } + + private class ServiceF + { + public ServiceF(ServiceG service) { } + } + private class ServiceD { public ServiceD(IEnumerable services) diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.Tests/ServiceProviderCompilationTest.cs b/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.Tests/ServiceProviderCompilationTest.cs index 5c6853e1b1c18..8094dde9364b1 100644 --- a/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.Tests/ServiceProviderCompilationTest.cs +++ b/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.Tests/ServiceProviderCompilationTest.cs @@ -12,6 +12,7 @@ namespace Microsoft.Extensions.DependencyInjection.Tests public class ServiceProviderCompilationTest { [Theory] + [InlineData(ServiceProviderMode.Default, typeof(I999))] [InlineData(ServiceProviderMode.Dynamic, typeof(I999))] [InlineData(ServiceProviderMode.Runtime, typeof(I999))] [InlineData(ServiceProviderMode.ILEmit, typeof(I999))] From fa06656c41947e22fc6efd909cce0a6a180f1078 Mon Sep 17 00:00:00 2001 From: Maryam Ariyan Date: Tue, 17 Nov 2020 20:50:05 -0800 Subject: [PATCH 07/19] Enable nullable annotations for M.E.L.Abstractions (#43892) * Enable nullable annotations for M.E.L.Abstractions * Corrections from review * LoggerExtensions.cs: params object?[] -> params object?[] * using Nullable Annotations, to allow annotations on relevant projects, not yet enabled * formatter not null --- .../Logging/NullExternalScopeProvider.cs | 6 +- .../TypeNameHelper/TypeNameHelper.cs | 18 ++- ...soft.Extensions.DependencyInjection.csproj | 1 + .../src/Microsoft.Extensions.Http.csproj | 1 + ...crosoft.Extensions.Logging.Abstractions.cs | 98 ++++++------ .../src/EventId.cs | 6 +- .../src/FormattedLogValues.cs | 20 +-- .../src/IExternalScopeProvider.cs | 4 +- .../src/ILogger.cs | 2 +- .../src/LogEntry.cs | 6 +- .../src/LogValuesFormatter.cs | 24 +-- .../src/LoggerExtensions.cs | 62 ++++---- .../src/LoggerExternalScopeProvider.cs | 18 +-- .../src/LoggerMessage.cs | 140 +++++++++--------- .../src/LoggerT.cs | 2 +- ...oft.Extensions.Logging.Abstractions.csproj | 6 +- .../src/NullLogger.cs | 2 +- .../src/NullLoggerT.cs | 4 +- 18 files changed, 216 insertions(+), 204 deletions(-) diff --git a/src/libraries/Common/src/Extensions/Logging/NullExternalScopeProvider.cs b/src/libraries/Common/src/Extensions/Logging/NullExternalScopeProvider.cs index 17936083a934d..791ecc87152cd 100644 --- a/src/libraries/Common/src/Extensions/Logging/NullExternalScopeProvider.cs +++ b/src/libraries/Common/src/Extensions/Logging/NullExternalScopeProvider.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#nullable enable + using System; namespace Microsoft.Extensions.Logging @@ -20,12 +22,12 @@ private NullExternalScopeProvider() public static IExternalScopeProvider Instance { get; } = new NullExternalScopeProvider(); /// - void IExternalScopeProvider.ForEachScope(Action callback, TState state) + void IExternalScopeProvider.ForEachScope(Action callback, TState state) { } /// - IDisposable IExternalScopeProvider.Push(object state) + IDisposable IExternalScopeProvider.Push(object? state) { return NullScope.Instance; } diff --git a/src/libraries/Common/src/Extensions/TypeNameHelper/TypeNameHelper.cs b/src/libraries/Common/src/Extensions/TypeNameHelper/TypeNameHelper.cs index 66d767c3fdf88..1377491df5cfa 100644 --- a/src/libraries/Common/src/Extensions/TypeNameHelper/TypeNameHelper.cs +++ b/src/libraries/Common/src/Extensions/TypeNameHelper/TypeNameHelper.cs @@ -1,9 +1,12 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#nullable enable + using System; using System.Text; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; namespace Microsoft.Extensions.Internal { @@ -31,7 +34,8 @@ internal static class TypeNameHelper { typeof(ushort), "ushort" } }; - public static string GetTypeDisplayName(object item, bool fullName = true) + [return: NotNullIfNotNull("item")] + public static string? GetTypeDisplayName(object? item, bool fullName = true) { return item == null ? null : GetTypeDisplayName(item.GetType(), fullName); } @@ -63,7 +67,7 @@ private static void ProcessType(StringBuilder builder, Type type, in DisplayName { ProcessArrayType(builder, type, options); } - else if (_builtInTypeNames.TryGetValue(type, out string builtInName)) + else if (_builtInTypeNames.TryGetValue(type, out string? builtInName)) { builder.Append(builtInName); } @@ -76,7 +80,7 @@ private static void ProcessType(StringBuilder builder, Type type, in DisplayName } else { - string name = options.FullName ? type.FullName : type.Name; + string name = options.FullName ? type.FullName! : type.Name; builder.Append(name); if (options.NestedTypeDelimiter != DefaultNestedTypeDelimiter) @@ -91,7 +95,7 @@ private static void ProcessArrayType(StringBuilder builder, Type type, in Displa Type innerType = type; while (innerType.IsArray) { - innerType = innerType.GetElementType(); + innerType = innerType.GetElementType()!; } ProcessType(builder, innerType, options); @@ -101,7 +105,7 @@ private static void ProcessArrayType(StringBuilder builder, Type type, in Displa builder.Append('['); builder.Append(',', type.GetArrayRank() - 1); builder.Append(']'); - type = type.GetElementType(); + type = type.GetElementType()!; } } @@ -110,14 +114,14 @@ private static void ProcessGenericType(StringBuilder builder, Type type, Type[] int offset = 0; if (type.IsNested) { - offset = type.DeclaringType.GetGenericArguments().Length; + offset = type.DeclaringType!.GetGenericArguments().Length; } if (options.FullName) { if (type.IsNested) { - ProcessGenericType(builder, type.DeclaringType, genericArguments, offset, options); + ProcessGenericType(builder, type.DeclaringType!, genericArguments, offset, options); builder.Append(options.NestedTypeDelimiter); } else if (!string.IsNullOrEmpty(type.Namespace)) diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection/src/Microsoft.Extensions.DependencyInjection.csproj b/src/libraries/Microsoft.Extensions.DependencyInjection/src/Microsoft.Extensions.DependencyInjection.csproj index 412c9bef97e48..58552c053317f 100644 --- a/src/libraries/Microsoft.Extensions.DependencyInjection/src/Microsoft.Extensions.DependencyInjection.csproj +++ b/src/libraries/Microsoft.Extensions.DependencyInjection/src/Microsoft.Extensions.DependencyInjection.csproj @@ -4,6 +4,7 @@ $(NetCoreAppCurrent);net461;netstandard2.0;netstandard2.1 False + Annotations diff --git a/src/libraries/Microsoft.Extensions.Http/src/Microsoft.Extensions.Http.csproj b/src/libraries/Microsoft.Extensions.Http/src/Microsoft.Extensions.Http.csproj index 6de909a45f7ea..f8382783997e5 100644 --- a/src/libraries/Microsoft.Extensions.Http/src/Microsoft.Extensions.Http.csproj +++ b/src/libraries/Microsoft.Extensions.Http/src/Microsoft.Extensions.Http.csproj @@ -3,6 +3,7 @@ netstandard2.0;net461 true + Annotations diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/ref/Microsoft.Extensions.Logging.Abstractions.cs b/src/libraries/Microsoft.Extensions.Logging.Abstractions/ref/Microsoft.Extensions.Logging.Abstractions.cs index 6c492ac9bd9cf..e2d403bc7b38c 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/ref/Microsoft.Extensions.Logging.Abstractions.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/ref/Microsoft.Extensions.Logging.Abstractions.cs @@ -10,11 +10,11 @@ public readonly partial struct EventId { private readonly object _dummy; private readonly int _dummyPrimitive; - public EventId(int id, string name = null) { throw null; } + public EventId(int id, string? name = null) { throw null; } public int Id { get { throw null; } } - public string Name { get { throw null; } } + public string? Name { get { throw null; } } public bool Equals(Microsoft.Extensions.Logging.EventId other) { throw null; } - public override bool Equals(object obj) { throw null; } + public override bool Equals(object? obj) { throw null; } public override int GetHashCode() { throw null; } public static bool operator ==(Microsoft.Extensions.Logging.EventId left, Microsoft.Extensions.Logging.EventId right) { throw null; } public static implicit operator Microsoft.Extensions.Logging.EventId (int i) { throw null; } @@ -23,14 +23,14 @@ public readonly partial struct EventId } public partial interface IExternalScopeProvider { - void ForEachScope(System.Action callback, TState state); - System.IDisposable Push(object state); + void ForEachScope(System.Action callback, TState state); + System.IDisposable Push(object? state); } public partial interface ILogger { System.IDisposable BeginScope(TState state); bool IsEnabled(Microsoft.Extensions.Logging.LogLevel logLevel); - void Log(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, TState state, System.Exception exception, System.Func formatter); + void Log(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, TState state, System.Exception? exception, System.Func formatter); } public partial interface ILoggerFactory : System.IDisposable { @@ -50,41 +50,41 @@ public partial interface ISupportExternalScope } public static partial class LoggerExtensions { - public static System.IDisposable BeginScope(this Microsoft.Extensions.Logging.ILogger logger, string messageFormat, params object[] args) { throw null; } - public static void Log(this Microsoft.Extensions.Logging.ILogger logger, Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, System.Exception exception, string message, params object[] args) { } - public static void Log(this Microsoft.Extensions.Logging.ILogger logger, Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string message, params object[] args) { } - public static void Log(this Microsoft.Extensions.Logging.ILogger logger, Microsoft.Extensions.Logging.LogLevel logLevel, System.Exception exception, string message, params object[] args) { } - public static void Log(this Microsoft.Extensions.Logging.ILogger logger, Microsoft.Extensions.Logging.LogLevel logLevel, string message, params object[] args) { } - public static void LogCritical(this Microsoft.Extensions.Logging.ILogger logger, Microsoft.Extensions.Logging.EventId eventId, System.Exception exception, string message, params object[] args) { } - public static void LogCritical(this Microsoft.Extensions.Logging.ILogger logger, Microsoft.Extensions.Logging.EventId eventId, string message, params object[] args) { } - public static void LogCritical(this Microsoft.Extensions.Logging.ILogger logger, System.Exception exception, string message, params object[] args) { } - public static void LogCritical(this Microsoft.Extensions.Logging.ILogger logger, string message, params object[] args) { } - public static void LogDebug(this Microsoft.Extensions.Logging.ILogger logger, Microsoft.Extensions.Logging.EventId eventId, System.Exception exception, string message, params object[] args) { } - public static void LogDebug(this Microsoft.Extensions.Logging.ILogger logger, Microsoft.Extensions.Logging.EventId eventId, string message, params object[] args) { } - public static void LogDebug(this Microsoft.Extensions.Logging.ILogger logger, System.Exception exception, string message, params object[] args) { } - public static void LogDebug(this Microsoft.Extensions.Logging.ILogger logger, string message, params object[] args) { } - public static void LogError(this Microsoft.Extensions.Logging.ILogger logger, Microsoft.Extensions.Logging.EventId eventId, System.Exception exception, string message, params object[] args) { } - public static void LogError(this Microsoft.Extensions.Logging.ILogger logger, Microsoft.Extensions.Logging.EventId eventId, string message, params object[] args) { } - public static void LogError(this Microsoft.Extensions.Logging.ILogger logger, System.Exception exception, string message, params object[] args) { } - public static void LogError(this Microsoft.Extensions.Logging.ILogger logger, string message, params object[] args) { } - public static void LogInformation(this Microsoft.Extensions.Logging.ILogger logger, Microsoft.Extensions.Logging.EventId eventId, System.Exception exception, string message, params object[] args) { } - public static void LogInformation(this Microsoft.Extensions.Logging.ILogger logger, Microsoft.Extensions.Logging.EventId eventId, string message, params object[] args) { } - public static void LogInformation(this Microsoft.Extensions.Logging.ILogger logger, System.Exception exception, string message, params object[] args) { } - public static void LogInformation(this Microsoft.Extensions.Logging.ILogger logger, string message, params object[] args) { } - public static void LogTrace(this Microsoft.Extensions.Logging.ILogger logger, Microsoft.Extensions.Logging.EventId eventId, System.Exception exception, string message, params object[] args) { } - public static void LogTrace(this Microsoft.Extensions.Logging.ILogger logger, Microsoft.Extensions.Logging.EventId eventId, string message, params object[] args) { } - public static void LogTrace(this Microsoft.Extensions.Logging.ILogger logger, System.Exception exception, string message, params object[] args) { } - public static void LogTrace(this Microsoft.Extensions.Logging.ILogger logger, string message, params object[] args) { } - public static void LogWarning(this Microsoft.Extensions.Logging.ILogger logger, Microsoft.Extensions.Logging.EventId eventId, System.Exception exception, string message, params object[] args) { } - public static void LogWarning(this Microsoft.Extensions.Logging.ILogger logger, Microsoft.Extensions.Logging.EventId eventId, string message, params object[] args) { } - public static void LogWarning(this Microsoft.Extensions.Logging.ILogger logger, System.Exception exception, string message, params object[] args) { } - public static void LogWarning(this Microsoft.Extensions.Logging.ILogger logger, string message, params object[] args) { } + public static System.IDisposable BeginScope(this Microsoft.Extensions.Logging.ILogger logger, string messageFormat, params object?[] args) { throw null; } + public static void Log(this Microsoft.Extensions.Logging.ILogger logger, Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, System.Exception? exception, string? message, params object?[] args) { } + public static void Log(this Microsoft.Extensions.Logging.ILogger logger, Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string? message, params object?[] args) { } + public static void Log(this Microsoft.Extensions.Logging.ILogger logger, Microsoft.Extensions.Logging.LogLevel logLevel, System.Exception? exception, string? message, params object?[] args) { } + public static void Log(this Microsoft.Extensions.Logging.ILogger logger, Microsoft.Extensions.Logging.LogLevel logLevel, string? message, params object?[] args) { } + public static void LogCritical(this Microsoft.Extensions.Logging.ILogger logger, Microsoft.Extensions.Logging.EventId eventId, System.Exception? exception, string? message, params object?[] args) { } + public static void LogCritical(this Microsoft.Extensions.Logging.ILogger logger, Microsoft.Extensions.Logging.EventId eventId, string? message, params object?[] args) { } + public static void LogCritical(this Microsoft.Extensions.Logging.ILogger logger, System.Exception? exception, string? message, params object?[] args) { } + public static void LogCritical(this Microsoft.Extensions.Logging.ILogger logger, string? message, params object?[] args) { } + public static void LogDebug(this Microsoft.Extensions.Logging.ILogger logger, Microsoft.Extensions.Logging.EventId eventId, System.Exception? exception, string? message, params object?[] args) { } + public static void LogDebug(this Microsoft.Extensions.Logging.ILogger logger, Microsoft.Extensions.Logging.EventId eventId, string? message, params object?[] args) { } + public static void LogDebug(this Microsoft.Extensions.Logging.ILogger logger, System.Exception? exception, string? message, params object?[] args) { } + public static void LogDebug(this Microsoft.Extensions.Logging.ILogger logger, string? message, params object?[] args) { } + public static void LogError(this Microsoft.Extensions.Logging.ILogger logger, Microsoft.Extensions.Logging.EventId eventId, System.Exception? exception, string? message, params object?[] args) { } + public static void LogError(this Microsoft.Extensions.Logging.ILogger logger, Microsoft.Extensions.Logging.EventId eventId, string? message, params object?[] args) { } + public static void LogError(this Microsoft.Extensions.Logging.ILogger logger, System.Exception? exception, string? message, params object?[] args) { } + public static void LogError(this Microsoft.Extensions.Logging.ILogger logger, string? message, params object?[] args) { } + public static void LogInformation(this Microsoft.Extensions.Logging.ILogger logger, Microsoft.Extensions.Logging.EventId eventId, System.Exception? exception, string? message, params object?[] args) { } + public static void LogInformation(this Microsoft.Extensions.Logging.ILogger logger, Microsoft.Extensions.Logging.EventId eventId, string? message, params object?[] args) { } + public static void LogInformation(this Microsoft.Extensions.Logging.ILogger logger, System.Exception? exception, string? message, params object?[] args) { } + public static void LogInformation(this Microsoft.Extensions.Logging.ILogger logger, string? message, params object?[] args) { } + public static void LogTrace(this Microsoft.Extensions.Logging.ILogger logger, Microsoft.Extensions.Logging.EventId eventId, System.Exception? exception, string? message, params object?[] args) { } + public static void LogTrace(this Microsoft.Extensions.Logging.ILogger logger, Microsoft.Extensions.Logging.EventId eventId, string? message, params object?[] args) { } + public static void LogTrace(this Microsoft.Extensions.Logging.ILogger logger, System.Exception? exception, string? message, params object?[] args) { } + public static void LogTrace(this Microsoft.Extensions.Logging.ILogger logger, string? message, params object?[] args) { } + public static void LogWarning(this Microsoft.Extensions.Logging.ILogger logger, Microsoft.Extensions.Logging.EventId eventId, System.Exception? exception, string? message, params object?[] args) { } + public static void LogWarning(this Microsoft.Extensions.Logging.ILogger logger, Microsoft.Extensions.Logging.EventId eventId, string? message, params object?[] args) { } + public static void LogWarning(this Microsoft.Extensions.Logging.ILogger logger, System.Exception? exception, string? message, params object?[] args) { } + public static void LogWarning(this Microsoft.Extensions.Logging.ILogger logger, string? message, params object?[] args) { } } public partial class LoggerExternalScopeProvider : Microsoft.Extensions.Logging.IExternalScopeProvider { public LoggerExternalScopeProvider() { } - public void ForEachScope(System.Action callback, TState state) { } - public System.IDisposable Push(object state) { throw null; } + public void ForEachScope(System.Action callback, TState state) { } + public System.IDisposable Push(object? state) { throw null; } } public static partial class LoggerFactoryExtensions { @@ -93,7 +93,7 @@ public static partial class LoggerFactoryExtensions } public static partial class LoggerMessage { - public static System.Action Define(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString) { throw null; } + public static System.Action Define(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString) { throw null; } public static System.Func DefineScope(string formatString) { throw null; } public static System.Func DefineScope(string formatString) { throw null; } public static System.Func DefineScope(string formatString) { throw null; } @@ -101,12 +101,12 @@ public static partial class LoggerMessage public static System.Func DefineScope(string formatString) { throw null; } public static System.Func DefineScope(string formatString) { throw null; } public static System.Func DefineScope(string formatString) { throw null; } - public static System.Action Define(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString) { throw null; } - public static System.Action Define(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString) { throw null; } - public static System.Action Define(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString) { throw null; } - public static System.Action Define(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString) { throw null; } - public static System.Action Define(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString) { throw null; } - public static System.Action Define(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString) { throw null; } + public static System.Action Define(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString) { throw null; } + public static System.Action Define(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString) { throw null; } + public static System.Action Define(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString) { throw null; } + public static System.Action Define(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString) { throw null; } + public static System.Action Define(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString) { throw null; } + public static System.Action Define(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString) { throw null; } } public partial class Logger : Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.ILogger { @@ -133,11 +133,11 @@ public readonly partial struct LogEntry private readonly TState _State_k__BackingField; private readonly object _dummy; private readonly int _dummyPrimitive; - public LogEntry(Microsoft.Extensions.Logging.LogLevel logLevel, string category, Microsoft.Extensions.Logging.EventId eventId, TState state, System.Exception exception, System.Func formatter) { throw null; } + public LogEntry(Microsoft.Extensions.Logging.LogLevel logLevel, string category, Microsoft.Extensions.Logging.EventId eventId, TState state, System.Exception? exception, System.Func formatter) { throw null; } public string Category { get { throw null; } } public Microsoft.Extensions.Logging.EventId EventId { get { throw null; } } - public System.Exception Exception { get { throw null; } } - public System.Func Formatter { get { throw null; } } + public System.Exception? Exception { get { throw null; } } + public System.Func? Formatter { get { throw null; } } public Microsoft.Extensions.Logging.LogLevel LogLevel { get { throw null; } } public TState State { get { throw null; } } } @@ -147,7 +147,7 @@ internal NullLogger() { } public static Microsoft.Extensions.Logging.Abstractions.NullLogger Instance { get { throw null; } } public System.IDisposable BeginScope(TState state) { throw null; } public bool IsEnabled(Microsoft.Extensions.Logging.LogLevel logLevel) { throw null; } - public void Log(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, TState state, System.Exception exception, System.Func formatter) { } + public void Log(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, TState state, System.Exception? exception, System.Func formatter) { } } public partial class NullLoggerFactory : Microsoft.Extensions.Logging.ILoggerFactory, System.IDisposable { @@ -170,6 +170,6 @@ public partial class NullLogger : Microsoft.Extensions.Logging.ILogger, Micro public NullLogger() { } public System.IDisposable BeginScope(TState state) { throw null; } public bool IsEnabled(Microsoft.Extensions.Logging.LogLevel logLevel) { throw null; } - public void Log(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, TState state, System.Exception exception, System.Func formatter) { } + public void Log(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, TState state, System.Exception? exception, System.Func formatter) { } } } diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/EventId.cs b/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/EventId.cs index 5c7d7de2b9d36..7e031c5ec5f6b 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/EventId.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/EventId.cs @@ -44,7 +44,7 @@ public static implicit operator EventId(int i) /// /// The numeric identifier for this event. /// The name of this event. - public EventId(int id, string name = null) + public EventId(int id, string? name = null) { Id = id; Name = name; @@ -58,7 +58,7 @@ public EventId(int id, string name = null) /// /// Gets the name of this event. /// - public string Name { get; } + public string? Name { get; } /// public override string ToString() @@ -77,7 +77,7 @@ public bool Equals(EventId other) } /// - public override bool Equals(object obj) + public override bool Equals(object? obj) { if (obj is null) { diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/FormattedLogValues.cs b/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/FormattedLogValues.cs index ad0bde9b6fb95..4ee37937aa514 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/FormattedLogValues.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/FormattedLogValues.cs @@ -10,23 +10,23 @@ namespace Microsoft.Extensions.Logging { /// - /// LogValues to enable formatting options supported by . + /// LogValues to enable formatting options supported by . /// This also enables using {NamedformatItem} in the format string. /// - internal readonly struct FormattedLogValues : IReadOnlyList> + internal readonly struct FormattedLogValues : IReadOnlyList> { internal const int MaxCachedFormatters = 1024; private const string NullFormat = "[null]"; private static int _count; private static ConcurrentDictionary _formatters = new ConcurrentDictionary(); - private readonly LogValuesFormatter _formatter; - private readonly object[] _values; + private readonly LogValuesFormatter? _formatter; + private readonly object?[]? _values; private readonly string _originalMessage; // for testing purposes - internal LogValuesFormatter Formatter => _formatter; + internal LogValuesFormatter? Formatter => _formatter; - public FormattedLogValues(string format, params object[] values) + public FormattedLogValues(string? format, params object?[]? values) { if (values != null && values.Length != 0 && format != null) { @@ -55,7 +55,7 @@ public FormattedLogValues(string format, params object[] values) _values = values; } - public KeyValuePair this[int index] + public KeyValuePair this[int index] { get { @@ -66,10 +66,10 @@ public KeyValuePair this[int index] if (index == Count - 1) { - return new KeyValuePair ("{OriginalFormat}", _originalMessage); + return new KeyValuePair ("{OriginalFormat}", _originalMessage); } - return _formatter.GetValue(_values, index); + return _formatter!.GetValue(_values!, index); } } @@ -86,7 +86,7 @@ public int Count } } - public IEnumerator> GetEnumerator() + public IEnumerator> GetEnumerator() { for (int i = 0; i < Count; ++i) { diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/IExternalScopeProvider.cs b/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/IExternalScopeProvider.cs index 85e8d9cf29a83..20855aa043c0a 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/IExternalScopeProvider.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/IExternalScopeProvider.cs @@ -17,13 +17,13 @@ public interface IExternalScopeProvider /// The callback to be executed for every scope object /// The state object to be passed into the callback /// The type of state to accept. - void ForEachScope(Action callback, TState state); + void ForEachScope(Action callback, TState state); /// /// Adds scope object to the list /// /// The scope object /// The token that removes scope on dispose. - IDisposable Push(object state); + IDisposable Push(object? state); } } diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/ILogger.cs b/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/ILogger.cs index d7164852b4837..15c7025827647 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/ILogger.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/ILogger.cs @@ -20,7 +20,7 @@ public interface ILogger /// The exception related to this entry. /// Function to create a message of the and . /// The type of the object to be written. - void Log(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func formatter); + void Log(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func formatter); /// /// Checks if the given is enabled. diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/LogEntry.cs b/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/LogEntry.cs index e0cab847a156f..cebd054da91b7 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/LogEntry.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/LogEntry.cs @@ -19,7 +19,7 @@ public readonly struct LogEntry /// The state for which log is being written. /// The log exception. /// The formatter. - public LogEntry(LogLevel logLevel, string category, EventId eventId, TState state, Exception exception, Func formatter) + public LogEntry(LogLevel logLevel, string category, EventId eventId, TState state, Exception? exception, Func formatter) { LogLevel = logLevel; Category = category; @@ -52,11 +52,11 @@ public LogEntry(LogLevel logLevel, string category, EventId eventId, TState stat /// /// Gets the log exception /// - public Exception Exception { get; } + public Exception? Exception { get; } /// /// Gets the formatter /// - public Func Formatter { get; } + public Func? Formatter { get; } } } diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/LogValuesFormatter.cs b/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/LogValuesFormatter.cs index 2368a18848465..f9565145d666b 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/LogValuesFormatter.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/LogValuesFormatter.cs @@ -128,7 +128,7 @@ private static int FindIndexOfAny(string format, char[] chars, int startIndex, i return findIndex == -1 ? endIndex : findIndex; } - public string Format(object[] values) + public string Format(object?[]? values) { if (values != null) { @@ -146,22 +146,22 @@ internal string Format() return _format; } - internal string Format(object arg0) + internal string Format(object? arg0) { return string.Format(CultureInfo.InvariantCulture, _format, FormatArgument(arg0)); } - internal string Format(object arg0, object arg1) + internal string Format(object? arg0, object? arg1) { return string.Format(CultureInfo.InvariantCulture, _format, FormatArgument(arg0), FormatArgument(arg1)); } - internal string Format(object arg0, object arg1, object arg2) + internal string Format(object? arg0, object? arg1, object? arg2) { return string.Format(CultureInfo.InvariantCulture, _format, FormatArgument(arg0), FormatArgument(arg1), FormatArgument(arg2)); } - public KeyValuePair GetValue(object[] values, int index) + public KeyValuePair GetValue(object?[] values, int index) { if (index < 0 || index > _valueNames.Count) { @@ -170,25 +170,25 @@ public KeyValuePair GetValue(object[] values, int index) if (_valueNames.Count > index) { - return new KeyValuePair(_valueNames[index], values[index]); + return new KeyValuePair(_valueNames[index], values[index]); } - return new KeyValuePair("{OriginalFormat}", OriginalFormat); + return new KeyValuePair("{OriginalFormat}", OriginalFormat); } - public IEnumerable> GetValues(object[] values) + public IEnumerable> GetValues(object[] values) { - var valueArray = new KeyValuePair[values.Length + 1]; + var valueArray = new KeyValuePair[values.Length + 1]; for (int index = 0; index != _valueNames.Count; ++index) { - valueArray[index] = new KeyValuePair(_valueNames[index], values[index]); + valueArray[index] = new KeyValuePair(_valueNames[index], values[index]); } - valueArray[valueArray.Length - 1] = new KeyValuePair("{OriginalFormat}", OriginalFormat); + valueArray[valueArray.Length - 1] = new KeyValuePair("{OriginalFormat}", OriginalFormat); return valueArray; } - private object FormatArgument(object value) + private object FormatArgument(object? value) { if (value == null) { diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/LoggerExtensions.cs b/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/LoggerExtensions.cs index 6f742843a5493..4ef6c371e2b91 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/LoggerExtensions.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/LoggerExtensions.cs @@ -10,7 +10,7 @@ namespace Microsoft.Extensions.Logging /// public static class LoggerExtensions { - private static readonly Func _messageFormatter = MessageFormatter; + private static readonly Func _messageFormatter = MessageFormatter; //------------------------------------------DEBUG------------------------------------------// @@ -23,7 +23,7 @@ public static class LoggerExtensions /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.LogDebug(0, exception, "Error while processing request from {Address}", address) - public static void LogDebug(this ILogger logger, EventId eventId, Exception exception, string message, params object[] args) + public static void LogDebug(this ILogger logger, EventId eventId, Exception? exception, string? message, params object?[] args) { logger.Log(LogLevel.Debug, eventId, exception, message, args); } @@ -36,7 +36,7 @@ public static void LogDebug(this ILogger logger, EventId eventId, Exception exce /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.LogDebug(0, "Processing request from {Address}", address) - public static void LogDebug(this ILogger logger, EventId eventId, string message, params object[] args) + public static void LogDebug(this ILogger logger, EventId eventId, string? message, params object?[] args) { logger.Log(LogLevel.Debug, eventId, message, args); } @@ -49,7 +49,7 @@ public static void LogDebug(this ILogger logger, EventId eventId, string message /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.LogDebug(exception, "Error while processing request from {Address}", address) - public static void LogDebug(this ILogger logger, Exception exception, string message, params object[] args) + public static void LogDebug(this ILogger logger, Exception? exception, string? message, params object?[] args) { logger.Log(LogLevel.Debug, exception, message, args); } @@ -61,7 +61,7 @@ public static void LogDebug(this ILogger logger, Exception exception, string mes /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.LogDebug("Processing request from {Address}", address) - public static void LogDebug(this ILogger logger, string message, params object[] args) + public static void LogDebug(this ILogger logger, string? message, params object?[] args) { logger.Log(LogLevel.Debug, message, args); } @@ -77,7 +77,7 @@ public static void LogDebug(this ILogger logger, string message, params object[] /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.LogTrace(0, exception, "Error while processing request from {Address}", address) - public static void LogTrace(this ILogger logger, EventId eventId, Exception exception, string message, params object[] args) + public static void LogTrace(this ILogger logger, EventId eventId, Exception? exception, string? message, params object?[] args) { logger.Log(LogLevel.Trace, eventId, exception, message, args); } @@ -90,7 +90,7 @@ public static void LogTrace(this ILogger logger, EventId eventId, Exception exce /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.LogTrace(0, "Processing request from {Address}", address) - public static void LogTrace(this ILogger logger, EventId eventId, string message, params object[] args) + public static void LogTrace(this ILogger logger, EventId eventId, string? message, params object?[] args) { logger.Log(LogLevel.Trace, eventId, message, args); } @@ -103,7 +103,7 @@ public static void LogTrace(this ILogger logger, EventId eventId, string message /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.LogTrace(exception, "Error while processing request from {Address}", address) - public static void LogTrace(this ILogger logger, Exception exception, string message, params object[] args) + public static void LogTrace(this ILogger logger, Exception? exception, string? message, params object?[] args) { logger.Log(LogLevel.Trace, exception, message, args); } @@ -115,7 +115,7 @@ public static void LogTrace(this ILogger logger, Exception exception, string mes /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.LogTrace("Processing request from {Address}", address) - public static void LogTrace(this ILogger logger, string message, params object[] args) + public static void LogTrace(this ILogger logger, string? message, params object?[] args) { logger.Log(LogLevel.Trace, message, args); } @@ -131,7 +131,7 @@ public static void LogTrace(this ILogger logger, string message, params object[] /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.LogInformation(0, exception, "Error while processing request from {Address}", address) - public static void LogInformation(this ILogger logger, EventId eventId, Exception exception, string message, params object[] args) + public static void LogInformation(this ILogger logger, EventId eventId, Exception? exception, string? message, params object?[] args) { logger.Log(LogLevel.Information, eventId, exception, message, args); } @@ -144,7 +144,7 @@ public static void LogInformation(this ILogger logger, EventId eventId, Exceptio /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.LogInformation(0, "Processing request from {Address}", address) - public static void LogInformation(this ILogger logger, EventId eventId, string message, params object[] args) + public static void LogInformation(this ILogger logger, EventId eventId, string? message, params object?[] args) { logger.Log(LogLevel.Information, eventId, message, args); } @@ -157,7 +157,7 @@ public static void LogInformation(this ILogger logger, EventId eventId, string m /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.LogInformation(exception, "Error while processing request from {Address}", address) - public static void LogInformation(this ILogger logger, Exception exception, string message, params object[] args) + public static void LogInformation(this ILogger logger, Exception? exception, string? message, params object?[] args) { logger.Log(LogLevel.Information, exception, message, args); } @@ -169,7 +169,7 @@ public static void LogInformation(this ILogger logger, Exception exception, stri /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.LogInformation("Processing request from {Address}", address) - public static void LogInformation(this ILogger logger, string message, params object[] args) + public static void LogInformation(this ILogger logger, string? message, params object?[] args) { logger.Log(LogLevel.Information, message, args); } @@ -185,7 +185,7 @@ public static void LogInformation(this ILogger logger, string message, params ob /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.LogWarning(0, exception, "Error while processing request from {Address}", address) - public static void LogWarning(this ILogger logger, EventId eventId, Exception exception, string message, params object[] args) + public static void LogWarning(this ILogger logger, EventId eventId, Exception? exception, string? message, params object?[] args) { logger.Log(LogLevel.Warning, eventId, exception, message, args); } @@ -198,7 +198,7 @@ public static void LogWarning(this ILogger logger, EventId eventId, Exception ex /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.LogWarning(0, "Processing request from {Address}", address) - public static void LogWarning(this ILogger logger, EventId eventId, string message, params object[] args) + public static void LogWarning(this ILogger logger, EventId eventId, string? message, params object?[] args) { logger.Log(LogLevel.Warning, eventId, message, args); } @@ -211,7 +211,7 @@ public static void LogWarning(this ILogger logger, EventId eventId, string messa /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.LogWarning(exception, "Error while processing request from {Address}", address) - public static void LogWarning(this ILogger logger, Exception exception, string message, params object[] args) + public static void LogWarning(this ILogger logger, Exception? exception, string? message, params object?[] args) { logger.Log(LogLevel.Warning, exception, message, args); } @@ -223,7 +223,7 @@ public static void LogWarning(this ILogger logger, Exception exception, string m /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.LogWarning("Processing request from {Address}", address) - public static void LogWarning(this ILogger logger, string message, params object[] args) + public static void LogWarning(this ILogger logger, string? message, params object?[] args) { logger.Log(LogLevel.Warning, message, args); } @@ -239,7 +239,7 @@ public static void LogWarning(this ILogger logger, string message, params object /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.LogError(0, exception, "Error while processing request from {Address}", address) - public static void LogError(this ILogger logger, EventId eventId, Exception exception, string message, params object[] args) + public static void LogError(this ILogger logger, EventId eventId, Exception? exception, string? message, params object?[] args) { logger.Log(LogLevel.Error, eventId, exception, message, args); } @@ -252,7 +252,7 @@ public static void LogError(this ILogger logger, EventId eventId, Exception exce /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.LogError(0, "Processing request from {Address}", address) - public static void LogError(this ILogger logger, EventId eventId, string message, params object[] args) + public static void LogError(this ILogger logger, EventId eventId, string? message, params object?[] args) { logger.Log(LogLevel.Error, eventId, message, args); } @@ -265,7 +265,7 @@ public static void LogError(this ILogger logger, EventId eventId, string message /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.LogError(exception, "Error while processing request from {Address}", address) - public static void LogError(this ILogger logger, Exception exception, string message, params object[] args) + public static void LogError(this ILogger logger, Exception? exception, string? message, params object?[] args) { logger.Log(LogLevel.Error, exception, message, args); } @@ -277,7 +277,7 @@ public static void LogError(this ILogger logger, Exception exception, string mes /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.LogError("Processing request from {Address}", address) - public static void LogError(this ILogger logger, string message, params object[] args) + public static void LogError(this ILogger logger, string? message, params object?[] args) { logger.Log(LogLevel.Error, message, args); } @@ -293,7 +293,7 @@ public static void LogError(this ILogger logger, string message, params object[] /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.LogCritical(0, exception, "Error while processing request from {Address}", address) - public static void LogCritical(this ILogger logger, EventId eventId, Exception exception, string message, params object[] args) + public static void LogCritical(this ILogger logger, EventId eventId, Exception? exception, string? message, params object?[] args) { logger.Log(LogLevel.Critical, eventId, exception, message, args); } @@ -306,7 +306,7 @@ public static void LogCritical(this ILogger logger, EventId eventId, Exception e /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.LogCritical(0, "Processing request from {Address}", address) - public static void LogCritical(this ILogger logger, EventId eventId, string message, params object[] args) + public static void LogCritical(this ILogger logger, EventId eventId, string? message, params object?[] args) { logger.Log(LogLevel.Critical, eventId, message, args); } @@ -319,7 +319,7 @@ public static void LogCritical(this ILogger logger, EventId eventId, string mess /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.LogCritical(exception, "Error while processing request from {Address}", address) - public static void LogCritical(this ILogger logger, Exception exception, string message, params object[] args) + public static void LogCritical(this ILogger logger, Exception? exception, string? message, params object?[] args) { logger.Log(LogLevel.Critical, exception, message, args); } @@ -331,7 +331,7 @@ public static void LogCritical(this ILogger logger, Exception exception, string /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.LogCritical("Processing request from {Address}", address) - public static void LogCritical(this ILogger logger, string message, params object[] args) + public static void LogCritical(this ILogger logger, string? message, params object?[] args) { logger.Log(LogLevel.Critical, message, args); } @@ -343,7 +343,7 @@ public static void LogCritical(this ILogger logger, string message, params objec /// Entry will be written on this level. /// Format string of the log message. /// An object array that contains zero or more objects to format. - public static void Log(this ILogger logger, LogLevel logLevel, string message, params object[] args) + public static void Log(this ILogger logger, LogLevel logLevel, string? message, params object?[] args) { logger.Log(logLevel, 0, null, message, args); } @@ -356,7 +356,7 @@ public static void Log(this ILogger logger, LogLevel logLevel, string message, p /// The event id associated with the log. /// Format string of the log message. /// An object array that contains zero or more objects to format. - public static void Log(this ILogger logger, LogLevel logLevel, EventId eventId, string message, params object[] args) + public static void Log(this ILogger logger, LogLevel logLevel, EventId eventId, string? message, params object?[] args) { logger.Log(logLevel, eventId, null, message, args); } @@ -369,7 +369,7 @@ public static void Log(this ILogger logger, LogLevel logLevel, EventId eventId, /// The exception to log. /// Format string of the log message. /// An object array that contains zero or more objects to format. - public static void Log(this ILogger logger, LogLevel logLevel, Exception exception, string message, params object[] args) + public static void Log(this ILogger logger, LogLevel logLevel, Exception? exception, string? message, params object?[] args) { logger.Log(logLevel, 0, exception, message, args); } @@ -383,7 +383,7 @@ public static void Log(this ILogger logger, LogLevel logLevel, Exception excepti /// The exception to log. /// Format string of the log message. /// An object array that contains zero or more objects to format. - public static void Log(this ILogger logger, LogLevel logLevel, EventId eventId, Exception exception, string message, params object[] args) + public static void Log(this ILogger logger, LogLevel logLevel, EventId eventId, Exception? exception, string? message, params object?[] args) { if (logger == null) { @@ -410,7 +410,7 @@ public static void Log(this ILogger logger, LogLevel logLevel, EventId eventId, public static IDisposable BeginScope( this ILogger logger, string messageFormat, - params object[] args) + params object?[] args) { if (logger == null) { @@ -422,7 +422,7 @@ public static IDisposable BeginScope( //------------------------------------------HELPERS------------------------------------------// - private static string MessageFormatter(FormattedLogValues state, Exception error) + private static string MessageFormatter(FormattedLogValues state, Exception? error) { return state.ToString(); } diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/LoggerExternalScopeProvider.cs b/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/LoggerExternalScopeProvider.cs index bd6980a963b1f..0afed527c11bc 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/LoggerExternalScopeProvider.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/LoggerExternalScopeProvider.cs @@ -11,7 +11,7 @@ namespace Microsoft.Extensions.Logging /// public class LoggerExternalScopeProvider : IExternalScopeProvider { - private readonly AsyncLocal _currentScope = new AsyncLocal(); + private readonly AsyncLocal _currentScope = new AsyncLocal(); /// /// Creates a new . @@ -20,9 +20,9 @@ public LoggerExternalScopeProvider() { } /// - public void ForEachScope(Action callback, TState state) + public void ForEachScope(Action callback, TState state) { - void Report(Scope current) + void Report(Scope? current) { if (current == null) { @@ -35,9 +35,9 @@ void Report(Scope current) } /// - public IDisposable Push(object state) + public IDisposable Push(object? state) { - Scope parent = _currentScope.Value; + Scope? parent = _currentScope.Value; var newScope = new Scope(this, state, parent); _currentScope.Value = newScope; @@ -49,18 +49,18 @@ private class Scope : IDisposable private readonly LoggerExternalScopeProvider _provider; private bool _isDisposed; - internal Scope(LoggerExternalScopeProvider provider, object state, Scope parent) + internal Scope(LoggerExternalScopeProvider provider, object? state, Scope? parent) { _provider = provider; State = state; Parent = parent; } - public Scope Parent { get; } + public Scope? Parent { get; } - public object State { get; } + public object? State { get; } - public override string ToString() + public override string? ToString() { return State?.ToString(); } diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/LoggerMessage.cs b/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/LoggerMessage.cs index 27c7b5b75031c..2d9fa977ee725 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/LoggerMessage.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/LoggerMessage.cs @@ -127,7 +127,7 @@ public static Func DefineScopeThe event id /// The named format string /// A delegate which when invoked creates a log message. - public static Action Define(LogLevel logLevel, EventId eventId, string formatString) + public static Action Define(LogLevel logLevel, EventId eventId, string formatString) { LogValuesFormatter formatter = CreateLogValuesFormatter(formatString, expectedNamedParameterCount: 0); @@ -148,11 +148,11 @@ public static Action Define(LogLevel logLevel, EventId event /// The event id /// The named format string /// A delegate which when invoked creates a log message. - public static Action Define(LogLevel logLevel, EventId eventId, string formatString) + public static Action Define(LogLevel logLevel, EventId eventId, string formatString) { LogValuesFormatter formatter = CreateLogValuesFormatter(formatString, expectedNamedParameterCount: 1); - void Log(ILogger logger, T1 arg1, Exception exception) + void Log(ILogger logger, T1 arg1, Exception? exception) { logger.Log(logLevel, eventId, new LogValues(formatter, arg1), exception, LogValues.Callback); } @@ -175,11 +175,11 @@ void Log(ILogger logger, T1 arg1, Exception exception) /// The event id /// The named format string /// A delegate which when invoked creates a log message. - public static Action Define(LogLevel logLevel, EventId eventId, string formatString) + public static Action Define(LogLevel logLevel, EventId eventId, string formatString) { LogValuesFormatter formatter = CreateLogValuesFormatter(formatString, expectedNamedParameterCount: 2); - void Log(ILogger logger, T1 arg1, T2 arg2, Exception exception) + void Log(ILogger logger, T1 arg1, T2 arg2, Exception? exception) { logger.Log(logLevel, eventId, new LogValues(formatter, arg1, arg2), exception, LogValues.Callback); } @@ -203,11 +203,11 @@ void Log(ILogger logger, T1 arg1, T2 arg2, Exception exception) /// The event id /// The named format string /// A delegate which when invoked creates a log message. - public static Action Define(LogLevel logLevel, EventId eventId, string formatString) + public static Action Define(LogLevel logLevel, EventId eventId, string formatString) { LogValuesFormatter formatter = CreateLogValuesFormatter(formatString, expectedNamedParameterCount: 3); - void Log(ILogger logger, T1 arg1, T2 arg2, T3 arg3, Exception exception) + void Log(ILogger logger, T1 arg1, T2 arg2, T3 arg3, Exception? exception) { logger.Log(logLevel, eventId, new LogValues(formatter, arg1, arg2, arg3), exception, LogValues.Callback); } @@ -232,11 +232,11 @@ void Log(ILogger logger, T1 arg1, T2 arg2, T3 arg3, Exception exception) /// The event id /// The named format string /// A delegate which when invoked creates a log message. - public static Action Define(LogLevel logLevel, EventId eventId, string formatString) + public static Action Define(LogLevel logLevel, EventId eventId, string formatString) { LogValuesFormatter formatter = CreateLogValuesFormatter(formatString, expectedNamedParameterCount: 4); - void Log(ILogger logger, T1 arg1, T2 arg2, T3 arg3, T4 arg4, Exception exception) + void Log(ILogger logger, T1 arg1, T2 arg2, T3 arg3, T4 arg4, Exception? exception) { logger.Log(logLevel, eventId, new LogValues(formatter, arg1, arg2, arg3, arg4), exception, LogValues.Callback); } @@ -262,7 +262,7 @@ void Log(ILogger logger, T1 arg1, T2 arg2, T3 arg3, T4 arg4, Exception exception /// The event id /// The named format string /// A delegate which when invoked creates a log message. - public static Action Define(LogLevel logLevel, EventId eventId, string formatString) + public static Action Define(LogLevel logLevel, EventId eventId, string formatString) { LogValuesFormatter formatter = CreateLogValuesFormatter(formatString, expectedNamedParameterCount: 5); @@ -288,7 +288,7 @@ public static Action DefineThe event id /// The named format string /// A delegate which when invoked creates a log message. - public static Action Define(LogLevel logLevel, EventId eventId, string formatString) + public static Action Define(LogLevel logLevel, EventId eventId, string formatString) { LogValuesFormatter formatter = CreateLogValuesFormatter(formatString, expectedNamedParameterCount: 6); @@ -315,9 +315,9 @@ private static LogValuesFormatter CreateLogValuesFormatter(string formatString, return logValuesFormatter; } - private readonly struct LogValues : IReadOnlyList> + private readonly struct LogValues : IReadOnlyList> { - public static readonly Func Callback = (state, exception) => state.ToString(); + public static readonly Func Callback = (state, exception) => state.ToString(); private readonly LogValuesFormatter _formatter; @@ -326,13 +326,13 @@ public LogValues(LogValuesFormatter formatter) _formatter = formatter; } - public KeyValuePair this[int index] + public KeyValuePair this[int index] { get { if (index == 0) { - return new KeyValuePair("{OriginalFormat}", _formatter.OriginalFormat); + return new KeyValuePair("{OriginalFormat}", _formatter.OriginalFormat); } throw new IndexOutOfRangeException(nameof(index)); } @@ -340,7 +340,7 @@ public KeyValuePair this[int index] public int Count => 1; - public IEnumerator> GetEnumerator() + public IEnumerator> GetEnumerator() { yield return this[0]; } @@ -353,9 +353,9 @@ IEnumerator IEnumerable.GetEnumerator() } } - private readonly struct LogValues : IReadOnlyList> + private readonly struct LogValues : IReadOnlyList> { - public static readonly Func, Exception, string> Callback = (state, exception) => state.ToString(); + public static readonly Func, Exception?, string> Callback = (state, exception) => state.ToString(); private readonly LogValuesFormatter _formatter; private readonly T0 _value0; @@ -366,16 +366,16 @@ public LogValues(LogValuesFormatter formatter, T0 value0) _value0 = value0; } - public KeyValuePair this[int index] + public KeyValuePair this[int index] { get { switch (index) { case 0: - return new KeyValuePair(_formatter.ValueNames[0], _value0); + return new KeyValuePair(_formatter.ValueNames[0], _value0); case 1: - return new KeyValuePair("{OriginalFormat}", _formatter.OriginalFormat); + return new KeyValuePair("{OriginalFormat}", _formatter.OriginalFormat); default: throw new IndexOutOfRangeException(nameof(index)); } @@ -384,7 +384,7 @@ public KeyValuePair this[int index] public int Count => 2; - public IEnumerator> GetEnumerator() + public IEnumerator> GetEnumerator() { for (int i = 0; i < Count; ++i) { @@ -401,9 +401,9 @@ IEnumerator IEnumerable.GetEnumerator() } } - private readonly struct LogValues : IReadOnlyList> + private readonly struct LogValues : IReadOnlyList> { - public static readonly Func, Exception, string> Callback = (state, exception) => state.ToString(); + public static readonly Func, Exception?, string> Callback = (state, exception) => state.ToString(); private readonly LogValuesFormatter _formatter; private readonly T0 _value0; @@ -416,18 +416,18 @@ public LogValues(LogValuesFormatter formatter, T0 value0, T1 value1) _value1 = value1; } - public KeyValuePair this[int index] + public KeyValuePair this[int index] { get { switch (index) { case 0: - return new KeyValuePair(_formatter.ValueNames[0], _value0); + return new KeyValuePair(_formatter.ValueNames[0], _value0); case 1: - return new KeyValuePair(_formatter.ValueNames[1], _value1); + return new KeyValuePair(_formatter.ValueNames[1], _value1); case 2: - return new KeyValuePair("{OriginalFormat}", _formatter.OriginalFormat); + return new KeyValuePair("{OriginalFormat}", _formatter.OriginalFormat); default: throw new IndexOutOfRangeException(nameof(index)); } @@ -436,7 +436,7 @@ public KeyValuePair this[int index] public int Count => 3; - public IEnumerator> GetEnumerator() + public IEnumerator> GetEnumerator() { for (int i = 0; i < Count; ++i) { @@ -452,9 +452,9 @@ IEnumerator IEnumerable.GetEnumerator() } } - private readonly struct LogValues : IReadOnlyList> + private readonly struct LogValues : IReadOnlyList> { - public static readonly Func, Exception, string> Callback = (state, exception) => state.ToString(); + public static readonly Func, Exception?, string> Callback = (state, exception) => state.ToString(); private readonly LogValuesFormatter _formatter; private readonly T0 _value0; @@ -463,20 +463,20 @@ IEnumerator IEnumerable.GetEnumerator() public int Count => 4; - public KeyValuePair this[int index] + public KeyValuePair this[int index] { get { switch (index) { case 0: - return new KeyValuePair(_formatter.ValueNames[0], _value0); + return new KeyValuePair(_formatter.ValueNames[0], _value0); case 1: - return new KeyValuePair(_formatter.ValueNames[1], _value1); + return new KeyValuePair(_formatter.ValueNames[1], _value1); case 2: - return new KeyValuePair(_formatter.ValueNames[2], _value2); + return new KeyValuePair(_formatter.ValueNames[2], _value2); case 3: - return new KeyValuePair("{OriginalFormat}", _formatter.OriginalFormat); + return new KeyValuePair("{OriginalFormat}", _formatter.OriginalFormat); default: throw new IndexOutOfRangeException(nameof(index)); } @@ -493,7 +493,7 @@ public LogValues(LogValuesFormatter formatter, T0 value0, T1 value1, T2 value2) public override string ToString() => _formatter.Format(_value0, _value1, _value2); - public IEnumerator> GetEnumerator() + public IEnumerator> GetEnumerator() { for (int i = 0; i < Count; ++i) { @@ -507,9 +507,9 @@ IEnumerator IEnumerable.GetEnumerator() } } - private readonly struct LogValues : IReadOnlyList> + private readonly struct LogValues : IReadOnlyList> { - public static readonly Func, Exception, string> Callback = (state, exception) => state.ToString(); + public static readonly Func, Exception?, string> Callback = (state, exception) => state.ToString(); private readonly LogValuesFormatter _formatter; private readonly T0 _value0; @@ -519,22 +519,22 @@ IEnumerator IEnumerable.GetEnumerator() public int Count => 5; - public KeyValuePair this[int index] + public KeyValuePair this[int index] { get { switch (index) { case 0: - return new KeyValuePair(_formatter.ValueNames[0], _value0); + return new KeyValuePair(_formatter.ValueNames[0], _value0); case 1: - return new KeyValuePair(_formatter.ValueNames[1], _value1); + return new KeyValuePair(_formatter.ValueNames[1], _value1); case 2: - return new KeyValuePair(_formatter.ValueNames[2], _value2); + return new KeyValuePair(_formatter.ValueNames[2], _value2); case 3: - return new KeyValuePair(_formatter.ValueNames[3], _value3); + return new KeyValuePair(_formatter.ValueNames[3], _value3); case 4: - return new KeyValuePair("{OriginalFormat}", _formatter.OriginalFormat); + return new KeyValuePair("{OriginalFormat}", _formatter.OriginalFormat); default: throw new IndexOutOfRangeException(nameof(index)); } @@ -550,11 +550,11 @@ public LogValues(LogValuesFormatter formatter, T0 value0, T1 value1, T2 value2, _value3 = value3; } - private object[] ToArray() => new object[] { _value0, _value1, _value2, _value3 }; + private object?[] ToArray() => new object?[] { _value0, _value1, _value2, _value3 }; public override string ToString() => _formatter.Format(ToArray()); - public IEnumerator> GetEnumerator() + public IEnumerator> GetEnumerator() { for (int i = 0; i < Count; ++i) { @@ -568,9 +568,9 @@ IEnumerator IEnumerable.GetEnumerator() } } - private readonly struct LogValues : IReadOnlyList> + private readonly struct LogValues : IReadOnlyList> { - public static readonly Func, Exception, string> Callback = (state, exception) => state.ToString(); + public static readonly Func, Exception?, string> Callback = (state, exception) => state.ToString(); private readonly LogValuesFormatter _formatter; private readonly T0 _value0; @@ -581,24 +581,24 @@ IEnumerator IEnumerable.GetEnumerator() public int Count => 6; - public KeyValuePair this[int index] + public KeyValuePair this[int index] { get { switch (index) { case 0: - return new KeyValuePair(_formatter.ValueNames[0], _value0); + return new KeyValuePair(_formatter.ValueNames[0], _value0); case 1: - return new KeyValuePair(_formatter.ValueNames[1], _value1); + return new KeyValuePair(_formatter.ValueNames[1], _value1); case 2: - return new KeyValuePair(_formatter.ValueNames[2], _value2); + return new KeyValuePair(_formatter.ValueNames[2], _value2); case 3: - return new KeyValuePair(_formatter.ValueNames[3], _value3); + return new KeyValuePair(_formatter.ValueNames[3], _value3); case 4: - return new KeyValuePair(_formatter.ValueNames[4], _value4); + return new KeyValuePair(_formatter.ValueNames[4], _value4); case 5: - return new KeyValuePair("{OriginalFormat}", _formatter.OriginalFormat); + return new KeyValuePair("{OriginalFormat}", _formatter.OriginalFormat); default: throw new IndexOutOfRangeException(nameof(index)); } @@ -615,11 +615,11 @@ public LogValues(LogValuesFormatter formatter, T0 value0, T1 value1, T2 value2, _value4 = value4; } - private object[] ToArray() => new object[] { _value0, _value1, _value2, _value3, _value4 }; + private object?[] ToArray() => new object?[] { _value0, _value1, _value2, _value3, _value4 }; public override string ToString() => _formatter.Format(ToArray()); - public IEnumerator> GetEnumerator() + public IEnumerator> GetEnumerator() { for (int i = 0; i < Count; ++i) { @@ -633,9 +633,9 @@ IEnumerator IEnumerable.GetEnumerator() } } - private readonly struct LogValues : IReadOnlyList> + private readonly struct LogValues : IReadOnlyList> { - public static readonly Func, Exception, string> Callback = (state, exception) => state.ToString(); + public static readonly Func, Exception?, string> Callback = (state, exception) => state.ToString(); private readonly LogValuesFormatter _formatter; private readonly T0 _value0; @@ -647,26 +647,26 @@ IEnumerator IEnumerable.GetEnumerator() public int Count => 7; - public KeyValuePair this[int index] + public KeyValuePair this[int index] { get { switch (index) { case 0: - return new KeyValuePair(_formatter.ValueNames[0], _value0); + return new KeyValuePair(_formatter.ValueNames[0], _value0); case 1: - return new KeyValuePair(_formatter.ValueNames[1], _value1); + return new KeyValuePair(_formatter.ValueNames[1], _value1); case 2: - return new KeyValuePair(_formatter.ValueNames[2], _value2); + return new KeyValuePair(_formatter.ValueNames[2], _value2); case 3: - return new KeyValuePair(_formatter.ValueNames[3], _value3); + return new KeyValuePair(_formatter.ValueNames[3], _value3); case 4: - return new KeyValuePair(_formatter.ValueNames[4], _value4); + return new KeyValuePair(_formatter.ValueNames[4], _value4); case 5: - return new KeyValuePair(_formatter.ValueNames[5], _value5); + return new KeyValuePair(_formatter.ValueNames[5], _value5); case 6: - return new KeyValuePair("{OriginalFormat}", _formatter.OriginalFormat); + return new KeyValuePair("{OriginalFormat}", _formatter.OriginalFormat); default: throw new IndexOutOfRangeException(nameof(index)); } @@ -684,11 +684,11 @@ public LogValues(LogValuesFormatter formatter, T0 value0, T1 value1, T2 value2, _value5 = value5; } - private object[] ToArray() => new object[] { _value0, _value1, _value2, _value3, _value4, _value5 }; + private object?[] ToArray() => new object?[] { _value0, _value1, _value2, _value3, _value4, _value5 }; public override string ToString() => _formatter.Format(ToArray()); - public IEnumerator> GetEnumerator() + public IEnumerator> GetEnumerator() { for (int i = 0; i < Count; ++i) { diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/LoggerT.cs b/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/LoggerT.cs index 59f2f043cd181..bea9a8bdeff70 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/LoggerT.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/LoggerT.cs @@ -42,7 +42,7 @@ bool ILogger.IsEnabled(LogLevel logLevel) } /// - void ILogger.Log(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func formatter) + void ILogger.Log(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func formatter) { _logger.Log(logLevel, eventId, state, exception, formatter); } diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/Microsoft.Extensions.Logging.Abstractions.csproj b/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/Microsoft.Extensions.Logging.Abstractions.csproj index 457b3e9b8c7c7..f110d08801ab1 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/Microsoft.Extensions.Logging.Abstractions.csproj +++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/Microsoft.Extensions.Logging.Abstractions.csproj @@ -1,9 +1,13 @@ - netstandard2.0;net461 + $(NetCoreAppCurrent);netstandard2.0;net461 + true true true + + false + enable diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/NullLogger.cs b/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/NullLogger.cs index f8bdacdc112d8..694ba8de9b1f6 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/NullLogger.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/NullLogger.cs @@ -32,7 +32,7 @@ public bool IsEnabled(LogLevel logLevel) } /// - public void Log(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func formatter) + public void Log(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func formatter) { } } diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/NullLoggerT.cs b/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/NullLoggerT.cs index 8e3a118575f35..1d228a33669f9 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/NullLoggerT.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/NullLoggerT.cs @@ -30,8 +30,8 @@ public void Log( LogLevel logLevel, EventId eventId, TState state, - Exception exception, - Func formatter) + Exception? exception, + Func formatter) { } From 88ecbab85beead9c7d9406ee2f3ea468b1d4cd1e Mon Sep 17 00:00:00 2001 From: Anton Lapounov Date: Tue, 17 Nov 2020 21:46:24 -0800 Subject: [PATCH 08/19] Fix decoding GC information in R2RDump (#44682) --- .../Amd64/GcInfo.cs | 29 +++++++++++-------- src/coreclr/src/tools/r2rdump/TextDumper.cs | 1 + 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/coreclr/src/tools/aot/ILCompiler.Reflection.ReadyToRun/Amd64/GcInfo.cs b/src/coreclr/src/tools/aot/ILCompiler.Reflection.ReadyToRun/Amd64/GcInfo.cs index 1f970811dbf46..63c1024b25168 100644 --- a/src/coreclr/src/tools/aot/ILCompiler.Reflection.ReadyToRun/Amd64/GcInfo.cs +++ b/src/coreclr/src/tools/aot/ILCompiler.Reflection.ReadyToRun/Amd64/GcInfo.cs @@ -103,7 +103,6 @@ public GcInfo(byte[] image, int offset, Machine machine, ushort majorVersion) Version = ReadyToRunVersionToGcInfoVersion(majorVersion); int bitOffset = offset * 8; - int startBitOffset = bitOffset; ParseHeaderFlags(image, ref bitOffset); @@ -185,17 +184,23 @@ public GcInfo(byte[] image, int offset, Machine machine, ushort majorVersion) SlotTable = new GcSlotTable(image, machine, _gcInfoTypes, ref bitOffset); - // Try partially interruptible first - if (NumSafePoints > 0) + if (SlotTable.NumSlots > 0) { - LiveSlotsAtSafepoints = GetLiveSlotsAtSafepoints(image, ref bitOffset); - } - else - { - Transitions = GetTransitions(image, ref bitOffset); + if (NumSafePoints > 0) + { + // Partially interruptible code + LiveSlotsAtSafepoints = GetLiveSlotsAtSafepoints(image, ref bitOffset); + } + else + { + // Fully interruptible code + Debug.Assert(NumInterruptibleRanges > 0); + Transitions = GetTransitions(image, ref bitOffset); + } } - Size = bitOffset - startBitOffset; + int nextByteOffset = (bitOffset + 7) >> 3; + Size = nextByteOffset - offset; } public override string ToString() @@ -482,7 +487,7 @@ private List> GetLiveSlotsAtSafepoints(byte[] image, ref int bi /// /// based on end of GcInfoDecoder::EnumerateLiveSlots and GcInfoEncoder::Build /// - public Dictionary> GetTransitions(byte[] image, ref int bitOffset) + private Dictionary> GetTransitions(byte[] image, ref int bitOffset) { int totalInterruptibleLength = 0; if (NumInterruptibleRanges == 0) @@ -511,8 +516,8 @@ public Dictionary> GetTransitions(byte[] image, ref chunkPointers[i] = NativeReader.ReadBits(image, numBitsPerPointer, ref bitOffset); } - // Offset to m_Info2 containing all the info on register liveness - int info2Offset = (int)Math.Ceiling(bitOffset / 8.0) * 8; + // Offset to m_Info2 containing all the info on register liveness, which starts at the next byte + int info2Offset = (bitOffset + 7) & ~7; List transitions = new List(); bool[] liveAtEnd = new bool[SlotTable.NumTracked]; // true if slot is live at the end of the chunk diff --git a/src/coreclr/src/tools/r2rdump/TextDumper.cs b/src/coreclr/src/tools/r2rdump/TextDumper.cs index f03b65ea8bc9b..a292d23792725 100644 --- a/src/coreclr/src/tools/r2rdump/TextDumper.cs +++ b/src/coreclr/src/tools/r2rdump/TextDumper.cs @@ -161,6 +161,7 @@ internal override void DumpMethod(ReadyToRunMethod method) if (_options.Raw) { + // TODO: Output RVAs for consistency with other DumpBytes calls DumpBytes(gcInfo.Offset, (uint)gcInfo.Size, "", false); } } From 30769e8f31b20be10ca26e27ec279cd4e79412b9 Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Wed, 18 Nov 2020 11:49:34 +0100 Subject: [PATCH 09/19] [master] Update dependencies from dotnet/arcade (#44835) * Update dependencies from https://github.com/dotnet/arcade build 20201113.2 Microsoft.DotNet.Build.Tasks.Archives , Microsoft.DotNet.Build.Tasks.Feed , Microsoft.DotNet.Build.Tasks.Installers , Microsoft.DotNet.Build.Tasks.Packaging , Microsoft.DotNet.Build.Tasks.SharedFramework.Sdk , Microsoft.DotNet.Build.Tasks.TargetFramework.Sdk , Microsoft.DotNet.CodeAnalysis , Microsoft.DotNet.GenAPI , Microsoft.DotNet.GenFacades , Microsoft.DotNet.XUnitExtensions , Microsoft.DotNet.Arcade.Sdk , Microsoft.DotNet.Helix.Sdk , Microsoft.DotNet.RemoteExecutor , Microsoft.DotNet.VersionTools.Tasks , Microsoft.DotNet.XUnitConsoleRunner , Microsoft.DotNet.ApiCompat From Version 6.0.0-beta.20552.5 -> To Version 6.0.0-beta.20563.2 * Update global.json Co-authored-by: dotnet-maestro[bot] Co-authored-by: Viktor Hofer Co-authored-by: Juan Hoyos --- .config/dotnet-tools.json | 2 +- eng/Version.Details.xml | 60 ++++++++--------- eng/Versions.props | 22 +++--- eng/common/cross/armel/armel.jessie.patch | 43 ++++++++++++ eng/common/cross/build-rootfs.sh | 8 ++- eng/common/performance/crossgen_perf.proj | 4 +- eng/common/post-build/publish-using-darc.ps1 | 6 ++ eng/common/templates/job/job.yml | 10 --- .../templates/post-build/post-build.yml | 67 ++----------------- global.json | 8 +-- 10 files changed, 108 insertions(+), 122 deletions(-) create mode 100644 eng/common/cross/armel/armel.jessie.patch diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 551fc37d6c4d0..4c7efe1d75452 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -27,4 +27,4 @@ ] } } -} \ No newline at end of file +} diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index a5aa361e57f06..9d3af614d4e46 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -10,69 +10,69 @@ - + https://github.com/dotnet/arcade - 72b28b7e023d4c3fffa0a0b9748a7d4e8cc799be + 3fea3a1b584e3ddd9145d80a0cfb51e3e658c464 - + https://github.com/dotnet/arcade - 8fb2f6133d86c84ba1e560027e2f3288ec755ba5 + 3fea3a1b584e3ddd9145d80a0cfb51e3e658c464 - + https://github.com/dotnet/arcade - 72b28b7e023d4c3fffa0a0b9748a7d4e8cc799be + 3fea3a1b584e3ddd9145d80a0cfb51e3e658c464 - + https://github.com/dotnet/arcade - 72b28b7e023d4c3fffa0a0b9748a7d4e8cc799be + 3fea3a1b584e3ddd9145d80a0cfb51e3e658c464 - + https://github.com/dotnet/arcade - 72b28b7e023d4c3fffa0a0b9748a7d4e8cc799be + 3fea3a1b584e3ddd9145d80a0cfb51e3e658c464 - + https://github.com/dotnet/arcade - 72b28b7e023d4c3fffa0a0b9748a7d4e8cc799be + 3fea3a1b584e3ddd9145d80a0cfb51e3e658c464 - + https://github.com/dotnet/arcade - 72b28b7e023d4c3fffa0a0b9748a7d4e8cc799be + 3fea3a1b584e3ddd9145d80a0cfb51e3e658c464 https://github.com/dotnet/arcade 94dab3b0a2c74c53d7552c6985eafea4629d0eb9 - + https://github.com/dotnet/arcade - 72b28b7e023d4c3fffa0a0b9748a7d4e8cc799be + 3fea3a1b584e3ddd9145d80a0cfb51e3e658c464 - + https://github.com/dotnet/arcade - 9a1e99f6c326a67297b074453e96bdd0cb36e7e3 + 3fea3a1b584e3ddd9145d80a0cfb51e3e658c464 - + https://github.com/dotnet/arcade - 72b28b7e023d4c3fffa0a0b9748a7d4e8cc799be + 3fea3a1b584e3ddd9145d80a0cfb51e3e658c464 - + https://github.com/dotnet/arcade - 72b28b7e023d4c3fffa0a0b9748a7d4e8cc799be + 3fea3a1b584e3ddd9145d80a0cfb51e3e658c464 - + https://github.com/dotnet/arcade - 72b28b7e023d4c3fffa0a0b9748a7d4e8cc799be + 3fea3a1b584e3ddd9145d80a0cfb51e3e658c464 - + https://github.com/dotnet/arcade - 72b28b7e023d4c3fffa0a0b9748a7d4e8cc799be + 3fea3a1b584e3ddd9145d80a0cfb51e3e658c464 - + https://github.com/dotnet/arcade - 72b28b7e023d4c3fffa0a0b9748a7d4e8cc799be + 3fea3a1b584e3ddd9145d80a0cfb51e3e658c464 - + https://github.com/dotnet/arcade - 72b28b7e023d4c3fffa0a0b9748a7d4e8cc799be + 3fea3a1b584e3ddd9145d80a0cfb51e3e658c464 https://dev.azure.com/dnceng/internal/_git/dotnet-optimization diff --git a/eng/Versions.props b/eng/Versions.props index d5760260d6865..2e4367be54189 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -53,18 +53,18 @@ 6.0.0-preview1.20513.4 3.8.0-4.20503.2 - 6.0.0-beta.20552.5 - 6.0.0-beta.20552.5 - 6.0.0-beta.20552.5 - 6.0.0-beta.20552.5 - 6.0.0-beta.20552.5 - 6.0.0-beta.20552.5 - 2.5.1-beta.20552.5 + 6.0.0-beta.20563.2 + 6.0.0-beta.20563.2 + 6.0.0-beta.20563.2 + 6.0.0-beta.20563.2 + 6.0.0-beta.20563.2 + 6.0.0-beta.20563.2 + 2.5.1-beta.20563.2 6.0.0-beta.20567.2 - 6.0.0-beta.20552.5 - 6.0.0-beta.20562.3 - 6.0.0-beta.20552.5 - 6.0.0-beta.20552.5 + 6.0.0-beta.20563.2 + 6.0.0-beta.20563.2 + 6.0.0-beta.20563.2 + 6.0.0-beta.20563.2 5.0.0-rc.1.20451.14 6.0.0-alpha.1.20501.4 diff --git a/eng/common/cross/armel/armel.jessie.patch b/eng/common/cross/armel/armel.jessie.patch new file mode 100644 index 0000000000000..2d2615619351f --- /dev/null +++ b/eng/common/cross/armel/armel.jessie.patch @@ -0,0 +1,43 @@ +diff -u -r a/usr/include/urcu/uatomic/generic.h b/usr/include/urcu/uatomic/generic.h +--- a/usr/include/urcu/uatomic/generic.h 2014-10-22 15:00:58.000000000 -0700 ++++ b/usr/include/urcu/uatomic/generic.h 2020-10-30 21:38:28.550000000 -0700 +@@ -69,10 +69,10 @@ + #endif + #ifdef UATOMIC_HAS_ATOMIC_SHORT + case 2: +- return __sync_val_compare_and_swap_2(addr, old, _new); ++ return __sync_val_compare_and_swap_2((uint16_t*) addr, old, _new); + #endif + case 4: +- return __sync_val_compare_and_swap_4(addr, old, _new); ++ return __sync_val_compare_and_swap_4((uint32_t*) addr, old, _new); + #if (CAA_BITS_PER_LONG == 64) + case 8: + return __sync_val_compare_and_swap_8(addr, old, _new); +@@ -109,7 +109,7 @@ + return; + #endif + case 4: +- __sync_and_and_fetch_4(addr, val); ++ __sync_and_and_fetch_4((uint32_t*) addr, val); + return; + #if (CAA_BITS_PER_LONG == 64) + case 8: +@@ -148,7 +148,7 @@ + return; + #endif + case 4: +- __sync_or_and_fetch_4(addr, val); ++ __sync_or_and_fetch_4((uint32_t*) addr, val); + return; + #if (CAA_BITS_PER_LONG == 64) + case 8: +@@ -187,7 +187,7 @@ + return __sync_add_and_fetch_2(addr, val); + #endif + case 4: +- return __sync_add_and_fetch_4(addr, val); ++ return __sync_add_and_fetch_4((uint32_t*) addr, val); + #if (CAA_BITS_PER_LONG == 64) + case 8: + return __sync_add_and_fetch_8(addr, val); diff --git a/eng/common/cross/build-rootfs.sh b/eng/common/cross/build-rootfs.sh index 575eee9fa1903..6d59e181c8fd9 100755 --- a/eng/common/cross/build-rootfs.sh +++ b/eng/common/cross/build-rootfs.sh @@ -336,7 +336,7 @@ elif [[ -n $__CodeName ]]; then chroot $__RootfsDir apt-get -f -y install chroot $__RootfsDir apt-get -y install $__UbuntuPackages chroot $__RootfsDir symlinks -cr /usr - chroot $__RootfsDir apt clean + chroot $__RootfsDir apt-get clean if [ $__SkipUnmount == 0 ]; then umount $__RootfsDir/* || true @@ -348,6 +348,12 @@ elif [[ -n $__CodeName ]]; then patch -p1 < $__CrossDir/$__BuildArch/trusty-lttng-2.4.patch popd fi + + if [[ "$__BuildArch" == "armel" && "$__CodeName" == "jessie" ]]; then + pushd $__RootfsDir + patch -p1 < $__CrossDir/$__BuildArch/armel.jessie.patch + popd + fi elif [[ "$__Tizen" == "tizen" ]]; then ROOTFS_DIR=$__RootfsDir $__CrossDir/$__BuildArch/tizen-build-rootfs.sh else diff --git a/eng/common/performance/crossgen_perf.proj b/eng/common/performance/crossgen_perf.proj index 48455e7aa8045..cf09e40578a5b 100644 --- a/eng/common/performance/crossgen_perf.proj +++ b/eng/common/performance/crossgen_perf.proj @@ -69,7 +69,7 @@ $(WorkItemDirectory) $(Python) $(CrossgenDirectory)pre.py crossgen --core-root $(CoreRoot) --single %(Identity) - $(Python) $(CrossgenDirectory)test.py sod --scenario-name "Crossgen %(Identity) Size" --dirs ./crossgen.out/ + $(Python) $(CrossgenDirectory)test.py sod --scenario-name "Crossgen %(Identity) Size" --dirs ./crossgen/ $(Python) $(CrossgenDirectory)post.py @@ -78,7 +78,7 @@ $(WorkItemDirectory) $(Python) $(Crossgen2Directory)pre.py crossgen2 --core-root $(CoreRoot) --single %(Identity) - $(Python) $(Crossgen2Directory)test.py sod --scenario-name "Crossgen2 %(Identity) Size" --dirs ./crossgen.out/ + $(Python) $(Crossgen2Directory)test.py sod --scenario-name "Crossgen2 %(Identity) Size" --dirs ./crossgen/ $(Python) $(Crossgen2Directory)post.py diff --git a/eng/common/post-build/publish-using-darc.ps1 b/eng/common/post-build/publish-using-darc.ps1 index 650b13b089b2f..31cf276741716 100644 --- a/eng/common/post-build/publish-using-darc.ps1 +++ b/eng/common/post-build/publish-using-darc.ps1 @@ -10,6 +10,7 @@ param( [Parameter(Mandatory=$false)][string] $EnableNugetValidation, [Parameter(Mandatory=$false)][string] $PublishInstallersAndChecksums, [Parameter(Mandatory=$false)][string] $ArtifactsPublishingAdditionalParameters, + [Parameter(Mandatory=$false)][string] $SymbolPublishingAdditionalParameters, [Parameter(Mandatory=$false)][string] $SigningValidationAdditionalParameters ) @@ -25,6 +26,11 @@ try { $optionalParams.Add($ArtifactsPublishingAdditionalParameters) | Out-Null } + if ("" -ne $SymbolPublishingAdditionalParameters) { + $optionalParams.Add("symbol-publishing-parameters") | Out-Null + $optionalParams.Add($SymbolPublishingAdditionalParameters) | Out-Null + } + if ("false" -eq $WaitPublishingFinish) { $optionalParams.Add("--no-wait") | Out-Null } diff --git a/eng/common/templates/job/job.yml b/eng/common/templates/job/job.yml index 06048c27907b2..8669679348024 100644 --- a/eng/common/templates/job/job.yml +++ b/eng/common/templates/job/job.yml @@ -24,7 +24,6 @@ parameters: enablePublishBuildAssets: false enablePublishTestResults: false enablePublishUsingPipelines: false - useBuildManifest: false mergeTestResults: false testRunTitle: '' testResultsFormat: '' @@ -243,12 +242,3 @@ jobs: ArtifactName: AssetManifests continueOnError: ${{ parameters.continueOnError }} condition: and(succeeded(), eq(variables['_DotNetPublishToBlobFeed'], 'true')) - - - ${{ if eq(parameters.useBuildManifest, true) }}: - - task: PublishBuildArtifacts@1 - displayName: Publish Build Manifest - inputs: - PathToPublish: '$(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)/manifest.props' - PublishLocation: Container - ArtifactName: BuildManifests - continueOnError: ${{ parameters.continueOnError }} diff --git a/eng/common/templates/post-build/post-build.yml b/eng/common/templates/post-build/post-build.yml index 761fb1a29c358..41f2d96a608cf 100644 --- a/eng/common/templates/post-build/post-build.yml +++ b/eng/common/templates/post-build/post-build.yml @@ -32,7 +32,6 @@ parameters: symbolPublishingAdditionalParameters: '' artifactsPublishingAdditionalParameters: '' signingValidationAdditionalParameters: '' - useBuildManifest: false # Which stages should finish execution before post-build stages start validateDependsOn: @@ -54,9 +53,6 @@ parameters: NETCoreExperimentalChannelId: 562 NetEngServicesIntChannelId: 678 NetEngServicesProdChannelId: 679 - Net5Preview8ChannelId: 1155 - Net5RC1ChannelId: 1157 - Net5RC2ChannelId: 1329 NetCoreSDK313xxChannelId: 759 NetCoreSDK313xxInternalChannelId: 760 NetCoreSDK314xxChannelId: 921 @@ -94,7 +90,7 @@ stages: inputs: filePath: $(Build.SourcesDirectory)/eng/common/post-build/check-channel-consistency.ps1 arguments: -PromoteToChannels "$(TargetChannels)" - -AvailableChannelIds ${{parameters.NetEngLatestChannelId}},${{parameters.NetEngValidationChannelId}},${{parameters.NetDev5ChannelId}},${{parameters.NetDev6ChannelId}},${{parameters.GeneralTestingChannelId}},${{parameters.NETCoreToolingDevChannelId}},${{parameters.NETCoreToolingReleaseChannelId}},${{parameters.NETInternalToolingChannelId}},${{parameters.NETCoreExperimentalChannelId}},${{parameters.NetEngServicesIntChannelId}},${{parameters.NetEngServicesProdChannelId}},${{parameters.Net5Preview8ChannelId}},${{parameters.Net5RC1ChannelId}},${{parameters.Net5RC2ChannelId}},${{parameters.NetCoreSDK313xxChannelId}},${{parameters.NetCoreSDK313xxInternalChannelId}},${{parameters.NetCoreSDK314xxChannelId}},${{parameters.NetCoreSDK314xxInternalChannelId}},${{parameters.VS166ChannelId}},${{parameters.VS167ChannelId}},${{parameters.VS168ChannelId}},${{parameters.VSMasterChannelId}} + -AvailableChannelIds ${{parameters.NetEngLatestChannelId}},${{parameters.NetEngValidationChannelId}},${{parameters.NetDev5ChannelId}},${{parameters.NetDev6ChannelId}},${{parameters.GeneralTestingChannelId}},${{parameters.NETCoreToolingDevChannelId}},${{parameters.NETCoreToolingReleaseChannelId}},${{parameters.NETInternalToolingChannelId}},${{parameters.NETCoreExperimentalChannelId}},${{parameters.NetEngServicesIntChannelId}},${{parameters.NetEngServicesProdChannelId}},${{parameters.NetCoreSDK313xxChannelId}},${{parameters.NetCoreSDK313xxInternalChannelId}},${{parameters.NetCoreSDK314xxChannelId}},${{parameters.NetCoreSDK314xxInternalChannelId}},${{parameters.VS166ChannelId}},${{parameters.VS167ChannelId}},${{parameters.VS168ChannelId}},${{parameters.VSMasterChannelId}} - job: displayName: NuGet Validation @@ -142,16 +138,6 @@ stages: pool: vmImage: 'windows-2019' steps: - - ${{ if eq(parameters.useBuildManifest, true) }}: - - task: DownloadBuildArtifacts@0 - displayName: Download build manifest - inputs: - buildType: specific - buildVersionToDownload: specific - project: $(AzDOProjectName) - pipeline: $(AzDOPipelineId) - buildId: $(AzDOBuildId) - artifactName: BuildManifests - task: DownloadBuildArtifacts@0 displayName: Download Package Artifacts inputs: @@ -253,6 +239,7 @@ stages: - job: displayName: Publish Using Darc dependsOn: setupMaestroVars + timeoutInMinutes: 120 variables: - name: BARBuildId value: $[ dependencies.setupMaestroVars.outputs['setReleaseVars.BARBuildId'] ] @@ -269,6 +256,8 @@ stages: -MaestroToken '$(MaestroApiAccessToken)' -WaitPublishingFinish ${{ parameters.waitPublishingFinish }} -PublishInstallersAndChecksums ${{ parameters.publishInstallersAndChecksums }} + -ArtifactsPublishingAdditionalParameters '${{ parameters.artifactsPublishingAdditionalParameters }}' + -SymbolPublishingAdditionalParameters '${{ parameters.symbolPublishingAdditionalParameters }}' - ${{ if and(le(parameters.publishingInfraVersion, 2), eq(parameters.inline, 'true')) }}: - template: \eng\common\templates\post-build\channels\generic-public-channel.yml @@ -303,54 +292,6 @@ stages: shippingFeed: 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json' symbolsFeed: 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6-symbols/nuget/v3/index.json' - - template: \eng\common\templates\post-build\channels\generic-internal-channel.yml - parameters: - BARBuildId: ${{ parameters.BARBuildId }} - PromoteToChannelIds: ${{ parameters.PromoteToChannelIds }} - artifactsPublishingAdditionalParameters: ${{ parameters.artifactsPublishingAdditionalParameters }} - dependsOn: ${{ parameters.publishDependsOn }} - publishInstallersAndChecksums: ${{ parameters.publishInstallersAndChecksums }} - symbolPublishingAdditionalParameters: ${{ parameters.symbolPublishingAdditionalParameters }} - stageName: 'Net5_Preview8_Publish' - channelName: '.NET 5 Preview 8' - akaMSChannelName: 'net5/preview8' - channelId: ${{ parameters.Net5Preview8ChannelId }} - transportFeed: 'https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet5-internal-transport/nuget/v3/index.json' - shippingFeed: 'https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet5-internal/nuget/v3/index.json' - symbolsFeed: 'https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet5-internal-symbols/nuget/v3/index.json' - - - template: \eng\common\templates\post-build\channels\generic-public-channel.yml - parameters: - BARBuildId: ${{ parameters.BARBuildId }} - PromoteToChannelIds: ${{ parameters.PromoteToChannelIds }} - artifactsPublishingAdditionalParameters: ${{ parameters.artifactsPublishingAdditionalParameters }} - dependsOn: ${{ parameters.publishDependsOn }} - publishInstallersAndChecksums: ${{ parameters.publishInstallersAndChecksums }} - symbolPublishingAdditionalParameters: ${{ parameters.symbolPublishingAdditionalParameters }} - stageName: 'Net5_RC1_Publish' - channelName: '.NET 5 RC 1' - akaMSChannelName: 'net5/rc1' - channelId: ${{ parameters.Net5RC1ChannelId }} - transportFeed: 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5-transport/nuget/v3/index.json' - shippingFeed: 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5/nuget/v3/index.json' - symbolsFeed: 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5-symbols/nuget/v3/index.json' - - - template: \eng\common\templates\post-build\channels\generic-public-channel.yml - parameters: - BARBuildId: ${{ parameters.BARBuildId }} - PromoteToChannelIds: ${{ parameters.PromoteToChannelIds }} - artifactsPublishingAdditionalParameters: ${{ parameters.artifactsPublishingAdditionalParameters }} - dependsOn: ${{ parameters.publishDependsOn }} - publishInstallersAndChecksums: ${{ parameters.publishInstallersAndChecksums }} - symbolPublishingAdditionalParameters: ${{ parameters.symbolPublishingAdditionalParameters }} - stageName: 'Net5_RC2_Publish' - channelName: '.NET 5 RC 2' - akaMSChannelName: 'net5/rc2' - channelId: ${{ parameters.Net5RC2ChannelId }} - transportFeed: 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5-transport/nuget/v3/index.json' - shippingFeed: 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5/nuget/v3/index.json' - symbolsFeed: 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5-symbols/nuget/v3/index.json' - - template: \eng\common\templates\post-build\channels\generic-public-channel.yml parameters: BARBuildId: ${{ parameters.BARBuildId }} diff --git a/global.json b/global.json index a67f1ea5bbd77..b08f3b4bc1703 100644 --- a/global.json +++ b/global.json @@ -12,10 +12,10 @@ "python3": "3.7.1" }, "msbuild-sdks": { - "Microsoft.DotNet.Build.Tasks.TargetFramework.Sdk": "6.0.0-beta.20554.1", - "Microsoft.DotNet.Arcade.Sdk": "6.0.0-beta.20552.5", - "Microsoft.DotNet.Build.Tasks.SharedFramework.Sdk": "6.0.0-beta.20552.5", - "Microsoft.DotNet.Helix.Sdk": "6.0.0-beta.20560.1", + "Microsoft.DotNet.Build.Tasks.TargetFramework.Sdk": "6.0.0-beta.20563.2", + "Microsoft.DotNet.Arcade.Sdk": "6.0.0-beta.20563.2", + "Microsoft.DotNet.Build.Tasks.SharedFramework.Sdk": "6.0.0-beta.20563.2", + "Microsoft.DotNet.Helix.Sdk": "6.0.0-beta.20563.2", "Microsoft.DotNet.SharedFramework.Sdk": "6.0.0-beta.20552.5", "Microsoft.NET.Sdk.IL": "6.0.0-alpha.1.20557.2", "Microsoft.Build.NoTargets": "2.0.1", From 65efefda7ccac49fc0b66b60d089ca67ac6e484a Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Wed, 18 Nov 2020 13:30:04 +0100 Subject: [PATCH 10/19] few minor MemoryCache perf improvements (#44797) * make ValidateCacheKey and CheckDisposed inlinable by moving throws to separate methods * ensure that the check for expiration does not require a method call for the most common case * update the last expiration scan when the Scan Task starts actual work * Apply suggestions from code review Co-authored-by: Stephen Toub --- .../src/MemoryCache.cs | 56 +++++++++++-------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.Caching.Memory/src/MemoryCache.cs b/src/libraries/Microsoft.Extensions.Caching.Memory/src/MemoryCache.cs index a3d22ca18e2dc..55dd1217e65f9 100644 --- a/src/libraries/Microsoft.Extensions.Caching.Memory/src/MemoryCache.cs +++ b/src/libraries/Microsoft.Extensions.Caching.Memory/src/MemoryCache.cs @@ -5,6 +5,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; +using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Internal; @@ -230,44 +231,45 @@ private void SetEntry(CacheEntry entry) } } - StartScanForExpiredItems(utcNow); + StartScanForExpiredItemsIfNeeded(utcNow); } /// public bool TryGetValue(object key, out object result) { ValidateCacheKey(key); - CheckDisposed(); - result = null; DateTimeOffset utcNow = _options.Clock.UtcNow; - bool found = false; if (_entries.TryGetValue(key, out CacheEntry entry)) { // Check if expired due to expiration tokens, timers, etc. and if so, remove it. // Allow a stale Replaced value to be returned due to concurrent calls to SetExpired during SetEntry. - if (entry.CheckExpired(utcNow) && entry.EvictionReason != EvictionReason.Replaced) + if (!entry.CheckExpired(utcNow) || entry.EvictionReason == EvictionReason.Replaced) { - // TODO: For efficiency queue this up for batch removal - RemoveEntry(entry); - } - else - { - found = true; entry.LastAccessed = utcNow; result = entry.Value; // When this entry is retrieved in the scope of creating another entry, // that entry needs a copy of these expiration tokens. entry.PropagateOptions(CacheEntryHelper.Current); + + StartScanForExpiredItemsIfNeeded(utcNow); + + return true; + } + else + { + // TODO: For efficiency queue this up for batch removal + RemoveEntry(entry); } } - StartScanForExpiredItems(utcNow); + StartScanForExpiredItemsIfNeeded(utcNow); - return found; + result = null; + return false; } /// @@ -287,7 +289,7 @@ public void Remove(object key) entry.InvokeEvictionCallbacks(); } - StartScanForExpiredItems(); + StartScanForExpiredItemsIfNeeded(_options.Clock.UtcNow); } private void RemoveEntry(CacheEntry entry) @@ -306,18 +308,22 @@ private void EntryExpired(CacheEntry entry) { // TODO: For efficiency consider processing these expirations in batches. RemoveEntry(entry); - StartScanForExpiredItems(); + StartScanForExpiredItemsIfNeeded(_options.Clock.UtcNow); } // Called by multiple actions to see how long it's been since we last checked for expired items. // If sufficient time has elapsed then a scan is initiated on a background task. - private void StartScanForExpiredItems(DateTimeOffset? utcNow = null) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private void StartScanForExpiredItemsIfNeeded(DateTimeOffset utcNow) { - // Since fetching time is expensive, minimize it in the hot paths - DateTimeOffset now = utcNow ?? _options.Clock.UtcNow; - if (_options.ExpirationScanFrequency < now - _lastExpirationScan) + if (_options.ExpirationScanFrequency < utcNow - _lastExpirationScan) { - _lastExpirationScan = now; + ScheduleTask(utcNow); + } + + void ScheduleTask(DateTimeOffset utcNow) + { + _lastExpirationScan = utcNow; Task.Factory.StartNew(state => ScanForExpiredItems((MemoryCache)state), this, CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default); } @@ -325,7 +331,7 @@ private void StartScanForExpiredItems(DateTimeOffset? utcNow = null) private static void ScanForExpiredItems(MemoryCache cache) { - DateTimeOffset now = cache._options.Clock.UtcNow; + DateTimeOffset now = cache._lastExpirationScan = cache._options.Clock.UtcNow; foreach (CacheEntry entry in cache._entries.Values) { if (entry.CheckExpired(now)) @@ -500,16 +506,20 @@ private void CheckDisposed() { if (_disposed) { - throw new ObjectDisposedException(typeof(MemoryCache).FullName); + Throw(); } + + static void Throw() => throw new ObjectDisposedException(typeof(MemoryCache).FullName); } private static void ValidateCacheKey(object key) { if (key == null) { - throw new ArgumentNullException(nameof(key)); + Throw(); } + + static void Throw() => throw new ArgumentNullException(nameof(key)); } } } From 1e8adf299e7f543fd548d63df3dedf574ff64e8d Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Wed, 18 Nov 2020 05:00:29 -0800 Subject: [PATCH 11/19] Integrate misc fixes from dotnet/runtimelab:NativeAOT (#44851) --- docs/workflow/editing-and-debugging.md | 3 +-- src/coreclr/src/inc/gcinfodecoder.h | 12 ++++++------ .../Compiler/CompilerTypeSystemContext.cs | 2 +- .../TypeSystem/Common/TypeSystemHelpers.cs | 15 ++++++++++----- .../SymbolReader/PortablePdbSymbolReader.cs | 19 ++++++++++++++++++- .../tools/Common/TypeSystem/IL/ILImporter.cs | 14 +++++++------- src/tests/build.sh | 1 - 7 files changed, 43 insertions(+), 23 deletions(-) diff --git a/docs/workflow/editing-and-debugging.md b/docs/workflow/editing-and-debugging.md index 8297b10d28734..5ffc9813b9ca4 100644 --- a/docs/workflow/editing-and-debugging.md +++ b/docs/workflow/editing-and-debugging.md @@ -15,8 +15,7 @@ more on Markdown in general. # Visual Studio Solutions -The repository has a number of Visual Studio Solutions files (`*.sln`) that are useful for editing parts of -what are in the repository. In particular +The repository has a number of Visual Studio Solutions files (`*.sln`) that are useful for editing parts of the repository. In particular * `src\coreclr\src\System.Private.CoreLib\System.Private.CorLib.sln` - This solution is for all managed (C#) code that is defined in the runtime itself. This is all class library support of one form or another. diff --git a/src/coreclr/src/inc/gcinfodecoder.h b/src/coreclr/src/inc/gcinfodecoder.h index 576b5201623db..13b95756302a6 100644 --- a/src/coreclr/src/inc/gcinfodecoder.h +++ b/src/coreclr/src/inc/gcinfodecoder.h @@ -42,12 +42,12 @@ typedef ArrayDPTR(const uint8_t) PTR_CBYTE; #define VALIDATE_ROOT(isInterior, hCallBack, pObjRef) -#define UINT32 UInt32 -#define INT32 Int32 -#define UINT16 UInt16 -#define UINT UInt32 -#define SIZE_T UIntNative -#define SSIZE_T IntNative +#define UINT32 uint32_t +#define INT32 int32_t +#define UINT16 uint16_t +#define UINT uint32_t +#define SIZE_T uintptr_t +#define SSIZE_T intptr_t #define LPVOID void* typedef void * OBJECTREF; diff --git a/src/coreclr/src/tools/Common/Compiler/CompilerTypeSystemContext.cs b/src/coreclr/src/tools/Common/Compiler/CompilerTypeSystemContext.cs index 3cd92b4296e6e..4499457db5622 100644 --- a/src/coreclr/src/tools/Common/Compiler/CompilerTypeSystemContext.cs +++ b/src/coreclr/src/tools/Common/Compiler/CompilerTypeSystemContext.cs @@ -190,7 +190,7 @@ private EcmaModule AddModule(string filePath, string expectedSimpleName, bool us try { PEReader peReader = OpenPEFile(filePath, out mappedViewAccessor); - pdbReader = OpenAssociatedSymbolFile(filePath, peReader); + pdbReader = PortablePdbSymbolReader.TryOpenEmbedded(peReader, GetMetadataStringDecoder()) ?? OpenAssociatedSymbolFile(filePath, peReader); EcmaModule module = EcmaModule.Create(this, peReader, containingAssembly: null, pdbReader); diff --git a/src/coreclr/src/tools/Common/TypeSystem/Common/TypeSystemHelpers.cs b/src/coreclr/src/tools/Common/TypeSystem/Common/TypeSystemHelpers.cs index a72d9a1d7d9f5..75a95154f66d6 100644 --- a/src/coreclr/src/tools/Common/TypeSystem/Common/TypeSystemHelpers.cs +++ b/src/coreclr/src/tools/Common/TypeSystem/Common/TypeSystemHelpers.cs @@ -369,7 +369,7 @@ public static MethodDesc ResolveInterfaceMethodTarget(this TypeDesc thisType, Me return result; } - public static bool ContainsSignatureVariables(this TypeDesc thisType) + public static bool ContainsSignatureVariables(this TypeDesc thisType, bool treatGenericParameterLikeSignatureVariable = false) { switch (thisType.Category) { @@ -377,29 +377,34 @@ public static bool ContainsSignatureVariables(this TypeDesc thisType) case TypeFlags.SzArray: case TypeFlags.ByRef: case TypeFlags.Pointer: - return ((ParameterizedType)thisType).ParameterType.ContainsSignatureVariables(); + return ((ParameterizedType)thisType).ParameterType.ContainsSignatureVariables(treatGenericParameterLikeSignatureVariable); case TypeFlags.FunctionPointer: MethodSignature pointerSignature = ((FunctionPointerType)thisType).Signature; for (int i = 0; i < pointerSignature.Length; i++) - if (pointerSignature[i].ContainsSignatureVariables()) + if (pointerSignature[i].ContainsSignatureVariables(treatGenericParameterLikeSignatureVariable)) return true; - return pointerSignature.ReturnType.ContainsSignatureVariables(); + return pointerSignature.ReturnType.ContainsSignatureVariables(treatGenericParameterLikeSignatureVariable); case TypeFlags.SignatureMethodVariable: case TypeFlags.SignatureTypeVariable: return true; case TypeFlags.GenericParameter: + if (treatGenericParameterLikeSignatureVariable) + return true; + // It is generally a bug to have instantiations over generic parameters + // in the system. Typical instantiations are represented as instantiations + // over own formals - so these should be signature variables instead. throw new ArgumentException(); default: Debug.Assert(thisType is DefType); foreach (TypeDesc arg in thisType.Instantiation) { - if (arg.ContainsSignatureVariables()) + if (arg.ContainsSignatureVariables(treatGenericParameterLikeSignatureVariable)) return true; } diff --git a/src/coreclr/src/tools/Common/TypeSystem/Ecma/SymbolReader/PortablePdbSymbolReader.cs b/src/coreclr/src/tools/Common/TypeSystem/Ecma/SymbolReader/PortablePdbSymbolReader.cs index 886280f21f75c..4d14480129cec 100644 --- a/src/coreclr/src/tools/Common/TypeSystem/Ecma/SymbolReader/PortablePdbSymbolReader.cs +++ b/src/coreclr/src/tools/Common/TypeSystem/Ecma/SymbolReader/PortablePdbSymbolReader.cs @@ -7,6 +7,7 @@ using System.IO.MemoryMappedFiles; using System.Reflection.Metadata; using System.Reflection.Metadata.Ecma335; +using System.Reflection.PortableExecutable; using Internal.IL; @@ -74,6 +75,21 @@ public static PdbSymbolReader TryOpen(string pdbFilename, MetadataStringDecoder return new PortablePdbSymbolReader(reader, mappedViewAccessor); } + public static PdbSymbolReader TryOpenEmbedded(PEReader peReader, MetadataStringDecoder stringDecoder) + { + foreach (DebugDirectoryEntry debugEntry in peReader.ReadDebugDirectory()) + { + if (debugEntry.Type != DebugDirectoryEntryType.EmbeddedPortablePdb) + continue; + + MetadataReaderProvider embeddedReaderProvider = peReader.ReadEmbeddedPortablePdbDebugDirectoryData(debugEntry); + MetadataReader reader = embeddedReaderProvider.GetMetadataReader(MetadataReaderOptions.Default, stringDecoder); + return new PortablePdbSymbolReader(reader, mappedViewAccessor: null); + } + + return null; + } + private MetadataReader _reader; private MemoryMappedViewAccessor _mappedViewAccessor; @@ -85,7 +101,8 @@ private PortablePdbSymbolReader(MetadataReader reader, MemoryMappedViewAccessor public override void Dispose() { - _mappedViewAccessor.Dispose(); + if (_mappedViewAccessor != null) + _mappedViewAccessor.Dispose(); } public override IEnumerable GetSequencePointsForMethod(int methodToken) diff --git a/src/coreclr/src/tools/Common/TypeSystem/IL/ILImporter.cs b/src/coreclr/src/tools/Common/TypeSystem/IL/ILImporter.cs index e3e4fba5983aa..8f4cb7440c71a 100644 --- a/src/coreclr/src/tools/Common/TypeSystem/IL/ILImporter.cs +++ b/src/coreclr/src/tools/Common/TypeSystem/IL/ILImporter.cs @@ -746,25 +746,25 @@ private void ImportBasicBlock(BasicBlock basicBlock) ImportConvert(WellKnownType.SByte, true, false); break; case ILOpcode.conv_ovf_u1: - ImportConvert(WellKnownType.Byte, true, false); + ImportConvert(WellKnownType.Byte, true, true); break; case ILOpcode.conv_ovf_i2: ImportConvert(WellKnownType.Int16, true, false); break; case ILOpcode.conv_ovf_u2: - ImportConvert(WellKnownType.UInt16, true, false); + ImportConvert(WellKnownType.UInt16, true, true); break; case ILOpcode.conv_ovf_i4: ImportConvert(WellKnownType.Int32, true, false); break; case ILOpcode.conv_ovf_u4: - ImportConvert(WellKnownType.UInt32, true, false); + ImportConvert(WellKnownType.UInt32, true, true); break; case ILOpcode.conv_ovf_i8: ImportConvert(WellKnownType.Int64, true, false); break; case ILOpcode.conv_ovf_u8: - ImportConvert(WellKnownType.UInt64, true, false); + ImportConvert(WellKnownType.UInt64, true, true); break; case ILOpcode.refanyval: ImportRefAnyVal(ReadILToken()); @@ -779,10 +779,10 @@ private void ImportBasicBlock(BasicBlock basicBlock) ImportLdToken(ReadILToken()); break; case ILOpcode.conv_u2: - ImportConvert(WellKnownType.UInt16, false, false); + ImportConvert(WellKnownType.UInt16, false, true); break; case ILOpcode.conv_u1: - ImportConvert(WellKnownType.Byte, false, false); + ImportConvert(WellKnownType.Byte, false, true); break; case ILOpcode.conv_i: ImportConvert(WellKnownType.IntPtr, false, false); @@ -791,7 +791,7 @@ private void ImportBasicBlock(BasicBlock basicBlock) ImportConvert(WellKnownType.IntPtr, true, false); break; case ILOpcode.conv_ovf_u: - ImportConvert(WellKnownType.UIntPtr, true, false); + ImportConvert(WellKnownType.UIntPtr, true, true); break; case ILOpcode.add_ovf: case ILOpcode.add_ovf_un: diff --git a/src/tests/build.sh b/src/tests/build.sh index 88c7a23e73e97..a1efe50cc009e 100755 --- a/src/tests/build.sh +++ b/src/tests/build.sh @@ -440,7 +440,6 @@ build_MSBuild_projects() usage_list=() usage_list+=("-skiprestorepackages: skip package restore.") -usage_list+=("-skipstressdependencies: Don't install stress dependencies.") usage_list+=("-skipgeneratelayout: Do not generate the Core_Root layout.") usage_list+=("-skiptestwrappers: Don't generate test wrappers.") From 04ad4274e14bca9909547db053edffd6151ff4b1 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Wed, 18 Nov 2020 13:37:25 +0000 Subject: [PATCH 12/19] Use read-only auto-implemented property (#44677) * Use read-only auto-implemented property in src\libraries\Common Use read-only auto-implemented property (RCS1170) https://github.com/JosefPihrt/Roslynator/blob/master/docs/analyzers/RCS1170.md * Revert changes except to ComEventsMethod --- .../src/System/Runtime/InteropServices/ComEventsMethod.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/Common/src/System/Runtime/InteropServices/ComEventsMethod.cs b/src/libraries/Common/src/System/Runtime/InteropServices/ComEventsMethod.cs index 22281c58e3169..766c120d51607 100644 --- a/src/libraries/Common/src/System/Runtime/InteropServices/ComEventsMethod.cs +++ b/src/libraries/Common/src/System/Runtime/InteropServices/ComEventsMethod.cs @@ -38,7 +38,7 @@ public DelegateWrapper(Delegate d, bool wrapArgs) public Delegate Delegate { get; set; } - public bool WrapArgs { get; private set; } + public bool WrapArgs { get; } public object? Invoke(object[] args) { From 6cb16e12fd912c28f2ab4577414b4a2d8b321a28 Mon Sep 17 00:00:00 2001 From: Rikki Gibson Date: Wed, 18 Nov 2020 07:16:49 -0800 Subject: [PATCH 13/19] Remove unnecessary suppression (#44811) --- src/libraries/System.Linq/src/System/Linq/DefaultIfEmpty.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Linq/src/System/Linq/DefaultIfEmpty.cs b/src/libraries/System.Linq/src/System/Linq/DefaultIfEmpty.cs index a513a6eb7fe33..593a6b8a67b3d 100644 --- a/src/libraries/System.Linq/src/System/Linq/DefaultIfEmpty.cs +++ b/src/libraries/System.Linq/src/System/Linq/DefaultIfEmpty.cs @@ -9,7 +9,7 @@ namespace System.Linq public static partial class Enumerable { public static IEnumerable DefaultIfEmpty(this IEnumerable source) => - DefaultIfEmpty(source, default!); + DefaultIfEmpty(source, default); public static IEnumerable DefaultIfEmpty(this IEnumerable source, TSource defaultValue) { From 9765835057496db6ec2c1e5fb7a7610f628915ef Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Wed, 18 Nov 2020 17:14:23 +0100 Subject: [PATCH 14/19] [browser][wasm] Cleanup debug statement (#44870) --- .../System/Net/WebSockets/BrowserWebSockets/BrowserWebSocket.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/BrowserWebSockets/BrowserWebSocket.cs b/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/BrowserWebSockets/BrowserWebSocket.cs index 1f5beaf0644d4..b767c3149bee4 100644 --- a/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/BrowserWebSockets/BrowserWebSocket.cs +++ b/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/BrowserWebSockets/BrowserWebSocket.cs @@ -301,7 +301,6 @@ private void NativeCleanup() public override void Dispose() { - System.Diagnostics.Debug.WriteLine("BrowserWebSocket::Dispose"); int priorState = Interlocked.Exchange(ref _state, (int)InternalState.Disposed); if (priorState == (int)InternalState.Disposed) { From 35e535e6fa50b8284a44428d6b03b0180bc9b499 Mon Sep 17 00:00:00 2001 From: Vitek Karas Date: Wed, 18 Nov 2020 08:21:05 -0800 Subject: [PATCH 15/19] Fix a comment in the bundle marker (#44874) --- src/installer/corehost/cli/apphost/bundle_marker.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/installer/corehost/cli/apphost/bundle_marker.cpp b/src/installer/corehost/cli/apphost/bundle_marker.cpp index ae796a44436e5..aac23e5f32865 100644 --- a/src/installer/corehost/cli/apphost/bundle_marker.cpp +++ b/src/installer/corehost/cli/apphost/bundle_marker.cpp @@ -9,9 +9,8 @@ int64_t bundle_marker_t::header_offset() { // Contains the bundle_placeholder default value at compile time. - // If this is a single-file bundle, the last 8 bytes are replaced - // bundle-header replaced by "dotnet publish" with the offset - // where the bundle_header is located. + // If this is a single-file bundle, the first 8 bytes are replaced + // by "dotnet publish" with the offset where the bundle_header is located. static volatile uint8_t placeholder[] = { // 8 bytes represent the bundle header-offset From 57c14a2d86b739fb135da5a0e5c65da38dafe552 Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Wed, 18 Nov 2020 12:13:45 -0500 Subject: [PATCH 16/19] Remove most LINQ usage from Microsoft.Extensions.Configuration (#44825) Resulting in several hundred Func, IEnumerable, set, and string allocations at startup. --- .../src/ChainedConfigurationProvider.cs | 12 ++++--- .../src/ConfigurationKeyComparer.cs | 3 ++ .../src/ConfigurationProvider.cs | 36 +++++++++++++++---- .../src/ConfigurationRoot.cs | 3 +- 4 files changed, 40 insertions(+), 14 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.Configuration/src/ChainedConfigurationProvider.cs b/src/libraries/Microsoft.Extensions.Configuration/src/ChainedConfigurationProvider.cs index 44605958a6fa4..a240f3da8e7d1 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/src/ChainedConfigurationProvider.cs +++ b/src/libraries/Microsoft.Extensions.Configuration/src/ChainedConfigurationProvider.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Linq; using Microsoft.Extensions.Primitives; namespace Microsoft.Extensions.Configuration @@ -78,11 +77,14 @@ public IEnumerable GetChildKeys( string parentPath) { IConfiguration section = parentPath == null ? _config : _config.GetSection(parentPath); - IEnumerable children = section.GetChildren(); var keys = new List(); - keys.AddRange(children.Select(c => c.Key)); - return keys.Concat(earlierKeys) - .OrderBy(k => k, ConfigurationKeyComparer.Instance); + foreach (IConfigurationSection child in section.GetChildren()) + { + keys.Add(child.Key); + } + keys.AddRange(earlierKeys); + keys.Sort(ConfigurationKeyComparer.Comparison); + return keys; } /// diff --git a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationKeyComparer.cs b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationKeyComparer.cs index b0abce12d36cb..b5dc31fdffe73 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationKeyComparer.cs +++ b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationKeyComparer.cs @@ -18,6 +18,9 @@ public class ConfigurationKeyComparer : IComparer /// public static ConfigurationKeyComparer Instance { get; } = new ConfigurationKeyComparer(); + /// A comparer delegate with the default instance. + internal static Comparison Comparison { get; } = Instance.Compare; + /// /// Compares two strings. /// diff --git a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationProvider.cs b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationProvider.cs index 15927fedce25d..e337bd3148331 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationProvider.cs +++ b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationProvider.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; -using System.Linq; +using System.Diagnostics; using System.Threading; using Microsoft.Extensions.Primitives; @@ -62,13 +62,35 @@ public virtual IEnumerable GetChildKeys( IEnumerable earlierKeys, string parentPath) { - string prefix = parentPath == null ? string.Empty : parentPath + ConfigurationPath.KeyDelimiter; + var results = new List(); - return Data - .Where(kv => kv.Key.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)) - .Select(kv => Segment(kv.Key, prefix.Length)) - .Concat(earlierKeys) - .OrderBy(k => k, ConfigurationKeyComparer.Instance); + if (parentPath is null) + { + foreach (KeyValuePair kv in Data) + { + results.Add(Segment(kv.Key, 0)); + } + } + else + { + Debug.Assert(ConfigurationPath.KeyDelimiter == ":"); + + foreach (KeyValuePair kv in Data) + { + if (kv.Key.Length > parentPath.Length && + kv.Key.StartsWith(parentPath, StringComparison.OrdinalIgnoreCase) && + kv.Key[parentPath.Length] == ':') + { + results.Add(Segment(kv.Key, parentPath.Length + 1)); + } + } + } + + results.AddRange(earlierKeys); + + results.Sort(ConfigurationKeyComparer.Comparison); + + return results; } private static string Segment(string key, int prefixLength) diff --git a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationRoot.cs b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationRoot.cs index bff21d5eb068c..455efdb4176bf 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationRoot.cs +++ b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationRoot.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Threading; using Microsoft.Extensions.Primitives; @@ -66,7 +65,7 @@ public string this[string key] } set { - if (!_providers.Any()) + if (_providers.Count == 0) { throw new InvalidOperationException(SR.Error_NoSources); } From 2d801010e2e3cea69c49b961a72f03f6d391715e Mon Sep 17 00:00:00 2001 From: Levi Broderick Date: Wed, 18 Nov 2020 09:38:30 -0800 Subject: [PATCH 17/19] GetUninitializedObject fixes & improved tests (#44843) * Improve unit test coverage for GetUninitializedObject * Normalize most checks between coreclr and mono --- src/coreclr/src/vm/reflectioninvocation.cpp | 4 +- .../TestUtilities/System/PlatformDetection.cs | 1 + .../CompilerServices/RuntimeHelpersTests.cs | 120 ++++++++++++++++-- src/mono/mono/metadata/icall.c | 10 ++ 4 files changed, 122 insertions(+), 13 deletions(-) diff --git a/src/coreclr/src/vm/reflectioninvocation.cpp b/src/coreclr/src/vm/reflectioninvocation.cpp index 3dfa8ca727739..e8bc4beb61218 100644 --- a/src/coreclr/src/vm/reflectioninvocation.cpp +++ b/src/coreclr/src/vm/reflectioninvocation.cpp @@ -2193,8 +2193,8 @@ FCIMPL1(Object*, ReflectionSerialization::GetUninitializedObject, ReflectClassBa TypeHandle type = objType->GetType(); - // Don't allow arrays, pointers, byrefs or function pointers. - if (type.IsTypeDesc() || type.IsArray()) + // Don't allow void, arrays, pointers, byrefs or function pointers. + if (type.IsTypeDesc() || type.IsArray() || type.GetSignatureCorElementType() == ELEMENT_TYPE_VOID) COMPlusThrow(kArgumentException, W("Argument_InvalidValue")); MethodTable *pMT = type.AsMethodTable(); diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs index 313e6194e4ef0..3bb73dfe682a3 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs @@ -77,6 +77,7 @@ public static bool IsDrawingSupported } public static bool IsInContainer => GetIsInContainer(); + public static bool SupportsComInterop => IsWindows && IsNotMonoRuntime; // matches definitions in clr.featuredefines.props public static bool SupportsSsl3 => GetSsl3Support(); public static bool SupportsSsl2 => IsWindows && !PlatformDetection.IsWindows10Version1607OrGreater; diff --git a/src/libraries/System.Runtime/tests/System/Runtime/CompilerServices/RuntimeHelpersTests.cs b/src/libraries/System.Runtime/tests/System/Runtime/CompilerServices/RuntimeHelpersTests.cs index d3097d9316415..12620e947c06b 100644 --- a/src/libraries/System.Runtime/tests/System/Runtime/CompilerServices/RuntimeHelpersTests.cs +++ b/src/libraries/System.Runtime/tests/System/Runtime/CompilerServices/RuntimeHelpersTests.cs @@ -1,11 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Reflection; using System.Collections; using System.Collections.Generic; -using System.Runtime.CompilerServices; +using System.IO; +using System.Reflection; using System.Runtime.InteropServices; using Xunit; @@ -192,16 +191,107 @@ private static void FillStack(int depth) } } + public static IEnumerable GetUninitializedObject_NegativeTestCases() + { + // TODO: Test actual function pointer types when typeof(delegate*<...>) support is available + + yield return new[] { typeof(string), typeof(ArgumentException) }; // variable-length type + yield return new[] { typeof(int[]), typeof(ArgumentException) }; // variable-length type + yield return new[] { typeof(int[,]), typeof(ArgumentException) }; // variable-length type + yield return new[] { Array.CreateInstance(typeof(int), new[] { 1 }, new[] { 1 }).GetType(), typeof(ArgumentException) }; // variable-length type (non-szarray) + yield return new[] { typeof(Array), typeof(MemberAccessException) }; // abstract type + yield return new[] { typeof(Enum), typeof(MemberAccessException) }; // abstract type + + yield return new[] { typeof(Stream), typeof(MemberAccessException) }; // abstract type + yield return new[] { typeof(Buffer), typeof(MemberAccessException) }; // static type (runtime sees it as abstract) + yield return new[] { typeof(IDisposable), typeof(MemberAccessException) }; // interface type + + yield return new[] { typeof(List<>), typeof(MemberAccessException) }; // open generic type + yield return new[] { typeof(List<>).GetGenericArguments()[0], PlatformDetection.IsMonoRuntime ? typeof(MemberAccessException) : typeof(ArgumentException) }; // 'T' placeholder typedesc + + yield return new[] { typeof(Delegate), typeof(MemberAccessException) }; // abstract type + + yield return new[] { typeof(void), typeof(ArgumentException) }; // explicit block in place + yield return new[] { typeof(int).MakePointerType(), typeof(ArgumentException) }; // pointer typedesc + yield return new[] { typeof(int).MakeByRefType(), typeof(ArgumentException) }; // byref typedesc + + yield return new[] { typeof(ReadOnlySpan), typeof(NotSupportedException) }; // byref type + yield return new[] { typeof(ArgIterator), typeof(NotSupportedException) }; // byref type + + Type canonType = typeof(object).Assembly.GetType("System.__Canon", throwOnError: false); + if (canonType != null) + { + yield return new[] { typeof(List<>).MakeGenericType(canonType), typeof(NotSupportedException) }; // shared by generic instantiations + } + + Type comObjType = typeof(object).Assembly.GetType("System.__ComObject", throwOnError: false); + if (comObjType != null) + { + yield return new[] { comObjType, typeof(NotSupportedException) }; // COM type + } + + if (PlatformDetection.SupportsComInterop) + { + yield return new[] { typeof(WbemContext), typeof(NotSupportedException) }; // COM type + } + } + + // This type definition is lifted from System.Management, just for testing purposes + [ClassInterface((short)0x0000)] + [Guid("674B6698-EE92-11D0-AD71-00C04FD8FDFF")] + [ComImport] + internal class WbemContext + { + } + + internal class ClassWithBeforeFieldInitCctor + { + private static readonly int _theInt = GetInt(); + + private static int GetInt() + { + AppDomain.CurrentDomain.SetData("ClassWithBeforeFieldInitCctor_CctorRan", true); + return 0; + } + } + + internal class ClassWithNormalCctor + { +#pragma warning disable CS0414 // unused private field + private static readonly int _theInt; +#pragma warning restore CS0414 + + static ClassWithNormalCctor() + { + AppDomain.CurrentDomain.SetData("ClassWithNormalCctor_CctorRan", true); + _theInt = 0; + } + } + [Fact] - public static void GetUninitializedObject_InvalidArguments_ThrowsException() + public static void GetUninitalizedObject_DoesNotRunBeforeFieldInitCctors() { - AssertExtensions.Throws("type", () => RuntimeHelpers.GetUninitializedObject(null)); + object o = RuntimeHelpers.GetUninitializedObject(typeof(ClassWithBeforeFieldInitCctor)); + Assert.IsType(o); - AssertExtensions.Throws(null, () => RuntimeHelpers.GetUninitializedObject(typeof(string))); // special type - Assert.Throws(() => RuntimeHelpers.GetUninitializedObject(typeof(System.IO.Stream))); // abstract type - Assert.Throws(() => RuntimeHelpers.GetUninitializedObject(typeof(System.Collections.IEnumerable))); // interface - Assert.Throws(() => RuntimeHelpers.GetUninitializedObject(typeof(System.Collections.Generic.List<>))); // generic definition - Assert.Throws(() => RuntimeHelpers.GetUninitializedObject(typeof(TypedReference))); // byref-like type + Assert.Null(AppDomain.CurrentDomain.GetData("ClassWithBeforeFieldInitCctor_CctorRan")); + } + + [ActiveIssue("https://github.com/dotnet/runtime/issues/44852", TestRuntimes.Mono)] + [Fact] + public static void GetUninitalizedObject_RunsNormalStaticCtors() + { + object o = RuntimeHelpers.GetUninitializedObject(typeof(ClassWithNormalCctor)); + Assert.IsType(o); + + Assert.Equal(true, AppDomain.CurrentDomain.GetData("ClassWithNormalCctor_CctorRan")); + } + + [Theory] + [MemberData(nameof(GetUninitializedObject_NegativeTestCases))] + public static void GetUninitializedObject_InvalidArguments_ThrowsException(Type typeToInstantiate, Type expectedExceptionType) + { + Assert.Throws(expectedExceptionType, () => RuntimeHelpers.GetUninitializedObject(typeToInstantiate)); } [Fact] @@ -211,11 +301,19 @@ public static void GetUninitializedObject_DoesNotRunConstructor() Assert.Equal(0, ((ObjectWithDefaultCtor)RuntimeHelpers.GetUninitializedObject(typeof(ObjectWithDefaultCtor))).Value); } + [Fact] + public static void GetUninitializedObject_Struct() + { + object o = RuntimeHelpers.GetUninitializedObject(typeof(Guid)); + Assert.Equal(Guid.Empty, Assert.IsType(o)); + } + [Fact] public static void GetUninitializedObject_Nullable() { // Nullable returns the underlying type instead - Assert.Equal(typeof(int), RuntimeHelpers.GetUninitializedObject(typeof(Nullable)).GetType()); + object o = RuntimeHelpers.GetUninitializedObject(typeof(int?)); + Assert.Equal(0, Assert.IsType(o)); } private class ObjectWithDefaultCtor diff --git a/src/mono/mono/metadata/icall.c b/src/mono/mono/metadata/icall.c index 2d70ba3d1ed9a..d54276ceadc1e 100644 --- a/src/mono/mono/metadata/icall.c +++ b/src/mono/mono/metadata/icall.c @@ -1381,6 +1381,16 @@ ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetUninitializedObjectI return NULL_HANDLE; } + if (mono_class_is_array (klass) || mono_class_is_pointer (klass) || handle->byref) { + mono_error_set_argument (error, NULL, NULL); + return NULL_HANDLE; + } + + if (MONO_TYPE_IS_VOID (handle)) { + mono_error_set_argument (error, NULL, NULL); + return NULL_HANDLE; + } + if (m_class_is_abstract (klass) || m_class_is_interface (klass) || m_class_is_gtd (klass)) { mono_error_set_member_access (error, NULL, NULL); return NULL_HANDLE; From 38259c83703dbf6df50c814f7504e7073b5ffaef Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Wed, 18 Nov 2020 12:41:24 -0500 Subject: [PATCH 18/19] Avoid string.Concat(params string[]) in SimpleConsoleFormatter.CreateDefaultLogMessage (#44765) It's resulting in a string[] allocation and a string allocation, when we can instead just make a few more individual calls to Write and stackalloc the integer. --- .../src/SimpleConsoleFormatter.cs | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/src/SimpleConsoleFormatter.cs b/src/libraries/Microsoft.Extensions.Logging.Console/src/SimpleConsoleFormatter.cs index bc702ca0438ad..1c790a45e730d 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Console/src/SimpleConsoleFormatter.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Console/src/SimpleConsoleFormatter.cs @@ -3,10 +3,6 @@ using System; using System.IO; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; @@ -78,7 +74,19 @@ private void CreateDefaultLogMessage(TextWriter textWriter, in LogEntry< // Request received // category and event id - textWriter.Write(LoglevelPadding + logEntry.Category + '[' + eventId + "]"); + textWriter.Write(LoglevelPadding); + textWriter.Write(logEntry.Category); + textWriter.Write('['); + +#if NETCOREAPP + Span span = stackalloc char[10]; + if (eventId.TryFormat(span, out int charsWritten)) + textWriter.Write(span.Slice(0, charsWritten)); + else +#endif + textWriter.Write(eventId.ToString()); + + textWriter.Write(']'); if (!singleLine) { textWriter.Write(Environment.NewLine); @@ -177,7 +185,8 @@ private void WriteScopeInformation(TextWriter textWriter, IExternalScopeProvider if (paddingNeeded) { paddingNeeded = false; - state.Write(_messagePadding + "=> "); + state.Write(_messagePadding); + state.Write("=> "); } else { From eeba59712d0f8cfa3bda89e4e90b707366b9cd95 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 18 Nov 2020 11:07:06 -0800 Subject: [PATCH 19/19] Restore the Microsoft.NETCore.DotNetAppHost package since the SDK transitively uses it through the Microsoft.NETCore.DotNetHostResolver package. (#44883) --- .../Microsoft.NETCore.DotNetAppHost.pkgproj | 32 +++++++++++++++++++ src/installer/pkg/projects/host-packages.proj | 1 + 2 files changed, 33 insertions(+) create mode 100644 src/installer/pkg/projects/Microsoft.NETCore.DotNetAppHost/Microsoft.NETCore.DotNetAppHost.pkgproj diff --git a/src/installer/pkg/projects/Microsoft.NETCore.DotNetAppHost/Microsoft.NETCore.DotNetAppHost.pkgproj b/src/installer/pkg/projects/Microsoft.NETCore.DotNetAppHost/Microsoft.NETCore.DotNetAppHost.pkgproj new file mode 100644 index 0000000000000..0ce0a5fcb2c35 --- /dev/null +++ b/src/installer/pkg/projects/Microsoft.NETCore.DotNetAppHost/Microsoft.NETCore.DotNetAppHost.pkgproj @@ -0,0 +1,32 @@ + + + AppHostVersion + + + + + + + + + + + + + + + + + + + + + + + runtimes/$(PackageTargetRuntime)/native + true + + + \ No newline at end of file diff --git a/src/installer/pkg/projects/host-packages.proj b/src/installer/pkg/projects/host-packages.proj index ca72703065391..89042f8169dd8 100644 --- a/src/installer/pkg/projects/host-packages.proj +++ b/src/installer/pkg/projects/host-packages.proj @@ -2,6 +2,7 @@ +