public override void ApplyAttributeBuilder(Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { if (a.Target == AttributeTargets.Assembly) { assembly.ApplyAttributeBuilder(a, ctor, cdata, pa); return; } if (a.Type == pa.DefaultCharset) { switch (a.GetCharSetValue()) { case CharSet.Ansi: case CharSet.None: break; case CharSet.Auto: DefaultCharSet = CharSet.Auto; DefaultCharSetType = TypeAttributes.AutoClass; break; case CharSet.Unicode: DefaultCharSet = CharSet.Unicode; DefaultCharSetType = TypeAttributes.UnicodeClass; break; default: Report.Error(1724, a.Location, "Value specified for the argument to `{0}' is not valid", a.GetSignatureForError()); break; } } else if (a.Type == pa.CLSCompliant) { Attribute cls = DeclaringAssembly.CLSCompliantAttribute; if (cls == null) { Report.Warning(3012, 1, a.Location, "You must specify the CLSCompliant attribute on the assembly, not the module, to enable CLS compliance checking"); } else if (DeclaringAssembly.IsCLSCompliant != a.GetBoolean()) { Report.SymbolRelatedToPreviousError(cls.Location, cls.GetSignatureForError()); Report.Warning(3017, 1, a.Location, "You cannot specify the CLSCompliant attribute on a module that differs from the CLSCompliant attribute on the assembly"); return; } } builder.SetCustomAttribute((ConstructorInfo)ctor.GetMetaInfo(), cdata); }
protected override bool CheckBase() { if (!base.CheckBase()) { return(false); } MemberSpec candidate; bool overrides = false; var conflict_symbol = MemberCache.FindBaseMember(this, out candidate, ref overrides); if (conflict_symbol == null) { conflict_symbol = candidate; } if (conflict_symbol == null) { if ((ModFlags & Modifiers.NEW) != 0) { Report.Warning(109, 4, Location, "The member `{0}' does not hide an inherited member. The new keyword is not required", GetSignatureForError()); } } else { if ((ModFlags & (Modifiers.NEW | Modifiers.OVERRIDE | Modifiers.BACKING_FIELD)) == 0) { Report.SymbolRelatedToPreviousError(conflict_symbol); Report.Warning(108, 2, Location, "`{0}' hides inherited member `{1}'. Use the new keyword if hiding was intended", GetSignatureForError(), conflict_symbol.GetSignatureForError()); } if (conflict_symbol.IsAbstract) { Report.SymbolRelatedToPreviousError(conflict_symbol); Report.Error(533, Location, "`{0}' hides inherited abstract member `{1}'", GetSignatureForError(), conflict_symbol.GetSignatureForError()); } } return(true); }
public static void Error_VariableOfStaticClass (Location loc, string variable_name, TypeSpec static_class, Report Report) { Report.SymbolRelatedToPreviousError (static_class); Report.Error (723, loc, "`{0}': cannot declare variables of static types", variable_name); }
protected override bool DoDefineMembers() { var builtin_types = Compiler.BuiltinTypes; var ctor_parameters = ParametersCompiled.CreateFullyResolved( new [] { new Parameter(new TypeExpression(builtin_types.Object, Location), "object", Parameter.Modifier.NONE, null, Location), new Parameter(new TypeExpression(builtin_types.IntPtr, Location), "method", Parameter.Modifier.NONE, null, Location) }, new [] { builtin_types.Object, builtin_types.IntPtr } ); Constructor = new Constructor(this, Constructor.ConstructorName, Modifiers.PUBLIC, null, ctor_parameters, Location); Constructor.Define(); // // Here the various methods like Invoke, BeginInvoke etc are defined // // First, call the `out of band' special method for // defining recursively any types we need: // var p = parameters; if (!p.Resolve(this)) { return(false); } // // Invoke method // // Check accessibility foreach (var partype in p.Types) { if (!IsAccessibleAs(partype)) { Report.SymbolRelatedToPreviousError(partype); Report.Error(59, Location, "Inconsistent accessibility: parameter type `{0}' is less accessible than delegate `{1}'", partype.GetSignatureForError(), GetSignatureForError()); } } var ret_type = ReturnType.ResolveAsType(this); if (ret_type == null) { return(false); } // // We don't have to check any others because they are all // guaranteed to be accessible - they are standard types. // if (!IsAccessibleAs(ret_type)) { Report.SymbolRelatedToPreviousError(ret_type); Report.Error(58, Location, "Inconsistent accessibility: return type `" + ret_type.GetSignatureForError() + "' is less " + "accessible than delegate `" + GetSignatureForError() + "'"); return(false); } CheckProtectedModifier(); if (Compiler.Settings.StdLib && ret_type.IsSpecialRuntimeType) { Method.Error1599(Location, ret_type, Report); return(false); } VarianceDecl.CheckTypeVariance(ret_type, Variance.Covariant, this); var resolved_rt = new TypeExpression(ret_type, Location); InvokeBuilder = new Method(this, resolved_rt, MethodModifiers, new MemberName(InvokeMethodName), p, null); InvokeBuilder.Define(); // // Don't emit async method for compiler generated delegates (e.g. dynamic site containers) // if (!IsCompilerGenerated) { DefineAsyncMethods(resolved_rt); } return(true); }
public static void Error_VariableOfStaticClass(Location loc, string variable_name, TypeSpec static_class, Report Report) { Report.SymbolRelatedToPreviousError(static_class); Report.Error(723, loc, "`{0}': cannot declare variables of static types", variable_name); }