Bug 33669

Summary: mcs emits CS1061 while csc does not (compiling class with generic virtual method and constraints)
Product: [Mono] Compilers Reporter: maxim.kropotov
Component: C#Assignee: Marek Safar <masafa>
Status: RESOLVED FIXED    
Severity: normal CC: mono-bugs+mono
Priority: ---    
Version: 4.0.0   
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS   
Tags: Is this bug a regression?: ---
Last known good build:

Description maxim.kropotov 2015-09-04 13:42:27 UTC
When compiling with mcs, the following code causes error CS1061, while csc compiles it without errors.

public abstract class ThingWithOrganizationId
{
	public Guid OrganizationId;
}

public class Thing : ThingWithOrganizationId
{
}

public abstract class  BaseService<TConstraint> 
{
	public abstract void Save<T> (T newThing) where T : TConstraint;
}

public class DerivedService:BaseService<Thing>
{
	public override void Save<TThing>(TThing newThing)
	{
		Console.WriteLine(newThing.OrganizationId);
	}
}

This is the error message returned by the compiler:
error CS1061: Type TThing' does not contain a definition forOrganizationId' and no extension method OrganizationId' of typeTThing' could be found. Are you missing an assembly reference?

I am trying to compile this on a Mac, this is the output of  "mcs --version":
>Mono C# compiler version 4.0.3.0

I am not sure this is a minimal reproduction, but this is the shortest example I've been able to produce.
Moving OrganizationId to the derived Thing class causes this to compile without errors, so does making Save a non-virtual method.
Comment 1 Marek Safar 2015-09-07 10:12:25 UTC
Fixed in master