-//
+//
// RuntimeBinderContext.cs
//
// Authors:
//
using System;
+using System.Collections.Generic;
using Compiler = Mono.CSharp;
namespace Microsoft.CSharp.RuntimeBinder
{
- class RuntimeBinderContext : Compiler.IMemberContext
+ sealed class RuntimeBinderContext : Compiler.IMemberContext
{
- readonly Compiler.CompilerContext ctx;
- readonly Compiler.TypeSpec currentType;
+ readonly Compiler.ModuleContainer module;
+ readonly Type callingType;
+ readonly DynamicContext ctx;
+ Compiler.TypeSpec callingTypeImported;
+
+ public RuntimeBinderContext (DynamicContext ctx, Compiler.TypeSpec callingType)
+ {
+ this.ctx = ctx;
+ this.module = ctx.Module;
+ this.callingTypeImported = callingType;
+ }
- public RuntimeBinderContext (Compiler.CompilerContext ctx, Compiler.TypeSpec currentType)
+ public RuntimeBinderContext (DynamicContext ctx, Type callingType)
{
this.ctx = ctx;
- this.currentType = currentType;
+ this.module = ctx.Module;
+ this.callingType = callingType;
}
#region IMemberContext Members
public Compiler.TypeSpec CurrentType {
- get { return currentType; }
+ get {
+ //
+ // Delay importing of calling type to be compatible with .net
+ // Some libraries are setting it to null which is invalid
+ // but the NullReferenceException is thrown only when the context
+ // is used and not during initialization
+ //
+ if (callingTypeImported == null && callingType != null)
+ callingTypeImported = ctx.ImportType (callingType);
+
+ return callingTypeImported;
+ }
}
- public Compiler.TypeParameter[] CurrentTypeParameters {
+ public Compiler.TypeParameters CurrentTypeParameters {
get { throw new NotImplementedException (); }
}
public Compiler.MemberCore CurrentMemberDefinition {
get {
- // For operators and methods
- return new Compiler.ModuleContainer (currentType.Assembly);
- }
- }
-
- public bool HasUnresolvedConstraints {
- get {
- return false;
+ return null;
}
}
}
public bool IsStatic {
- get { throw new NotImplementedException (); }
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ public Compiler.ModuleContainer Module {
+ get {
+ return module;
+ }
}
public string GetSignatureForError ()
throw new NotImplementedException ();
}
- public Compiler.ExtensionMethodGroupExpr LookupExtensionMethod (Compiler.TypeSpec extensionType, string name, int arity, Mono.CSharp.Location loc)
+ public Compiler.ExtensionMethodCandidates LookupExtensionMethod (Compiler.TypeSpec extensionType, string name, int arity)
{
// No extension method lookup in this context
return null;
}
- public Compiler.FullNamedExpression LookupNamespaceOrType (string name, int arity, Mono.CSharp.Location loc, bool ignore_cs0104)
+ public Compiler.FullNamedExpression LookupNamespaceOrType (string name, int arity, Mono.CSharp.LookupMode mode, Mono.CSharp.Location loc)
{
throw new NotImplementedException ();
}
return null;
}
- public Compiler.CompilerContext Compiler {
- get { return ctx; }
- }
-
#endregion
}
-}
\ No newline at end of file
+}