+ //
+ // Type lookup of documentation references uses context of type where
+ // the reference is used but type parameters from cref value
+ //
+ sealed class DocumentationMemberContext : IMemberContext
+ {
+ readonly MemberCore host;
+ MemberName contextName;
+
+ public DocumentationMemberContext (MemberCore host, MemberName contextName)
+ {
+ this.host = host;
+ this.contextName = contextName;
+ }
+
+ public TypeSpec CurrentType {
+ get {
+ return host.CurrentType;
+ }
+ }
+
+ public TypeParameters CurrentTypeParameters {
+ get {
+ return contextName.TypeParameters;
+ }
+ }
+
+ public MemberCore CurrentMemberDefinition {
+ get {
+ return host.CurrentMemberDefinition;
+ }
+ }
+
+ public bool IsObsolete {
+ get {
+ return false;
+ }
+ }
+
+ public bool IsUnsafe {
+ get {
+ return host.IsStatic;
+ }
+ }
+
+ public bool IsStatic {
+ get {
+ return host.IsStatic;
+ }
+ }
+
+ public ModuleContainer Module {
+ get {
+ return host.Module;
+ }
+ }
+
+ public string GetSignatureForError ()
+ {
+ return host.GetSignatureForError ();
+ }
+
+ public ExtensionMethodCandidates LookupExtensionMethod (TypeSpec extensionType, string name, int arity)
+ {
+ return null;
+ }
+
+ public FullNamedExpression LookupNamespaceOrType (string name, int arity, LookupMode mode, Location loc)
+ {
+ if (arity == 0) {
+ var tp = CurrentTypeParameters;
+ if (tp != null) {
+ for (int i = 0; i < tp.Count; ++i) {
+ var t = tp[i];
+ if (t.Name == name) {
+ t.Type.DeclaredPosition = i;
+ return new TypeParameterExpr (t, loc);
+ }
+ }
+ }
+ }
+
+ return host.Parent.LookupNamespaceOrType (name, arity, mode, loc);
+ }
+
+ public FullNamedExpression LookupNamespaceAlias (string name)
+ {
+ throw new NotImplementedException ();
+ }
+ }
+