Open Inspyro opened 9 years ago
The above example throws in the trace assert, as it cannot find the AttributeConstructor (it only finds an ErrorType for someAttribute)
+1 I'm facing the same problem.
@gafter, @Pilchie Seems like a bug to me, shouldn't this have the "Bug" label rather than the "Questions" label?
shouldn't this have the "Bug" label rather than the "Questions" label?
@fschmied That is the question. I believe the answer is "no", but it requires investigation.
Any recent thoughts on this?
@j3parker It's safe to assume that if there hasn't been any further discussion or links here then nothing really had changed. IMO, this is not a bug. It's an intrinsic way the Compilation/SemanticModel apis work. Barring any major shifts in thinking here, the right way to deal with this would be to add the appropriate references to the compilation, then ask semantic model questions. Thanks!
Assume the following project layout: ProjectA declares a custom attribute ProjectB references ProjectA and uses the custom attribute on ClassA ProjectC references ProjectB and uses ClassA in ClassB
Now we want get the AttributeData (compiled version of the custom attribute) by using the semantic model of ProjectC, however we only get an ErrorType as long as ProjectC does not reference ProjectA (the one that contains the custom attribute).
Is this a Roslyn bug? Or is there a way to retrieve the AttributeData without adding a reference to ProjectA.
Here is the source code to reproduce the issue