Skip to content

MissingMethodException when hosting assembly has reference to StreamJsonRpc #243

@soweli-p

Description

@soweli-p

Describe the bug
Hi, it's kinda weird behavior, but if my project which uses proj-info also refers to StreamJsonRpc, proj-info is not able to load any projects, and WorkspaceLoader.LoadProjects returns empty list. I've debugged it a bit and so exception is being thrown somewhere in ProjectLoader.loadProject:

System.MissingMethodException: Method not found: 'Boolean Microsoft.NET.StringTools.SpanBasedStringBuilder.Equals(System.String, System.StringComparison)'.
   at Microsoft.Build.Evaluation.Expander`2.ExtractArgument(SpanBasedStringBuilder argumentBuilder)
   at Microsoft.Build.Evaluation.Expander`2.ExtractFunctionArguments(IElementLocation elementLocation, String expressionFunction, ReadOnlyMemory`1 argumentsMemory)
   at Microsoft.Build.Evaluation.Expander`2.Function`1.ConstructFunction(IElementLocation elementLocation, String expressionFunction, Int32 argumentStartIndex, Int32 methodStartIndex, FunctionBuilder`1& functionBuilder)
   at Microsoft.Build.Evaluation.Expander`2.Function`1.ExtractPropertyFunction(String expressionFunction, IElementLocation elementLocation, Object propertyValue, PropertiesUseTracker propertiesUseTracker, IFileSystem fileSystem, LoggingContext loggingContext)
   at Microsoft.Build.Evaluation.Expander`2.PropertyExpander`1.ExpandPropertyBody(String propertyBody, Object propertyValue, IPropertyProvider`1 properties, ExpanderOptions options, IElementLocation elementLocation, PropertiesUseTracker propertiesUseTracker, IFileSystem fileSystem)
   at Microsoft.Build.Evaluation.Expander`2.PropertyExpander`1.ExpandPropertiesLeaveTypedAndEscaped(String expression, IPropertyProvider`1 properties, ExpanderOptions options, IElementLocation elementLocation, PropertiesUseTracker propertiesUseTracker, IFileSystem fileSystem)
   at Microsoft.Build.Evaluation.Expander`2.ExpandIntoStringLeaveEscaped(String expression, ExpanderOptions options, IElementLocation elementLocation)
   at Microsoft.Build.Evaluation.ConditionEvaluator.ConditionEvaluationState`2.ExpandIntoStringBreakEarly(String expression)
   at Microsoft.Build.Evaluation.StringExpressionNode.EvaluatesToEmpty(IConditionEvaluationState state)
   at Microsoft.Build.Evaluation.MultipleComparisonNode.BoolEvaluate(IConditionEvaluationState state)
   at Microsoft.Build.Evaluation.OperatorExpressionNode.TryBoolEvaluate(IConditionEvaluationState state, Boolean& result)
   at Microsoft.Build.Evaluation.GenericExpressionNode.Evaluate(IConditionEvaluationState state)
   at Microsoft.Build.Evaluation.ConditionEvaluator.EvaluateConditionCollectingConditionedProperties[P,I](String condition, ParserOptions options, Expander`2 expander, ExpanderOptions expanderOptions, Dictionary`2 conditionedPropertiesTable, String evaluationDirectory, ElementLocation elementLocation, IFileSystem fileSystem, LoggingContext loggingContext, ProjectRootElementCacheBase projectRootElementCache)
   at Microsoft.Build.Evaluation.Evaluator`4.EvaluateConditionCollectingConditionedProperties(ProjectElement element, String condition, ExpanderOptions expanderOptions, ParserOptions parserOptions, ProjectRootElementCacheBase projectRootElementCache)
   at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImportsFromUnescapedImportExpressionConditioned(String directoryOfImportingFile, ProjectImportElement importElement, List`1& projects, SdkResult& sdkResult)
   at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImports(String directoryOfImportingFile, ProjectImportElement importElement, SdkResult& sdkResult)
   at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
   at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
   at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
   at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
   at Microsoft.Build.Evaluation.Evaluator`4.Evaluate()
   at Microsoft.Build.Evaluation.Evaluator`4.Evaluate(IEvaluatorData`4 data, Project project, ProjectRootElement root, ProjectLoadSettings loadSettings, Int32 maxNodeCount, PropertyDictionary`1 environmentProperties, ICollection`1 propertiesFromCommandLine, ILoggingService loggingService, IItemFactory`2 itemFactory, IToolsetProvider toolsetProvider, IDirectoryCacheFactory directoryCacheFactory, ProjectRootElementCacheBase projectRootElementCache, BuildEventContext buildEventContext, ISdkResolverService sdkResolverService, Int32 submissionId, EvaluationContext evaluationContext, Boolean interactive)
   at Microsoft.Build.Evaluation.Project.ProjectImpl.Reevaluate(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
   at Microsoft.Build.Evaluation.Project.ProjectImpl.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
   at Microsoft.Build.Evaluation.Project.ProjectImpl.Initialize(IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext, Boolean interactive)
   at Microsoft.Build.Evaluation.Project..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext, IDirectoryCacheFactory directoryCacheFactory, Boolean interactive)
   at Microsoft.Build.Evaluation.Project..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings)
   at Ionide.ProjInfo.ProjectLoader.createNewProject@468(String path, ProjectCollection collection, IDictionary`2 properties) in /_//src/Ionide.ProjInfo/Library.fs:line 470
   at Ionide.ProjInfo.ProjectLoader.action@1(String path, ProjectCollection collection, IDictionary`2 globalProps, Unit _arg3) in /_//src/Ionide.ProjInfo/Library.fs:line 500
   at Ionide.ProjInfo.ProjectLoader.findOrCreateMatchingProject(String path, ProjectCollection collection, IDictionary`2 globalProps) in /_//src/Ionide.ProjInfo/Library.fs:line 495
   at Ionide.ProjInfo.ProjectLoader.loadProject(String path, BinaryLogGeneration binaryLogs, ProjectCollection projectCollection) in /_//src/Ionide.ProjInfo/Library.fs:line 642

To Reproduce
Steps to reproduce the behaviour:

  1. Create new project with fsproj like:
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net10.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="Program.fs" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="StreamJsonRpc" Version="2.22.23" />
    <PackageReference Include="Ionide.ProjInfo" Version="0.73.0"/>
  </ItemGroup>

</Project>

And Program.fs like

open System.IO
open Ionide.ProjInfo
open Ionide.ProjInfo.Types

let directory = Directory.GetCurrentDirectory ()

let toolsPath = Init.init (DirectoryInfo directory) None
let defaultLoader: IWorkspaceLoader = WorkspaceLoader.Create(toolsPath, [])

let projects = defaultLoader.LoadProjects ["test.fsproj"]

for p in projects do
  printfn "%s" p.ProjectFileName

Am I doing something wrong? FsAutoComplete uses both proj-info and StreamJsonRpc and it works somehow

Environment (please complete the following information):

  • OS: nixos 25.05
  • dotnet SDK version: 10.0.100

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions