if ((base_classp & MethodAttributes.FamORAssem) == MethodAttributes.FamORAssem){
//
// when overriding protected internal, the method can be declared
- // protected internal only within the same assembly
+ // protected internal only within the same assembly or assembly
+ // which has InternalsVisibleTo
//
-
if ((thisp & MethodAttributes.FamORAssem) == MethodAttributes.FamORAssem){
- if (Parent.TypeBuilder.Assembly != base_method.DeclaringType.Assembly){
- //
- // assemblies differ - report an error
- //
-
- return false;
- } else if (thisp != base_classp) {
+ if (Parent.TypeBuilder.Assembly != base_method.DeclaringType.Assembly)
+ return TypeManager.IsFriendAssembly (base_method.DeclaringType.Assembly);
+
+ if (thisp != base_classp) {
//
// same assembly, but other attributes differ - report an error
//
return false;
- };
+ }
} else if ((thisp & MethodAttributes.Family) != MethodAttributes.Family) {
//
// if it's not "protected internal", it must be "protected"
FieldAttributes fa = Modifiers.FieldAttr (ModFlags);
- if (Parent.PartialContainer.Kind == Kind.Struct &&
- ((fa & FieldAttributes.Static) == 0) &&
- MemberType == Parent.TypeBuilder &&
- !TypeManager.IsBuiltinType (MemberType)){
- Report.Error (523, Location, "Struct member `" + Parent.Name + "." + Name +
- "' causes a cycle in the structure layout");
- return false;
- }
-
try {
FieldBuilder = Parent.TypeBuilder.DefineField (
Name, MemberType, Modifiers.FieldAttr (ModFlags));
if (initializer != null)
((TypeContainer) Parent).RegisterFieldForInitialization (this,
new FieldInitializer (FieldBuilder, initializer));
+
+ if (Parent.PartialContainer.Kind == Kind.Struct && (fa & FieldAttributes.Static) == 0 &&
+ MemberType == Parent.TypeBuilder && !TypeManager.IsBuiltinType (MemberType) && initializer == null) {
+ Report.Error (523, Location, "Struct member `{0}' causes a cycle in the structure layout",
+ GetSignatureForError ());
+ return false;
+ }
+
return true;
}
Modifiers.SEALED |
Modifiers.OVERRIDE |
Modifiers.ABSTRACT |
- Modifiers.UNSAFE |
+ Modifiers.UNSAFE |
Modifiers.EXTERN |
Modifiers.METHOD_YIELDS |
Modifiers.VIRTUAL;
Field field = new Field (
Parent, Type,
Modifiers.COMPILER_GENERATED | Modifiers.PRIVATE | (ModFlags & Modifiers.STATIC),
- CompilerGeneratedClass.MakeName (null, "CompilerGeneratedField"),
- null, Location);
+ "<" + Name + ">k__BackingField", null, Location);
((TypeContainer)Parent).AddField (field);
// Make get block
is_iface ? AllowedInterfaceModifiers : AllowedModifiers,
is_iface, name, attrs, define_set_first)
{
- if (RootContext.Version >= LanguageVersion.LINQ &&
- !is_iface &&
- (mod & (Modifiers.ABSTRACT | Modifiers.EXTERN)) == 0 &&
+ if (!is_iface && (mod & (Modifiers.ABSTRACT | Modifiers.EXTERN)) == 0 &&
get_block != null && get_block.Block == null &&
- set_block != null && set_block.Block == null)
+ set_block != null && set_block.Block == null) {
+ if (RootContext.Version <= LanguageVersion.ISO_2)
+ Report.FeatureIsNotAvailable (Location, "automatically implemented properties");
+
CreateAutomaticProperty (current_block, get_block, set_block);
+ }
if (get_block == null)
Get = new GetMethod (this);
if (TypeManager.IsGenericType (MemberType))
SetMemberIsUsed();
+ if (Add.IsInterfaceImplementation)
+ SetMemberIsUsed ();
+
FieldBuilder = Parent.TypeBuilder.DefineField (
Name, MemberType,
FieldAttributes.Private | ((ModFlags & Modifiers.STATIC) != 0 ? FieldAttributes.Static : 0));
get { return null; }
}
+ public bool IsInterfaceImplementation {
+ get { return method_data.implementing != null; }
+ }
+
public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb)
{
if (a.IsInternalMethodImplAttribute) {
//
// Now name the parameters
//
- Parameter [] p = parameters.FixedParameters;
- if (p != null) {
- // TODO: should be done in parser and it needs to do cycle
- if ((p [0].ModFlags & Parameter.Modifier.ISBYREF) != 0) {
- CSharpParser.Error_ParameterModifierNotValid (Location);
- return false;
- }
- }
-
PropertyBuilder = Parent.TypeBuilder.DefineProperty (
Name, PropertyAttributes.None, MemberType, parameters.Types);