public Microsoft.FSharp.Quotations.FSharpExpr GetInvokerExpression(MethodBase syntheticMethodBase, Microsoft.FSharp.Quotations.FSharpExpr[] parameters) { Helpers.TraceCall(); if (syntheticMethodBase is System.Reflection.ConstructorInfo) { Debug.Assert(false, "NYI"); throw new NotImplementedException(); } else if (syntheticMethodBase is System.Reflection.MethodInfo) { var am = syntheticMethodBase as ArtificialMethodInfo; if (am.DeclaringType.FullName == "N.T" && am.Name == "M") { return(FSharpExpr.Lambda(FSharpVar.Global("", typeof(int[])), FSharpExpr.Value <int[]>(new[] { 1, 2, 3 }))); } else { Debug.Assert(false, "NYI"); throw new NotImplementedException(); } } else { Debug.Assert(false, "GetInvokerExpression() invoked with neither ConstructorInfo nor MethodInfo!"); return(null); } }
// TODO: what is this? protected override System.Reflection.TypeAttributes GetAttributeFlagsImpl() { Helpers.TraceCall(); //return TypeAttributes.AutoLayout | TypeAttributes.AnsiClass | TypeAttributes.Class | TypeAttributes.NestedPublic | TypeAttributes.ClassSemanticsMask | TypeAttributes.Abstract | TypeAttributes.Serializable; return((_IsInterface ? TypeAttributes.Interface : TypeAttributes.Class) | TypeAttributes.Public | (_IsAbstract ? TypeAttributes.Abstract : 0) | (TypeAttributes)TypeProviderTypeAttributes.IsErased); }
// By spec this NOT supposed to be called! // TODO: re-enable assert when bug is fixed public override bool Equals(Type o) { Helpers.TraceCall(); //Debug.Assert(false, "You should not call Equals"); //throw new NotImplementedException(); return(base.Equals(o)); }
public override MethodInfo GetRaiseMethod(bool nonPublic) { Helpers.TraceCall(); Debug.Assert(false, "NYI"); //throw new NotImplementedException(); return(null); }
// No events... public override System.Reflection.EventInfo GetEvent(string name, System.Reflection.BindingFlags bindingAttr) { Helpers.TraceCall(); // According to the spec, we should only expect these 4, so we guard against that here! Debug.Assert(bindingAttr == (BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly), "bindingAttr has value not according to the spec!"); return(null); }
public override Type[] GetNestedTypes(System.Reflection.BindingFlags bindingAttr) { Helpers.TraceCall(); // According to the spec, we should only expect these 4, so we guard against that here! Debug.Assert(bindingAttr == (BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly), "bindingAttr has value not according to the spec!"); return(new Type[] { }); }
// TODO: update when bug 199859 is fixed. // We should never be here (I think) public override int GetHashCode() { Helpers.TraceCall(); return(base.GetHashCode()); //Debug.Assert(false, "NYI"); //throw new NotImplementedException(); }
public override object[] GetCustomAttributes(Type attributeType, bool inherit) { Helpers.TraceCall(); Debug.Assert(inherit == false, "Is it expected that 'inherit' is true?"); var attrs = new List <Attribute>(); if (attributeType == typeof(TypeProviderXmlDocAttribute)) { attrs.Add(new TypeProviderXmlDocAttribute("This is a synthetic *method* created by me!")); } else if (attributeType == typeof(TypeProviderDefinitionLocationAttribute)) { var f = System.IO.Path.GetTempFileName() + ".fs"; System.IO.File.WriteAllText(f, string.Format("// This is a fake definition file to test TypeProviderDefinitionLocationAttribute for method {0}.{1}.{2}\nnamespace {0}\ntype {1} = static member {2}() = [|1,2,3|]", _DeclaringType.Namespace, _DeclaringType.Name, _Name)); attrs.Add(new TypeProviderDefinitionLocationAttribute() { Column = 22 + _DeclaringType.Name.Length, FilePath = f, Line = 3 }); } else { throw new Exception(string.Format("Are we looking for an undocumented attribute '{0}'?", attributeType.Name)); } return(attrs.ToArray()); }
public Type ApplyStaticArguments(Type typeWithoutArguments, string[] typePathWithArguments, object[] staticArguments) { //Console.WriteLine("Hello from ApplyStaticArguments"); //var n = new myType(typeof(N.S), "S,\"1\"", typeof(object), false); //return n; Helpers.TraceCall(); return(null); }
public override object[] GetCustomAttributes(bool inherit) { Helpers.TraceCall(); Debug.Assert(inherit == false, "Is it expected that 'inherit' is true?"); var a = new TypeProviderXmlDocAttribute("This is a synthetic type created by me?"); return(new[] { a }); }
// This method is called when in the source file we have something like: // - N.T.StaticProp // (most likely also when we have an instance prop...) // name -> "StaticProp" protected override System.Reflection.PropertyInfo GetPropertyImpl(string name, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, Type returnType, Type[] types, System.Reflection.ParameterModifier[] modifiers) { Helpers.TraceCall(); // According to the spec, we should only expect these 4, so we guard against that here! Debug.Assert(bindingAttr == (BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly), "bindingAttr has value not according to the spec!"); Debug.Assert(binder == null && returnType == null && types == null && modifiers == null, "One of binder, returnType, types, or modifiers was not null"); return(null); }
public Type ResolveTypeName(string typeName) { Helpers.TraceCall(); if (typeName == _Name) { return(myType); } return(null); }
// When you start typing more interesting things like... // let a = N.T.M() // this one gets invoked... public override System.Reflection.MethodInfo[] GetMethods(System.Reflection.BindingFlags bindingAttr) { Helpers.TraceCall(); // According to the spec, we should only expect these 4, so we guard against that here! Debug.Assert(bindingAttr == (BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly), "bindingAttr has value not according to the spec!"); var m = new ArtificialMethodInfo("M", this); return(new[] { m }); }
public override MethodInfo GetRemoveMethod(bool nonPublic) { Helpers.TraceCall(); #if GetRemoveMethodReturnsNull return(null); #else return(new ArtificialMethodInfo("foo_remove", this.DeclaringType, typeof(void))); #endif }
public Type ResolveTypeName(string typeName) { Helpers.TraceCall(); if (typeName == _Name) { return(myType); } Debug.Assert(false, "NYI"); return(null); }
// This one is now invoked when IsGenericType/IsArray/IsByref/IsPointer return true // public override Type GetGenericTypeDefinition() { Helpers.TraceCall(); if (_IsGenericType) { return(typeof(Tuple)); //a.GetType(); } else { Debug.Assert(false, "Why are we here?"); throw new NotImplementedException(); } }
// Events... public override System.Reflection.EventInfo[] GetEvents(System.Reflection.BindingFlags bindingAttr) { Helpers.TraceCall(); if (_IsInterface) { return new System.Reflection.EventInfo[] { } } ; else { return _Event1 != null ? new [] { _Event1 } } : new System.Reflection.EventInfo[] { }; }
// This one seems to be invoked when in IDE, I type something like: // let _ = typeof<N. // In this case => no constructors public override System.Reflection.ConstructorInfo[] GetConstructors(System.Reflection.BindingFlags bindingAttr) { Helpers.TraceCall(); // According to the spec, we should only expect these 4, so we guard against that here! Debug.Assert(bindingAttr == (BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly), "bindingAttr has value not according to the spec!"); if (_Ctor1 != null) { return new System.Reflection.ConstructorInfo[] { _Ctor1 } } ; else { return new System.Reflection.ConstructorInfo[] { } }; }
// This is invoked if the IsGenericType is true public override Type[] GetGenericArguments() { Helpers.TraceCall(); if (_IsGenericType) { return new Type[] { typeof(int), typeof(decimal), typeof(System.Guid) } } ; else { Debug.Assert(false, "Why are we here?"); throw new NotImplementedException(); } }
// Advertise our property... // I think that is this one returns an empty array => you don't get intellisense/autocomplete in IDE/FSI public override System.Reflection.PropertyInfo[] GetProperties(System.Reflection.BindingFlags bindingAttr) { Helpers.TraceCall(); // According to the spec, we should only expect these 4, so we guard against that here! Debug.Assert(bindingAttr == (BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly), "bindingAttr has value not according to the spec!"); if (_IsInterface) { return new PropertyInfo[] { } } ; else { return new PropertyInfo[] { _Property1, _Property2, _Property3 } }; }
public override IList <CustomAttributeData> GetCustomAttributesData() { Helpers.TraceCall(); var attrs = new List <CustomAttributeData>(); attrs.Add(new Helpers.TypeProviderCustomAttributeData(new TypeProviderXmlDocAttribute("This is a synthetic type created by me!"))); var f = System.IO.Path.GetTempFileName() + ".fs"; System.IO.File.WriteAllText(f, string.Format("// This is a fake definition file to test TypeProviderDefinitionLocationAttribute for type {0}.{1}\nnamespace {0}\ntype {1} = // blah", _Namespace, _Name)); attrs.Add(new Helpers.TypeProviderCustomAttributeData(new TypeProviderDefinitionLocationAttribute() { Column = 5, FilePath = f, Line = 3 })); attrs.Add(new Helpers.TypeProviderCustomAttributeData(new TypeProviderEditorHideMethodsAttribute())); return(attrs); }
public override System.Reflection.FieldInfo[] GetFields(System.Reflection.BindingFlags bindingAttr) { Helpers.TraceCall(); // According to the spec, we should only expect these 4, so we guard against that here! Debug.Assert(bindingAttr == (BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly), "bindingAttr has value not according to the spec!"); return(new System.Reflection.FieldInfo[] { _Field_null, _Field_single, _Field_double, _Field_bool, _Field_char, _Field_string, _Field_sbyte, _Field_byte, _Field_int16, _Field_uint16, _Field_int, _Field_uint32, _Field_int64, _Field_uint64, _Field_decimal, _Field_enum, _Field_TypeThatHasToStringThatThrows, _InstField_null, _InstField_single, _InstField_double, _InstField_bool, _InstField_char, _InstField_string, _InstField_sbyte, _InstField_byte, _InstField_int16, _InstField_uint16, _InstField_int, _InstField_uint32, _InstField_int64, _InstField_uint64, _InstField_decimal, _InstField_enum, _InstField_TypeThatHasToStringThatThrows }); }
public override IList <CustomAttributeData> GetCustomAttributesData() { Helpers.TraceCall(); var attrs = new List <CustomAttributeData>(); attrs.Add(new Helpers.TypeProviderCustomAttributeData(new TypeProviderXmlDocAttribute(string.Format("This is a synthetic *property* created by me for {0}.{1}", this._DeclaringType.Namespace, this._DeclaringType.Name)))); var f = System.IO.Path.GetTempFileName() + ".fs"; System.IO.File.WriteAllText(f, string.Format("// This is a fake definition file to test TypeProviderDefinitionLocationAttribute for type {0}.{1}\nnamespace {0}\ntype {1}() = static member {2} with get() = // blah", this._DeclaringType.Namespace, this._DeclaringType.Name, this.Name)); attrs.Add(new Helpers.TypeProviderCustomAttributeData(new TypeProviderDefinitionLocationAttribute() { Column = 19 + this._DeclaringType.Name.Length, FilePath = f, Line = 3 })); attrs.Add(new Helpers.TypeProviderCustomAttributeData(new TypeProviderEditorHideMethodsAttribute())); return(attrs); }
public Microsoft.FSharp.Quotations.FSharpExpr GetInvokerExpression(MethodBase syntheticMethodBase, Microsoft.FSharp.Quotations.FSharpExpr[] parameters) { Helpers.TraceCall(); if (syntheticMethodBase is System.Reflection.ConstructorInfo) { var ac = syntheticMethodBase as ArtificialConstructorInfo; if (ac.DeclaringType.FullName == "N.T") { return(FSharpExpr.DefaultValue(ac.DeclaringType.BaseType)); } Debug.Assert(false, "NYI"); throw new NotImplementedException(); } else if (syntheticMethodBase is System.Reflection.MethodInfo) { var am = syntheticMethodBase as ArtificialMethodInfo; if (am.DeclaringType.FullName == "N.T" && am.Name == "M") { return(FSharpExpr.Lambda(FSharpVar.Global("", typeof(int[])), FSharpExpr.Value <int[]>(new[] { 1, 2, 3 }))); } else if (am.DeclaringType.FullName == "N.T" && am.Name == "get_StaticProp") { return(FSharpExpr.Lambda(FSharpVar.Global("", typeof(decimal)), FSharpExpr.Value <decimal>(4.2M))); } else { Debug.Assert(false, "NYI"); throw new NotImplementedException(); } } else { Debug.Assert(false, "GetInvokerExpression() invoked with neither ConstructorInfo nor MethodInfo!"); return(null); } //Expression<Func<S>> e = () => new S(9); //return e.Body; //throw new NotImplementedException(); }
public Microsoft.FSharp.Quotations.FSharpExpr GetInvokerExpression(MethodBase syntheticMethodBase, Microsoft.FSharp.Quotations.FSharpExpr[] parameters) { Helpers.TraceCall(); if (syntheticMethodBase is System.Reflection.ConstructorInfo) { var ac = syntheticMethodBase as ArtificialConstructorInfo; if (ac.DeclaringType.FullName == "N.T") { return(FSharpExpr.DefaultValue(ac.DeclaringType.BaseType)); } Debug.Assert(false, "NYI"); throw new NotImplementedException(); } else if (syntheticMethodBase is System.Reflection.MethodInfo) { Debug.Assert(false, "Why are we here?"); throw new NotImplementedException(); } else { Debug.Assert(false, "GetInvokerExpression() invoked with neither ConstructorInfo nor MethodInfo!"); return(null); } }
public override object[] GetCustomAttributes(bool inherit) { Helpers.TraceCall(); System.Diagnostics.Debug.Assert(false, "NYI"); throw new NotImplementedException(); }
public override bool Equals(object obj) { Helpers.TraceCall(); System.Diagnostics.Debug.Assert(false, "BUG: We should not be calling Equals()"); throw new NotImplementedException(); }
public override void SetValueDirect(TypedReference obj, object value) { Helpers.TraceCall(); System.Diagnostics.Debug.Assert(false, "NYI"); throw new NotImplementedException(); }
public override string ToString() { Helpers.TraceCall(); System.Diagnostics.Debug.Assert(false, "NYI"); throw new NotImplementedException(); }
public override void SetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, System.Globalization.CultureInfo culture) { Helpers.TraceCall(); System.Diagnostics.Debug.Assert(false, "NYI"); throw new NotImplementedException(); }