Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VS 17.3.0 Preview 3.0 Generation failed: System.MissingMethodException: Method not found: 'System.ReadOnlySpan`1<Char> When LangVersion 8.0 or lower #9297

Closed
Rytisgit opened this issue Jul 16, 2022 · 7 comments
Labels
difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification

Comments

@Rytisgit
Copy link

Current behavior

Testing Uno.Samples on VS2022 preview 3 gives error when building projects with LangVersion 8.0 included in the .csproj file.

1>MSBUILD : error : Generation failed: System.MissingMethodException: Method not found: 'System.ReadOnlySpan`1<Char> Microsoft.IO.Path.GetFileName(System.ReadOnlySpan`1<Char>)'.
1>MSBUILD : error : 
1>MSBUILD : error : Server stack trace: 
1>MSBUILD : error :    at Microsoft.Build.Shared.FileMatcher.IsFileNameMatch(String path, String pattern)
1>MSBUILD : error :    at System.Linq.Enumerable.WhereArrayIterator`1.MoveNext()
1>MSBUILD : error :    at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
1>MSBUILD : error :    at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
1>MSBUILD : error :    at Microsoft.Build.Shared.FileMatcher.GetFilesForStep(RecursiveStepResult stepResult, RecursionState recursionState, String projectDirectory, Boolean stripProjectDirectory)
1>MSBUILD : error :    at Microsoft.Build.Shared.FileMatcher.GetFilesRecursive(ConcurrentStack`1 listOfFiles, RecursionState recursionState, String projectDirectory, Boolean stripProjectDirectory, IList`1 searchesToExclude, Dictionary`2 searchesToExcludeInSubdirs, TaskOptions taskOptions)
1>MSBUILD : error :    at Microsoft.Build.Shared.FileMatcher.GetFilesImplementation(String projectDirectoryUnescaped, String filespecUnescaped, List`1 excludeSpecsUnescaped)
1>MSBUILD : error :    at Microsoft.Build.Shared.FileMatcher.<>c__DisplayClass67_0.<GetFiles>b__1(String _)
1>MSBUILD : error :    at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
1>MSBUILD : error :    at Microsoft.Build.Shared.FileMatcher.GetFiles(String projectDirectoryUnescaped, String filespecUnescaped, List`1 excludeSpecsUnescaped)
1>MSBUILD : error :    at Microsoft.Build.Internal.EngineFileUtilities.GetFileList(String directoryEscaped, String filespecEscaped, Boolean returnEscaped, Boolean forceEvaluateWildCards, IEnumerable`1 excludeSpecsEscaped, FileMatcher fileMatcher, Object loggingMechanism, IElementLocation includeLocation, IElementLocation excludeLocation, IElementLocation importLocation, BuildEventContext buildEventContext, String buildEventFileInfoFullPath, Boolean disableExcludeDriveEnumerationWarning)
1>MSBUILD : error :    at Microsoft.Build.Internal.EngineFileUtilities.GetFileListEscaped(String directoryEscaped, String filespecEscaped, IEnumerable`1 excludeSpecsEscaped, Boolean forceEvaluate, FileMatcher fileMatcher, Object loggingMechanism, IElementLocation includeLocation, IElementLocation excludeLocation, IElementLocation importLocation, BuildEventContext buildEventContext, String buildEventFileInfoFullPath, Boolean disableExcludeDriveEnumerationWarning)
1>MSBUILD : error :    at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImportsFromUnescapedImportExpression(String directoryOfImportingFile, ProjectImportElement importElement, String unescapedExpression, Boolean throwOnFileNotExistsError, List`1& imports)
1>MSBUILD : error :    at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImportsFromUnescapedImportExpressionConditioned(String directoryOfImportingFile, ProjectImportElement importElement, List`1& projects, SdkResult& sdkResult, Boolean throwOnFileNotExistsError)
1>MSBUILD : error :    at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImports(String directoryOfImportingFile, ProjectImportElement importElement, SdkResult& sdkResult)
1>MSBUILD : error :    at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
1>MSBUILD : error :    at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
1>MSBUILD : error :    at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
1>MSBUILD : error :    at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
1>MSBUILD : error :    at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
1>MSBUILD : error :    at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
1>MSBUILD : error :    at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
1>MSBUILD : error :    at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
1>MSBUILD : error :    at Microsoft.Build.Evaluation.Evaluator`4.Evaluate()
1>MSBUILD : error :    at Microsoft.Build.Evaluation.Evaluator`4.Evaluate(IEvaluatorData`4 data, Project project, ProjectRootElement root, ProjectLoadSettings loadSettings, Int32 maxNodeCount, PropertyDictionary`1 environmentProperties, ILoggingService loggingService, IItemFactory`2 itemFactory, IToolsetProvider toolsetProvider, ProjectRootElementCacheBase projectRootElementCache, BuildEventContext buildEventContext, ISdkResolverService sdkResolverService, Int32 submissionId, EvaluationContext evaluationContext, Boolean interactive)
1>MSBUILD : error :    at Microsoft.Build.Evaluation.Project.ProjectImpl.Reevaluate(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
1>MSBUILD : error :    at Microsoft.Build.Evaluation.Project.ProjectImpl.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
1>MSBUILD : error :    at Microsoft.Build.Evaluation.Project.ProjectImpl.ReevaluateIfNecessary(EvaluationContext evaluationContext)
1>MSBUILD : error :    at Microsoft.Build.Evaluation.Project.ProjectImpl.Initialize(IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
1>MSBUILD : error :    at Uno.SourceGeneration.Host.ProjectLoader.LoadProjectDetails(BuildEnvironment environment, Dictionary`2 globalProperties) in D:\a\1\s\src\Uno.SourceGeneration.Engine.Shared\ProjectLoader.cs:line 143
1>MSBUILD : error :    at Uno.SourceGeneration.Host.SourceGeneratorEngine.Generate() in D:\a\1\s\src\Uno.SourceGeneration.Engine.Shared\SourceGeneratorEngine.cs:line 85
1>MSBUILD : error :    at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
1>MSBUILD : error :    at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
1>MSBUILD : error : 
1>MSBUILD : error : Exception rethrown at [0]: 
1>MSBUILD : error :    at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
1>MSBUILD : error :    at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
1>MSBUILD : error :    at Uno.SourceGeneratorTasks.RemoteSourceGeneratorEngine.Generate(RemotableLogger2 logger, BuildEnvironment environment)
1>MSBUILD : error :    at Uno.SourceGeneration.Host.Server.GenerationServerHost.GenerateForCollection(EnvironmentPool collection, BuildEnvironment environment) in D:\a\1\s\src\Uno.SourceGeneration.Host\Server\GenerationServerHost.netframework.cs:line 61
1>MSBUILD : error :    at Uno.SourceGeneration.Host.Server.GenerationServerHost.RunGeneration(RunRequest request, CancellationToken cancellationToken) in D:\a\1\s\src\Uno.SourceGeneration.Host\Server\GenerationServerHost.cs:line 73
1>C:\Users\SuperPC\.nuget\packages\uno.sourcegenerationtasks\4.0.2\build\netstandard1.0\Uno.SourceGenerationTasks.targets(134,2): error : Generation failed, error code Rejected
1>Done building project "UnoChat.Client.Wasm.csproj" -- FAILED.

