SonarQube Analysis Task Error After File Move - c#

We have been using SonarQube analysis on a C# project as part of a TFS 2015/15 RC2 vNext build for ages which has been working fine.
A few days a go I refactored several aspects of code, this consisted of moving files into new folders within the same project, as opposed to class name changes etc. Visual Studio didn't handle this correctly and I had to remove and re-add some files to the project on an individual basis.
Our analysis is now failing, when looking at the logs for the analysis task I can see the following error:
ERROR [o.s.s.c.t.CeWorkerCallableImpl] Failed to execute task AVe_-iOpE8SSKScA9O_3 java.lang.IllegalStateException:
Original file OriginalFile{id=1363, uuid='ca50dc09-5d0b-4083-9e52-eb0f66361422', key='MIS:MIS:4E9625D2-557E-450C-90CC-A6B6FB57B6C9:Models/XXX/Grids/ProjectTeams/SmpProjectTeamFilterModel.cs'}
already registered for file
ComponentImpl{key='StanMIS:StanMIS:4E9625D2-557E-450C-90CC-A6B6FB57B6C9:Models/Smp/Grids/ProjectTeams/SmpProjectTeamFilterModel.cs', type=FILE, uuid='AVe_-nQKU1hbfyCkniEZ', name='', description='null', fileAttributes=FileAttributes{languageKey='cs', unitTest=false},
reportAttributes=ReportAttributes{ref=1506, version='null',
path='Models/Smp/Grids/ProjectTeams/SmpProjectTeamFilterModel.cs'}}.
Unable to register OriginalFile{id=1353, uuid='1488ce7d-094c-4859-9e23-adae0f1ac2a3', key='StanMIS:StanMIS:4E9625D2-557E-450C-90CC-A6B6FB57B6C9:Models/XXX/Grids/DStanContacts/SmpDStanContactFilterModel.cs'}.
at com.google.common.base.Preconditions.checkState(Preconditions.java:197) ~[guava-18.0.jar:na]
at org.sonar.server.computation.filemove.MutableMovedFilesRepositoryImpl.setOriginalFile(MutableMovedFilesRepositoryImpl.java:41) ~[sonar-server-6.0.jar:na]
at org.sonar.server.computation.filemove.FileMoveDetectionStep.registerMatches(FileMoveDetectionStep.java:144) ~[sonar-server-6.0.jar:na]
at org.sonar.server.computation.filemove.FileMoveDetectionStep.execute(FileMoveDetectionStep.java:139) ~[sonar-server-6.0.jar:na]
at org.sonar.server.computation.step.ComputationStepExecutor.executeSteps(ComputationStepExecutor.java:64) ~[sonar-server-6.0.jar:na]
at org.sonar.server.computation.step.ComputationStepExecutor.execute(ComputationStepExecutor.java:52) ~[sonar-server-6.0.jar:na]
at org.sonar.server.computation.taskprocessor.report.ReportTaskProcessor.process(ReportTaskProcessor.java:75) ~[sonar-server-6.0.jar:na]
at org.sonar.server.computation.taskprocessor.CeWorkerCallableImpl.executeTask(CeWorkerCallableImpl.java:81) ~[sonar-server-6.0.jar:na]
at org.sonar.server.computation.taskprocessor.CeWorkerCallableImpl.call(CeWorkerCallableImpl.java:56) ~[sonar-server-6.0.jar:na]
at org.sonar.server.computation.taskprocessor.CeWorkerCallableImpl.call(CeWorkerCallableImpl.java:35) [sonar-server-6.0.jar:na]
at java.util.concurrent.FutureTask.run(Unknown Source) [na:1.8.0_45]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [na:1.8.0_45]
at java.util.concurrent.FutureTask.run(Unknown Source) [na:1.8.0_45]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(Unknown Source) [na:1.8.0_45]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) [na:1.8.0_45]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.8.0_45]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.8.0_45]
at java.lang.Thread.run(Unknown Source) [na:1.8.0_45]
ERROR [o.s.s.c.t.CeWorkerCallableImpl] Executed task | project=MIS | type=REPORT | id=AVe_-iOpE8SSKScA9O_3 | submitter=XXX | time=24633ms

You face https://jira.sonarsource.com/browse/SONAR-8013. It is fixed in version 6.1.

Related

Error The "ResolvePackageFileConflicts" task failed unexpectedly. System.ArgumentException: Illegal characters in path

