class Foo<T, U>
{
public bool Test() => true;
public T GenericFoo() => default(T);
public void GenericFoo(T value) { }
}
object obj = new Foo<int>();
((Foo<,>)obj).Test(); //GenericFoo methods of class Foo<,> should not be available in this case.
Foo<,> foo = (Foo<,>)obj;
((Foo<int,byte>)foo).GenericFoo()
class Foo<T> where T: Delegate
class Foo<T<U>>
But I very much suspect that it's not possible or too hard to implement.
public static var Foo = 0;
{
Foo();
return true;
}
catch return false;
{
}
catch(Exception ex)
{
rethrow ex; // bad example, but it's the same as just "throw;" in this case.
}
class Foo
{
public int Bar => this.bar;
private int bar;
public int this[string key] => 0;
public MemberInfo[] GetMembers<T>(bool someValue)
{
MethodInfo mi = memberof(this.ToString); // no need to cast
return new []
{
memberof(this.Bar),
memberof(this.bar),
memberof(this.GetMembers<T>(bool)), // specifying parameter types in case of overloading.
memberof(string.GetEnumerator), // It works like nameof operator
memberof(this[string]) // even indexers..
};
}
}
Also implementation must not use the search by function name using strings or something like, because it won't work after code obfuscation.
C# language change requests are taken at the http://github.com/dotnet/csharplang/ repository now. You'd want to make separate proposals rather than one mega-proposal. Many of these requests have already been made in one form or another, some championed and some already explained why they're not practical.
@DenisKudelin I'll go ahead and close the issue and let you re-open on csharplang. Thanks
Most helpful comment
C# language change requests are taken at the http://github.com/dotnet/csharplang/ repository now. You'd want to make separate proposals rather than one mega-proposal. Many of these requests have already been made in one form or another, some championed and some already explained why they're not practical.