Expected behavior

The samples build successfully. If the LangVersion 8 is not supported, a better message when building to make troubleshooting easier.

How to reproduce it (as minimally and precisely as possible)

Add 8.0 to a .csproj file, these are included in some of the samples, I tested ChatSignalR and SkiaSharpTest, also fails when adding to a sample which doesn't include LangVersion.

Workaround

Update .csproj to use LangVersion 9 or higher

Works on UWP/WinUI

Yes

Environment

No response

NuGet package version(s)

from ChatSignalR sample

<ItemGroup>
    <!-- Note that for WebAssembly version 1.1.1 of the console logger required -->
    <PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="3.1.6" />
    <PackageReference Include="MVx.Observable" Version="2.0.0" />
    <PackageReference Include="Uno.UI.Lottie" Version="4.1.9" />
    <PackageReference Include="Microsoft.Windows.Compatibility" Version="5.0.1" />
    <PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
    <PackageReference Include="Uno.Extensions.Logging.WebAssembly.Console" Version="1.0.1" />
    <PackageReference Include="Uno.UI.WebAssembly" Version="4.1.9" />
    <PackageReference Include="Uno.UI.RemoteControl" Version="4.1.9" Condition="'$(Configuration)'=='Debug'" />
    <PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.1.9" />
    <PackageReference Include="Uno.Wasm.Bootstrap" Version="3.2.0" />
    <PackageReference Include="Uno.Wasm.Bootstrap.DevServer" Version="3.2.0" />
  </ItemGroup>