This is the error I'm getting when I am trying to build a solution. I tried commenting the Item groups individually one by one and fix the issue but it isn't solved.
Severity Code Description Project File Line Suppression State
Error The "ResolvePackageFileConflicts" task failed unexpectedly.
System.ArgumentException: Illegal characters in path.
at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional)
at System.IO.Path.GetFileName(String path)
at Microsoft.NET.Build.Tasks.ItemUtilities.GetTargetPath(ITaskItem item)
at Microsoft.NET.Build.Tasks.ItemUtilities.GetReferenceTargetPath(ITaskItem item)
at Microsoft.NET.Build.Tasks.ConflictResolution.ResolvePackageFileConflicts.<>c.<ExecuteCore>b__44_7(ConflictItem ci)
at Microsoft.NET.Build.Tasks.ConflictResolution.ConflictResolver`1.ResolveConflicts(IEnumerable`1 conflictItems, Func`2 getItemKey, ConflictCallback`1 foundConflict, Boolean commitWinner)
at Microsoft.NET.Build.Tasks.ConflictResolution.ResolvePackageFileConflicts.ExecuteCore()
at Microsoft.NET.Build.Tasks.TaskBase.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() CocoonIT
I'm trying to build a solution and was getting this error and I'm not sure how to resolve it.
I have tried commenting the ItemGroups one by one in the csproj file but it didn't solve this.
Could you please help me in resolving this

Does StyleCop.Analyzers support C# records?

Problem description:
When adding a C# record in a project with StyleCop.Analyzers, it shows the warning:
Warning AD0001 Analyzer 'StyleCop.Analyzers.DocumentationRules.SA1649FileNameMustMatchTypeName' threw an exception of type 'System.ArgumentException' with message 'Unhandled declaration kind: RecordDeclaration'.
System.ArgumentException: Unhandled declaration kind: RecordDeclaration
at StyleCop.Analyzers.Helpers.NamedTypeHelpers.GetNameOrIdentifier(MemberDeclarationSyntax member)
at StyleCop.Analyzers.Helpers.FileNameHelpers.GetConventionalFileName(MemberDeclarationSyntax declaration, FileNamingConvention convention)
at StyleCop.Analyzers.DocumentationRules.SA1649FileNameMustMatchTypeName.Analyzer.HandleSyntaxTree(SyntaxTreeAnalysisContext context, StyleCopSettings settings)
at StyleCop.Analyzers.AnalyzerExtensions.<>c__DisplayClass0_0.<RegisterSyntaxTreeAction>b__0(SyntaxTreeAnalysisContext c)
at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c.<ExecuteSyntaxTreeActionsCore>b__59_1(ValueTuple`2 data)
at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info)
Is it a bug in StyleCop.Analyzers?
Steps to reproduce:
Create a new .Net6 console project (or even .Net5).
Add a C# record in it: public record Member(string FirstName, string LastName);
Install the package StyleCop.Analyzers v1.1.118
Look in the Visual Studio Error List, and you will see the warning.
Thank you #stuartd you pointed me to the right direction.
It is indeed a bug in Stylecop 1.1.X
It was corrected in the StyleCop.Analyzers.Unstable v1.2.0-beta.161. but unfortunately, it is not included in the stable version yet. So the workaround I see for now is to use the unstable version

'Expected Global Line.' exception while loading solution using Roslyn

I'm learning Roslyn and trying it out for the first time. I've written a small code snippet to load a solution and get a reference to a workspace.
IWorkspace workspace = Workspace.LoadSolution(solutionPath);
foreach (IProject project in workspace.CurrentSolution.Projects)
{
CommonCompilation objCompilation = project.GetCompilation();
}
return workspace;
But I'm getting an exception in the first line. The exception details are given below.
Message : Expected Global Line.
stack trace : at
Roslyn.Services.Host.SolutionFile.ParseGlobal(TextReader reader)
at Roslyn.Services.Host.SolutionFile.Parse(TextReader reader) at
Roslyn.Services.Host.LoadedWorkspace.LoadSolution(SolutionId
solutionId, String filePath) at
Roslyn.Services.Host.LoadedWorkspace.OpenSolution(String fileName)
at Roslyn.Services.Host.LoadedWorkspace.LoadSolution(String
solutionFileName, String configuration, String platform, Boolean
enableFileTracking) at
Roslyn.Services.Workspace.LoadSolution(String solutionFileName, String
configuration, String platform, Boolean enableFileTracking) at
Ros2.Program.GetWorkspace(String solutionPath) in
c:\users\amnatu\documents\visual studio
2015\Projects\Ros2\Ros2\Program.cs:line 30
I referred to this link which shows the same issue that I faced. However, the solution of removing the space between EndProject and Global isn't really applicable in my case as my solution file doesn't have any space between them.
Am I missing anything here?Any suggestions on how to resolve this issue?
Apologies for the delayed response. The comment by #JoshVarty helped me understand the issue.
I was indeed using the out dated version and had to use the latest Microsoft.CodeAnalysis library. After I made these changes and updated all classes accordingly, everything worked perfectly.
Thanks JoshVarty.!

Visual Studio 2012 Not Working Properly - Unexpected Error

My visual studio is acting weird. When I try to open a fresh unit test it freezes, gives me three options (close, restart, debugg), and does it again. When I open an existing file; they open but do not Run or Execute.
When trying to test or debug, I recieve a message that states "Unexpected error detected. Check the Tests Output Pane for details.".
Heading over to the output pane I get this message(Show output from tests):
" System.ArgumentNullException: Value cannot be null.
Parameter name: source
at Microsoft.VisualStudio.Shell.ValidateArg.NotNull[T](T arg, String parameterName)
at Microsoft.VisualStudio.Shell.ValidateArg.NotNullOrEmpty[T](IEnumerable`1 arg, String parameterName)
at Microsoft.VisualStudio.Shell.Interop.VSProjectExtensions.CompareNormalizedPath(String source, String target)
at Microsoft.VisualStudio.Shell.Interop.VSProjectExtensions.GetKeyOutputForIVsOutputGroup(IVsOutputGroup outputGroup)
at Microsoft.VisualStudio.Shell.Interop.VSProjectExtensions.GetProjectOutputPath(IVsProjectCfg2 projectConfig, String groupName)
at Microsoft.VisualStudio.Shell.Interop.VSProjectExtensions.GetKeyOutputForGroup(IVsSolutionBuildManager buildManager, IVsProject project, String groupName)
at Microsoft.VisualStudio.TestWindow.VsAdapters.VsTestContainer.get_Source()
at Microsoft.VisualStudio.TestWindow.VsAdapters.VsTestContainer.CreateTimeStamp()
at Microsoft.VisualStudio.TestWindow.VsAdapters.VsTestContainer..ctor(ITestContainerDiscoverer discoverer, ILogger log, IVsProject project, IServiceProvider serviceProvider, IVsAppContainerUtilities appContainerUtilities)
at Microsoft.VisualStudio.TestWindow.VsAdapters.VsProjectOutputContainerDiscoverer.<get_TestContainers>b__0(IVsProject p)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Microsoft.VisualStudio.TestWindow.Controller.TestContainerDiscovererExtension.GetSortedContainers(ITestContainerDiscoverer discoverer)
at Microsoft.VisualStudio.TestWindow.Controller.TestContainerProvider.GetContainersFromDiscoverer(ITestContainerDiscoverer discoverer)"
I have tried updating my SSDT version to the latest and that has not been of help to me. Please help I depend on this program for day to day usage.

