olsh / resharper-structured-logging

An extension for ReSharper and Rider that highlights structured logging templates and contains some useful analyzers
MIT License
141 stars 14 forks source link

Error when using the ReSharper CLI #107

Closed megla-tlanghorst closed 4 months ago

megla-tlanghorst commented 7 months ago

When using the ReSharper CLI (you can get that from NuGet): dotnet jb inspectcode <file>.sln --telemetry-optout --extensions=ReSharper.Structured.Logging --format=Sarif --output=out.sarif

The plugin results in the following error:

Error ``` JetBrains Inspect Code 2023.3.3 ReSharper Structured.Logging 2023.3.2.321 Running on x64 OS in x64 architecture, .NET 8.0.1 under Microsoft Windows 10.0.22631 Warning: Starting from version 2021.2, InspectCode builds the target solution before starting the analysis to make sure it only finds relevant code issues. To explicitly accept the new behavior and suppress this warning, use the '--build' option. To match the behavior in previous versions and skip the build, use '--no-build'. Using toolset version 17.0 from "C:\Program Files\dotnet\sdk\8.0.101" Configuration: Debug, Platform: Any CPU Nullable object must have a value. --- EXCEPTION #1/1 [LoggerException] Message = "Nullable object must have a value." ExceptionPath = Root ClassName = JetBrains.Util.LoggerException HResult = COR_E_APPLICATION=80131600 StackTraceString = " at JetBrains.Util.ILoggerEx.LogMessage(ILogger this, LoggingLevel level, String message) in LogMessage.il:line IL_002E mvid 9968 at JetBrains.Util.ILoggerEx.Error(ILogger this, String message) in Error.il:line IL_0000 mvid 9968 at JetBrains.CommandLine.InspectCode.Unattended.Console.InspectCodeProductMain.Main(Lifetime lifetime, IThreading invocator, IComponentContainer container, IShellLocks shellLocks, ILogger logger, IInspectCodeSettings settings, InspectCodeCommandLineArguments argumentsRaw, IProductInfo productInfo) in Main.il:line IL_0388 mvid 83B6 at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor) at System.Reflection.MethodBaseInvoker.InvokeWithManyArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) in InvokeWithManyArgs.il:line IL_0243 mvid 477B at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) in Invoke.il:line IL_0000 mvid 477B at JetBrains.Application.Components.MethodBindigns.Activate(ISingletonDescriptor descriptor, Object[] dependencies) in Activate.il:line IL_0053 mvid 9EEF at JetBrains.Application.Components.RuntimeMemberComponentDescriptor.DoCreateInstance(MethodBindigns bindings, Object[] dependencies) in DoCreateInstance.il:line IL_0000 mvid 9EEF at JetBrains.Application.Components.SingletonDescriptor`1.CreateInstance(Object[] dependencies) in CreateInstance.il:line IL_005F mvid 9EEF at JetBrains.Application.Components.AsyncDescriptorBase.ActivatingComponentState.CreateInstance() in CreateInstance.il:line IL_0033 mvid 9EEF at JetBrains.Application.Components.AsyncDescriptorBase.ActivatingComponentState.TryGetSyncImpl() in TryGetSyncImpl.il:line IL_00A8 mvid 9EEF at JetBrains.Application.Components.AsyncDescriptorBase.StateWithPriorityCache`1.TryGetSync() in TryGetSync.il:line IL_0010 mvid 9EEF at JetBrains.Application.Components.AsyncDescriptorBase.TryActivate(Object[] dependencyValues) in TryActivate.il:line IL_000B mvid 9EEF at JetBrains.Application.Components.AsyncDescriptorBase.TryGetOrCreateValue() in TryGetOrCreateValue.il:line IL_002F mvid 9EEF at JetBrains.Application.Components.AsyncDescriptorBase.GetValue() in GetValue.il:line IL_0006 mvid 9EEF at JetBrains.Application.Components.FactoryComponentContainer.InvokeLive(Lifetime lifetime, IComponentContainer parent, MemberInfo method, Object instance, Object[] args) in InvokeLive.il:line IL_008D mvid 9EEF at JetBrains.Application.Environment.RunsPublicStaticIntMain.<>c__DisplayClass0_0.<.ctor>b__0() in RunsPublicStaticIntMain.il:line IL_000B mvid 5434 or RunsPublicStaticIntMain.il:line IL_016C mvid 5434 at JetBrains.Application.Environment.RunsPublicStaticIntMain.<>c__DisplayClass0_2.<.ctor>b__5() in RunsPublicStaticIntMain.il:line IL_000B mvid 5434 or RunsPublicStaticIntMain.il:line IL_016C mvid 5434 at JetBrains.Application.Threading.IThreadingEx.<>c__DisplayClass16_0.<g__RunAsync|0>d.MoveNext() in ExecuteOrQueueWhenNotGuarded.il:line IL_0081 mvid 5434 at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AsyncStateMachineBox`1.ExecutionContextCallback(Object s) in ExecutionContextCallback.il:line IL_0000 mvid 477B at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) in RunInternal.il:line IL_0040 mvid 477B at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AsyncStateMachineBox`1.MoveNext(Thread threadPoolThread) in MoveNext.il:line IL_0000 mvid 477B or MoveNext.il:line IL_0040 mvid 477B at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AsyncStateMachineBox`1.MoveNext() in MoveNext.il:line IL_0000 mvid 477B or MoveNext.il:line IL_0040 mvid 477B at JetBrains.Application.Threading.YieldWhenNotGuardedAwaiter.ExecuteAsync(Action continuation) in ExecuteAsync.il:line IL_019A mvid 5434 at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AsyncStateMachineBox`1.ExecutionContextCallback(Object s) in ExecutionContextCallback.il:line IL_0000 mvid 477B at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) in RunInternal.il:line IL_0040 mvid 477B at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AsyncStateMachineBox`1.MoveNext(Thread threadPoolThread) in MoveNext.il:line IL_0000 mvid 477B or MoveNext.il:line IL_0040 mvid 477B at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AsyncStateMachineBox`1.MoveNext() in MoveNext.il:line IL_0000 mvid 477B or MoveNext.il:line IL_0040 mvid 477B at JetBrains.Util.Concurrency.Threading.Tasks.SchedulerAwaiter.<>c__DisplayClass11_0.b__0(Object _) in SchedulerAwaiter.il:line IL_0000 mvid 9968 at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) in RunInternal.il:line IL_0040 mvid 477B at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) in ExecuteWithThreadLocal.il:line IL_0096 mvid 477B at System.Threading.Tasks.Task.ExecuteEntry() in ExecuteEntry.il:line IL_0036 mvid 477B at JetBrains.Util.Concurrency.Dispatcher.JetDispatcherTaskScheduler.<>c__DisplayClass12_0.b__0() in JetDispatcherTaskScheduler.il:line IL_0000 mvid 9968 at JetBrains.Util.Concurrency.ExecutionContextEx.<>c__DisplayClass1_0.b__0(Object _) in ExecutionContextEx.il:line IL_0000 mvid 9968 or ExecutionContextEx.il:line IL_0011 mvid 9968 at JetBrains.Util.Concurrency.ExecutionContextEx.<>c__DisplayClass0_0.b__0(Object _) in ExecutionContextEx.il:line IL_0000 mvid 9968 or ExecutionContextEx.il:line IL_0011 mvid 9968 at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) in RunInternal.il:line IL_0040 mvid 477B at JetBrains.Util.Concurrency.ExecutionContextEx.Run(ExecutionContext context, ContextCallback callback, Object state) in Run.il:line IL_001A mvid 9968 or Run.il:line IL_0028 mvid 9968 at JetBrains.Util.Concurrency.ExecutionContextEx.Run(ExecutionContext context, Action action) in Run.il:line IL_001A mvid 9968 or Run.il:line IL_0028 mvid 9968 at JetBrains.Threading.JetDispatcher.Closure.<>c__DisplayClass1_1.<.ctor>b__0() in Closure.il:line IL_0000 mvid 9968 at JetBrains.Threading.JetDispatcher.Closure.Execute() in Execute.il:line IL_0100 mvid 9968 at JetBrains.Threading.JetDispatcher.ProcessQueue(Int32 nMinBucket, Int32 nProcessQueueGeneration) in ProcessQueue.il:line IL_01D0 mvid 9968 at JetBrains.Threading.JetDispatcher.<>c__DisplayClass69_0.g__ProcessQueueWithPriority|0() in JetDispatcher.il:line IL_0000 mvid 9968 at System.Windows.Threading.DispatcherOperation.InvokeDelegateCore() in InvokeDelegateCore.il:line IL_0000 mvid 7333 at System.Windows.Threading.DispatcherOperation.InvokeImpl() in InvokeImpl.il:line IL_0062 mvid 7333 at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj) in CallbackWrapper.il:line IL_001A mvid 7333 at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) in RunInternal.il:line IL_0040 mvid 477B at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state) in Run.il:line IL_0034 mvid 7333 at System.Windows.Threading.DispatcherOperation.Invoke() in Invoke.il:line IL_000F mvid 7333 at System.Windows.Threading.Dispatcher.ProcessQueue() in ProcessQueue.il:line IL_00E5 mvid 7333 at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) in WndProcHook.il:line IL_003A mvid 7333 at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) in WndProc.il:line IL_0023 mvid 7333 at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) in DispatcherCallbackOperation.il:line IL_0036 mvid 7333 at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) in InternalRealCall.il:line IL_0076 mvid 7333 at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler) in TryCatchWhen.il:line IL_0002 mvid 7333 at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs) in LegacyInvokeImpl.il:line IL_00BC mvid 7333 at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) in SubclassWndProc.il:line IL_010A mvid 7333 at JetBrains.Interop.WinApi.User32Dll.DispatchMessageW(MSG* lpmsg) at JetBrains.Interop.WinApi.User32Dll.DispatchMessageW(MSG* lpmsg) at JetBrains.Util.Concurrency.WinDispatcherImpl.WindowsDispatcherPlatformSpecific.InternalPumpMessagesOnce() in InternalPumpMessagesOnce.il:line IL_0020 mvid 9968 at JetBrains.Threading.JetDispatcher.<>c__DisplayClass47_0.b__0(IJetDispatcherPlatformSpecific staticMethods, TimeSpan t, Boolean _) in JetDispatcher.il:line IL_0000 mvid 9968 at JetBrains.Threading.JetDispatcher.RunAndRestartIfNeeded(TimeSpan timeout, Boolean bThrowOnTimeout, Func`4 runLoopAction) in RunAndRestartIfNeeded.il:line IL_0059 mvid 9968 at JetBrains.Threading.JetDispatcher.Run(IProperty`1 condition, TimeSpan timeout, Boolean bThrowOnTimeout) in Run.il:line IL_0027 mvid 9968 at JetBrains.Application.Environment.IJetHostEx.<>c__DisplayClass3_0.b__0(Lifetime lifetime) in IJetHostEx.il:line IL_0025 mvid 5434 at JetBrains.Lifetimes.Lifetime.Using(Action`1 action) in Using.il:line IL_0014 mvid CC54 at JetBrains.Application.Environment.IJetHostEx.RunHostMessageLoop(IComponentContainer containerEnv) in RunHostMessageLoop.il:line IL_0030 mvid 5434 at JetBrains.Application.Environment.HostParameters.MessagePumpMainLoopHostMixin.JetBrains.Application.Environment.HostParameters.IRunMainLoopHostMixin.RunMainLoop(ComponentContainer containerEnv) at JetBrains.Application.Environment.HostParameters.JetHostParametersCaller.RunMainLoop(ComponentContainer containerEnv) in RunMainLoop.il:line IL_009F mvid 5434 at JetBrains.Application.Environment.JetEnvironment.InternalRun(JetHostParametersCaller host, ComponentContainer containerEnv) in InternalRun.il:line IL_0010 mvid 5434 at JetBrains.Application.Environment.JetEnvironment.CreateAndRun(Full hostparams) in CreateAndRun.il:line IL_002E mvid 5434 at JetBrains.Application.Environment.JetHostItems.CreateAndRun(Full input) in CreateAndRun.il:line IL_000E mvid 5434 at JetBrains.ReSharperAutomationTools.CommandLine.Common.Application.CommandLineProgram.Main(Assembly assembly, Type environmentZoneType, HostInfo hostInfo, String[] args, IJetHostMixin[] mixins) in Main.il:line IL_0048 mvid AE3D at JetBrains.ReSharperAutomationTools.CommandLine.Common.Application.CommandLineProgramWithPlugins`1.Main(Assembly assembly, Type environmentZoneType, HostInfo hostInfo, String[] args, IJetHostMixin[] mixins) in Main.il:line IL_0033 mvid AE3D at JetBrains.ReSharperAutomationTools.CommandLine.Common.Application.CommandLineProgramWithPlugins`1.<>c__DisplayClass0_0`1.b__0() in CommandLineProgramWithPlugins.il:line IL_0000 mvid AE3D " ```

Sadly there doesn't seem to be any good stacktrace, since this doesn't even include plugin code (it works without the plugin though).

jackmcbrezel commented 4 months ago

Hi @megla-tlanghorst , I get a very similar exception without using the mentioned plugin (but a different one), so I assume this could be a general R# CLT problem...

See my ticket at jetbrains: https://youtrack.jetbrains.com/issue/RSRP-496947/Exception-in-ReSharper-CLT-with-SARIF-output

olsh commented 4 months ago

I'm uncertain if this issue stems from the plugin. Therefore, I recommend waiting for a response from the JB team before taking further action.

derigel23 commented 4 months ago

Yes, it's a bug in R# due to a bug in SARIF SDK. https://github.com/microsoft/sarif-sdk/issues/2808