Affected platforms

Build tasks

IDE

Visual Studio 2022

IDE version

17.3.0 Preview 3.0

Relevant plugins

No response

Anything else we need to know?

No response

@Rytisgit Rytisgit added difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification labels Jul 16, 2022
@francoistanguay
Copy link
Contributor

What a great catch. Thank you, the team will investigate asap now that we have a repro!

@francoistanguay
Copy link
Contributor

So, team found the issue:

The new msbuild shipped with 17.3 Preview 3 includes this commit where they bumped the System.Memory version: dotnet/msbuild@bfd80ab

Our Source Gen Host therefore suddendly become incompatible because of that breaking change.

If you do an bindingRedirect ,in this file it should start working again : "C:\Users\User.nuget\packages\uno.sourcegenerationtasks\4.0.2\build\host\net472\Uno.SourceGeneration.Host.exe.config"
bindingRedirect

Short term, we'll push an update to our Source Generation Host.

@artemious7
Copy link
Contributor

artemious7 commented Jul 20, 2022

Thanks, it did the trick!

The file is in
C:\Users\<user>\.nuget\packages\uno.sourcegenerationtasks\<your_version>\build\host\net472\Uno.SourceGeneration.Host.exe.config

Here's the text to easily paste it:

      <dependentAssembly>
        <assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
      </dependentAssembly>

Save and restart Visual Studio

@francoistanguay
Copy link
Contributor

Thank you for the more accurate details!

@francoistanguay
Copy link
Contributor

francoistanguay commented Jul 23, 2022

The new Uno Source Generation host now tonains the updated dependency to System.Memory so the nuget should be updated to latest dev: https://www.nuget.org/packages/Uno.SourceGenerationTasks/4.1.0-dev.9

The Uno Source Generator is an msbuild tasks used to generate C# code.

@pkar70
Copy link
Contributor

pkar70 commented Aug 18, 2022

So, when my app uses Uno 4.2.6, workaround presented here ("set LangVersion to 9") works. But for newer Uno versions this workaround doesn't work, and app doesn't compile.
What should I do to be able to use Uno > 4.2.6?

@jeromelaban
Copy link
Member

@pkar70 see #9531

trungnt2910 added a commit to AzureAms/TimetableApp.Uno that referenced this issue Aug 26, 2022
Reference the latest Uno.SourceGenerationTasks as a workaround for
unoplatform/uno#9297
michael-hawker added a commit to CommunityToolkit/Labs-Windows that referenced this issue Oct 5, 2022
michael-hawker added a commit to CommunityToolkit/Labs-Windows that referenced this issue Oct 13, 2022
* Adding new controls

* Uno fixes

* Added SettingsExpanderSample

* Adding sampleref

* Bugfixes

* CI fix

* Fix CI

* Adding ExpanderV2

* CI fix

* Update Generic.xaml

* Add overrides

* Uno fixes

* CI fix

* Update ExampleSettingsControlsTestClass.cs

* Simplifing state setting

* Revert "Simplifing state setting"

This reverts commit a014377.

* Quick fix to enable building locally to workaround unoplatform/uno#9297

* Update labs/SettingsControls/samples/SettingsControls.Samples/SettingsExpanderSample.xaml

Co-authored-by: Michael Hawker MSFT (XAML Llama) <24302614+michael-hawker@users.noreply.github.com>

* Update labs/SettingsControls/samples/SettingsControls.Samples/SettingsExpanderSample.xaml

Co-authored-by: Michael Hawker MSFT (XAML Llama) <24302614+michael-hawker@users.noreply.github.com>

* Tweaks

* Renamed ButtonIcon to ActionIcon

* Make SettingsExpander Content a ContentProperty

* File rename

* Making the StyleSelector work

* Add github.com/rudyhuyn/XamlPlus Attached Style Helper

Resolve issue with ToggleSwitch override due to microsoft/microsoft-ui-xaml#7792

* Add binding to Expander option toggle

Note: should be TwoWay bound but issue on Uno, added note here for now: #207 (comment)

* Removing HeaderedContentControl from the template

* XAML styling

* Removed HeaderedContentControl out of the SettingsCard template

