Skip to content

Instantly share code, notes, and snippets.

@undeadcat
Last active September 4, 2015 17:15
Show Gist options
  • Save undeadcat/289423c4341a6275d8d9 to your computer and use it in GitHub Desktop.
Save undeadcat/289423c4341a6275d8d9 to your computer and use it in GitHub Desktop.
Mono Generic Constraint Bug?
public abstract class ThingWithOrganizationId
{
public Guid OrganizationId;
}
public class Thing : ThingWithOrganizationId
{
}
public abstract class BaseService<TConstraint>
{
public abstract void Save<T> (T newView) where T : TConstraint;
}
public class DerivedService:BaseService<Thing>
{
public override void Save<TThing>(TThing newView)
{
Console.WriteLine(newView.OrganizationId);
}
}
@undeadcat
Copy link
Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment