You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Resolve a CS0104 ambiguity instead of guessing at its cause
CS0104 is the fifth most common Sandbox build error, and the runs it
kills are the ones that report it more than once: all three runs in the
cached corpus that hit it two or three times finished
sandbox_inconclusive, while the eight that resolved it in one attempt
mostly reached a candidate. A failed compile does not consume a semantic
attempt, so an unresolved ambiguity quietly spends the build retries.
The advice blamed a PlatformConfiguration import, which is one of the ten
distinct ambiguities actually observed; the rest are Android.Widget,
Microsoft.UI.Xaml, Microsoft.Maui.Platform and neighbouring
Microsoft.Maui namespaces, for which that cause is simply absent.
The diagnostic already names both candidates, so parse it and say which
one a Sandbox page means: the cross-platform type over a platform one,
the control over a non-control when both are cross-platform, and neither
when there is no basis to choose.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 735ac9a2-7bec-4baa-ad19-c298e5bc795a
Copy file name to clipboardExpand all lines: .github/scripts/Replicate-Issue.Tests.ps1
+100Lines changed: 100 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -107,6 +107,7 @@ BeforeAll {
107
107
'Assert-GeneratedSandboxSources',
108
108
'Get-ReplicationFixBaselineGreenCause',
109
109
'Get-ReplicationMissingIdentifierEvidence',
110
+
'Get-ReplicationAmbiguousTypeEvidence',
110
111
'Get-ReplicationIdentifierSiteRank',
111
112
'Set-ReplicationVerificationRunCount',
112
113
'Test-ReplicationFixBaselineStillRed',
@@ -13495,3 +13496,102 @@ Describe 'A verified reproduction survives a fix-phase timeout' {
13495
13496
}
13496
13497
}
13497
13498
13499
+
Describe 'A CS0104 ambiguity is resolved, not re-described' {
13500
+
# Fifth most common Sandbox build error in the corpus. Runs that resolved it
13501
+
# in one attempt mostly reached CANDIDATE READY; all three that reported it
13502
+
# two or three times finished sandbox_inconclusive. The standing advice
13503
+
# blamed a PlatformConfiguration import, which is 1 of the 10 distinct
13504
+
# ambiguities actually observed. Every fixture below is corpus-verbatim.
13505
+
It 'recommends the cross-platform type over a platform one' -ForEach @(
13506
+
@{ D = "CS0104: 'Button' is an ambiguous reference between 'Microsoft.Maui.Controls.Button' and 'Android.Widget.Button'"
13507
+
Want = 'Microsoft.Maui.Controls.Button' }
13508
+
@{ D = "CS0104: 'ContentView' is an ambiguous reference between 'Microsoft.Maui.Controls.ContentView' and 'Microsoft.Maui.Platform.ContentView'"
13509
+
Want = 'Microsoft.Maui.Controls.ContentView' }
13510
+
@{ D = "CS0104: 'Map' is an ambiguous reference between 'Microsoft.Maui.ApplicationModel.Map' and 'Microsoft.Maui.Controls.Maps.Map'"
13511
+
Want = 'Microsoft.Maui.Controls.Maps.Map' }
13512
+
@{ D = "CS0104: 'Page' is an ambiguous reference between 'Microsoft.Maui.Controls.Page' and 'Microsoft.UI.Xaml.Controls.Page'"
13513
+
Want = 'Microsoft.Maui.Controls.Page' }
13514
+
@{ D = "CS0104: 'Rect' is an ambiguous reference between 'Android.Graphics.Rect' and 'Microsoft.Maui.Graphics.Rect'"
13515
+
Want = 'Microsoft.Maui.Graphics.Rect' }
13516
+
@{ D = "CS0104: 'ScrollView' is an ambiguous reference between 'Microsoft.Maui.Controls.ScrollView' and 'Android.Widget.ScrollView'"
13517
+
Want = 'Microsoft.Maui.Controls.ScrollView' }
13518
+
@{ D = "CS0104: 'TextChangedEventArgs' is an ambiguous reference between 'Microsoft.Maui.Controls.TextChangedEventArgs' and 'Microsoft.UI.Xaml.Controls.TextChangedEventArgs'"
$lines.Add(("'{0}' is ambiguous between '{1}' and '{2}'; a Sandbox page is cross-platform MAUI UI, so write '{1}' fully qualified, or alias it with 'using {3} = {1};', rather than removing either using."-f$name,$first,$second, ('M'+$name)))
$lines.Add(("'{0}' is ambiguous between '{1}' and '{2}'; a Sandbox page is cross-platform MAUI UI, so write '{2}' fully qualified, or alias it with 'using {3} = {2};', rather than removing either using."-f$name,$first,$second, ('M'+$name)))
1197
+
} else {
1198
+
$lines.Add(("'{0}' is ambiguous between '{1}' and '{2}'; both are cross-platform MAUI namespaces, so fully qualify whichever one the scenario needs - do not assume."-f$name,$first,$second))
1199
+
}
1200
+
}
1201
+
1202
+
if ($lines.Count-eq0) {
1203
+
return''
1204
+
}
1205
+
1206
+
return ('The diagnostic already names both candidates. '+ ($lines-join''))
The Sandbox build failed with these compiler diagnostics: $prepareDiagnostics
7548
7677
Fix the authored Sandbox source so it compiles. This repository builds with warnings as errors. Resolve ambiguous type references such as ILayout by fully qualifying the intended type, match the exact overload signature of the API you call, and give collection expressions a constructible target type.
7549
-
A CS0104 ambiguity on VisualElement, Page, Application, Entry or similar usually means the file imports Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific, AndroidSpecific or WindowsSpecific, each of which declares its own static class with that name. Drop the platform-specific using and call the platform helper through its full namespace instead. Do not guess at member names on those helpers; use only members you have confirmed in this repository's source.
7678
+
A CS0104 ambiguity on VisualElement, Page, Application, Entry or similar usually means the file imports Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific, AndroidSpecific or WindowsSpecific, each of which declares its own static class with that name. Drop the platform-specific using and call the platform helper through its full namespace instead. Do not guess at member names on those helpers; use only members you have confirmed in this repository's source.$ambiguityNote
0 commit comments