* Adding WrapThreshold

* Fix failing test in SettingsCard tests

* Tweaked SettingsCard sample

* XAML styling

* Remove SettingsExpanderItem and use SettingsCard directly

Allows for better interop to just cut/paste SettingsCards in/out of Expanders 🙂

* UI tweaks to samples and SettingsCard to render the correct height

* Adding VSM only

* Temp: Comment out column trigger which was causing control to grow after state change and cause infinite layout cycle

i.e. when the break point was reached (e.g. control size 560), VSM was changing the layout and now control size would be larger again (e.g. 605), which would then turn off trigger and re-layout back to old size which would now be smaller again, etc...

We need to ensure the transition between the Right and Vertical states doesn't increase the width of the control.

* Remove redundant minwidth

* Clean up code, comments

* Code cleanup SettingsCard

* Settings ToolkitSampleRenderer alignment to Stretch

* Bumping version number

* Removing HeaderedContentControl

* Removing remaining reference

* Add triggers

* Update Generic.xaml

* Update Generic.xaml

* Use ThemeResource instead of StaticResource

Co-authored-by: michael-hawker <24302614+michael-hawker@users.noreply.github.com>
Co-authored-by: Rudy Huyn <rudyhuyn@gmail.com>
michael-hawker added a commit to CommunityToolkit/Tooling-Windows-Submodule that referenced this issue Mar 14, 2023
* Adding new controls

* Uno fixes

* Added SettingsExpanderSample

* Adding sampleref

* Bugfixes

* CI fix

* Fix CI

* Adding ExpanderV2

* CI fix

* Update Generic.xaml

* Add overrides

* Uno fixes

* CI fix

* Update ExampleSettingsControlsTestClass.cs

* Simplifing state setting

* Revert "Simplifing state setting"

This reverts commit a014377730da0672d6e8010e58de0d006b0099ba.

* Quick fix to enable building locally to workaround unoplatform/uno#9297

* Update labs/SettingsControls/samples/SettingsControls.Samples/SettingsExpanderSample.xaml

Co-authored-by: Michael Hawker MSFT (XAML Llama) <24302614+michael-hawker@users.noreply.github.com>

* Update labs/SettingsControls/samples/SettingsControls.Samples/SettingsExpanderSample.xaml

Co-authored-by: Michael Hawker MSFT (XAML Llama) <24302614+michael-hawker@users.noreply.github.com>

* Tweaks

* Renamed ButtonIcon to ActionIcon

* Make SettingsExpander Content a ContentProperty

* File rename

* Making the StyleSelector work

* Add github.com/rudyhuyn/XamlPlus Attached Style Helper

Resolve issue with ToggleSwitch override due to microsoft/microsoft-ui-xaml#7792

* Add binding to Expander option toggle

Note: should be TwoWay bound but issue on Uno, added note here for now: CommunityToolkit/Labs-Windows#207 (comment)

* Removing HeaderedContentControl from the template

* XAML styling

* Removed HeaderedContentControl out of the SettingsCard template

* Adding WrapThreshold

* Fix failing test in SettingsCard tests

* Tweaked SettingsCard sample

* XAML styling

* Remove SettingsExpanderItem and use SettingsCard directly

Allows for better interop to just cut/paste SettingsCards in/out of Expanders 🙂

* UI tweaks to samples and SettingsCard to render the correct height

* Adding VSM only

* Temp: Comment out column trigger which was causing control to grow after state change and cause infinite layout cycle

i.e. when the break point was reached (e.g. control size 560), VSM was changing the layout and now control size would be larger again (e.g. 605), which would then turn off trigger and re-layout back to old size which would now be smaller again, etc...

We need to ensure the transition between the Right and Vertical states doesn't increase the width of the control.

* Remove redundant minwidth

* Clean up code, comments

* Code cleanup SettingsCard

* Settings ToolkitSampleRenderer alignment to Stretch

* Bumping version number

* Removing HeaderedContentControl

* Removing remaining reference

* Add triggers

* Update Generic.xaml

* Update Generic.xaml

* Use ThemeResource instead of StaticResource

Co-authored-by: michael-hawker <24302614+michael-hawker@users.noreply.github.com>
Co-authored-by: Rudy Huyn <rudyhuyn@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification
Projects
None yet
Development

No branches or pull requests

5 participants