Ambiguous type references resolved to first match?

SyntaxEditor .NET Languages Add-on for Silverlight Forum

Posted 12 years ago by Peter Palotas
Version: 12.1.0562
Avatar

Assume I have a file containing an ambiguous type name in a variable declaration. (A type with the specified name exists in two namespaces and both namespaced are imported using a using-statement).

When executing

var context = new CSharpContextFactory().CreateContext(new ActiproSoftware.Text.TextSnapshotOffset(document.CurrentSnapshot, qn.StartOffset.Value));
IResolverResultSet results = context.Resolve();

where qn is a QualifiedName instance, the result set returned from Resolve() only contains one match, (the one from the namespace that was first imported it seems). Why aren't both matches returned here?

Comments (3)

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Peter,

It looks like this scenario only occurs if the types are defined in the same assembly.  It's due to how we track results in our resolver while working through them.  At the moment, only one result per assembly is stored.  So if your two types with the same name were in different assemblies, you would get two results.  We've marked this down to try and improve in the future, but it would require some redesign of our resolver's internals to handle properly.


Actipro Software Support

Posted 12 years ago by Peter Palotas
Avatar

Okay, thanks... do you have any idea on how I could go about to manually verify whether the result returned is indeed ambiguous?  That is to say, is there another way I can check whether a given QualifiedName is ambiguous in a given context or not?

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Peter,

What you are currently doing is really the only way to check such things.  It will work in nearly all cases except for the one you found where a type with the same name is defined twice within the same assembly.  Unfortuntely I don't think there's anything else that would give you good contextual-based results.


Actipro Software Support

The latest build of this product (v18.1 build 0233) was released 4 years ago, which was after the last post in this thread.