ILMerge assembly not merged in correctly

I am using ILMerge version 2.11.1103.0 to merge 4 DLL's into a new assembly. Assuming they are called A, B, C, and D, their relationships are as follows:
B -> A
C -> A
D -> A
D -> C
When I run ILMerge on A, B, and C, it all works perfectly fine. However when I add D I receive the following error:
An exception occurred during merging:
ILMerge.Merge: The assembly 'A' was not merged in correctly.
It is still listed as an external reference in the target assembly.
at ILMerging.ILMerge.Merge()
at ILMerging.ILMerge.Main(String[] args)
I have tried using the /closed option as indicated here ILMerge DLL: Assembly not merged in correctly, still listed as an external reference but unfortunately it does not help:
In order to close the target assembly, the number of assemblies to be added to the input is 0.
When I change the order of the assemblies, I receive the following exception:
An exception occurred during merging:
Index was outside the bounds of the array.
at System.Compiler.ISymUnmanagedWriter.CloseMethod()
at System.Compiler.Ir2md.VisitMethodBody(Method method)
at System.Compiler.Ir2md.VisitMethod(Method method)
at System.Compiler.Ir2md.Visit(Node node)
at System.Compiler.Ir2md.VisitClass(Class Class)
at System.Compiler.Ir2md.Visit(Node node)
at System.Compiler.Ir2md.VisitModule(Module module)
at System.Compiler.Ir2md.SetupMetadataWriter(String debugSymbolsLocation)
at System.Compiler.Ir2md.WritePE(Module module, String debugSymbolsLocation, BinaryWriter writer)
at System.Compiler.Writer.WritePE(String location, Boolean writeDebugSymbols, Module module, Boolean delaySign, String keyFileName, String keyName)
at System.Compiler.Writer.WritePE(CompilerParameters compilerParameters, Module module)
at System.Compiler.Module.WriteModule(String location, CompilerParameters options)
at ILMerging.ILMerge.Merge()
at ILMerging.ILMerge.Main(String[] args)
The full command line I'm using is:
ILMerge.exe /targetplatform:v4,"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0" /log:ilmerge.log /target:library /union /xmldocs /copyattrs /allowMultiple /internalize /closed /keyfile:keyfile.snk /out:Merged.dll A B C D
Can anyone see what am I doing wrong? Thanks.
As suggested by #HansPassant in the comment above, I contacted Mike Barnett of Microsoft fame. He was able to help me fix this by:
Upgrading to the latest version of ilmerge (2.12.0803) from http://nuget.org/packages/ilmerge
Removing the /union switch from the command (this was previously added to resolve an issue running gendarme on merged assemblies that had been rewritten by the Code Contracts rewriter. Thankfully due to a change in the build process this was no longer required).
I've encountered issues with ILMerge not working before. I suppose they're just bugs... Try merging in multiple phases, e.g. Merge B and A in to A', then merge A' with C and D. Maybe that will produce different results/errors that might lead to a solution.

Categories