Module.PredefinedAttributes.Dynamic.EmitAttribute (PropertyBuilder, member_type, Location);
}
+ if (member_type.HasNamedTupleElement) {
+ Module.PredefinedAttributes.TupleElementNames.EmitAttribute (PropertyBuilder, member_type, Location);
+ }
+
ConstraintChecker.Check (this, member_type, type_expr.Location);
first.Emit (Parent);
Parent.PartialContainer.Members.Add (BackingField);
FieldExpr fe = new FieldExpr (BackingField, Location);
- if ((BackingField.ModFlags & Modifiers.STATIC) == 0)
+ if ((BackingField.ModFlags & Modifiers.STATIC) == 0) {
fe.InstanceExpression = new CompilerGeneratedThis (Parent.CurrentType, Location);
+ Parent.PartialContainer.HasInstanceField = true;
+ }
//
// Create get block but we careful with location to
return false;
}
+ if (MemberType.Kind == MemberKind.ByRef) {
+ Report.Error (8145, Location, "Auto-implemented property `{0}' cannot return by reference",
+ GetSignatureForError ());
+ return false;
+ }
+
+ if ((Parent.PartialContainer.ModFlags & Modifiers.READONLY) != 0 && Set != null && !IsStatic) {
+ Report.Error (8341, Location, "Auto-implemented instance property `{0}' in readonly structs must be readonly",
+ GetSignatureForError ());
+ }
+
if (Compiler.Settings.Version < LanguageVersion.V_3 && Initializer == null)
Report.FeatureIsNotAvailable (Compiler, Location, "auto-implemented properties");
base.ApplyAttributeBuilder (a, ctor, cdata, pa);
}
+ protected override void DoMemberTypeIndependentChecks ()
+ {
+ if ((Parent.PartialContainer.ModFlags & Modifiers.READONLY) != 0 && (ModFlags & Modifiers.STATIC) == 0) {
+ Report.Error (8342, Location, "`{0}': Field-like instance events are not allowed in readonly structs",
+ GetSignatureForError ());
+ }
+
+ base.DoMemberTypeIndependentChecks ();
+ }
+
public override bool Define()
{
var mod_flags_src = ModFlags;
}
#endregion
+ public static ParametersImported CreateParametersFromSetter (MethodSpec setter, int set_param_count)
+ {
+ //
+ // Creates indexer parameters based on setter method parameters (the last parameter has to be removed)
+ //
+ var data = new IParameterData [set_param_count];
+ var types = new TypeSpec [set_param_count];
+ Array.Copy (setter.Parameters.FixedParameters, data, set_param_count);
+ Array.Copy (setter.Parameters.Types, types, set_param_count);
+ return new ParametersImported (data, types, setter.Parameters.HasParams);
+ }
+
public override string GetSignatureForDocumentation ()
{
return base.GetSignatureForDocumentation () + parameters.GetSignatureForDocumentation ();