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

Multitarget O# external access projects to fix issues accessing prope… #67163

Merged
merged 1 commit into from
Mar 3, 2023

Conversation

dibarbet
Copy link
Member

@dibarbet dibarbet commented Mar 2, 2023

…rties on records

The last PR - #67106 was slightly incorrect - it fixed the build, but caused a bunch of test failures trying to call methods on records

System.MissingMethodException : Method not found: 'Void Microsoft.CodeAnalysis.Completion.CompletionOptions.set_ShowItemsFromUnimportedNamespaces(System.Nullable`1<Boolean>)'.[xUnit.net 00:00:19.95]       Stack Trace:[xUnit.net 00:00:19.95]            at Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Completion.OmniSharpCompletionOptions.ToCompletionOptions()[xUnit.net 00:00:19.95]            at Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Completion.OmniSharpCompletionService.GetCompletionsAsync(CompletionService completionService, Document document, Int32 caretPosition, CompletionTrigger trigger, ImmutableHashSet`1 roles, OmniSharpCompletionOptions options, CancellationToken cancellationToken)[xUnit.net 00:00:19.95]         /home/runner/work/omnisharp-roslyn/omnisharp-roslyn/src/OmniSharp.Roslyn.CSharp/Services/Completion/CompletionService.cs(95,0): at OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService.Handle(CompletionRequest request, Boolean forceExpandedCompletionIndexCreation)[xUnit.net 00:00:19.95]         /home/runner/work/omnisharp-roslyn/omnisharp-roslyn/tests/OmniSharp.Roslyn.CSharp.Tests/CompletionFacts.cs(2281,0): at OmniSharp.Roslyn.CSharp.Tests.CompletionFacts.FindCompletionsAsync(String filename, String source, OmniSharpTestHost testHost, Nullable`1 triggerChar, TestFile[] additionalFiles, Boolean forceExpandedCompletionIndexCreation)[xUnit.net 00:00:19.95]         /home/runner/work/omnisharp-roslyn/omnisharp-roslyn/tests/OmniSharp.Roslyn.CSharp.Tests/CompletionFacts.cs(301,0): at OmniSharp.Roslyn.CSharp.Tests.CompletionFacts.ImportCompletion_OnLine0(String filename, Boolean useAsyncCompletion)[xUnit.net 00:00:19.95]         --- End of stack trace from previous location ---

The root cause of that failure appeared to be a mismatch in the method signatures caused by the workspace version of IsExternalInit

.method public hidebysig specialname         instance void modreq([System.Runtime]System.Runtime.CompilerServices.IsExternalInit) set_ShowItemsFromUnimportedNamespaces (            valuetype [System.Runtime]System.Nullable`1<bool> 'value'        ) cil managed

vs the caller

IL_0016: callvirt instance void modreq([Microsoft.CodeAnalysis.Workspaces]System.Runtime.CompilerServices.IsExternalInit) [Microsoft.CodeAnalysis.Features]Microsoft.CodeAnalysis.Completion.CompletionOptions::set_ShowItemsFromUnimportedNamespaces(valuetype [netstandard]System.Nullable`1<bool>)

Switching over to appropriately multi-target the external access project appears to have fixed the issue in build and in the tests (so far).

@sharwell
Copy link
Member

sharwell commented Mar 3, 2023

Are you interested in the other option here? All we need to do is add a TypeForwardedTo to IsExternalInit.cs so that it's part of the API surface in both binaries. As it stands, we still are creating a netstandard2.0 binary which can't be loaded on a net6.0 execution of the compiler.

Copy link
Member

@sharwell sharwell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to answer the question before proceeding

@sharwell
Copy link
Member

sharwell commented Mar 3, 2023

I'll send a PR for a concrete example here

@sharwell
Copy link
Member

sharwell commented Mar 3, 2023

Submitted #67171

@dibarbet
Copy link
Member Author

dibarbet commented Mar 3, 2023

@sharwell I'm not necessarily opposed to another fix, but O# multi-targets netframework and .netcore already, so multi-targeting the external access project doesn't seem inappropriate to me.

I can try out your change, but I don't think I'll be able to get to it until late this afternoon / Monday.

@sharwell sharwell dismissed their stale review March 3, 2023 19:09

Withdrawing by block on the basis that both binaries here will be used. If we were only building downstream for one target, this wouldn't be an appropriate resolution.

@dibarbet
Copy link
Member Author

dibarbet commented Mar 3, 2023

Going ahead with this change since O# multi-targets and I already tested this one (and CI already finished).

@dibarbet dibarbet merged commit 834823c into dotnet:main Mar 3, 2023
@dibarbet dibarbet deleted the omnisharp_upgrade branch March 3, 2023 19:19
@ghost ghost added this to the Next milestone Mar 3, 2023
@allisonchou allisonchou modified the milestones: Next, 17.6 P3 Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants