The .NET Compiler Platform ("Roslyn") provides open-source C# and Visual Basic compilers with rich code analysis APIs.
Hey people, just a sanity check before I waste more time... can I have a source generator create a class with a partial unimplemented method, and then have the user implement that method in a class they write manually?
Generation works, and the compiler complains afterword's that CS8795 Partial method 'MyClass.MyMethod(CancellationToken)' must have an implementation part because it has accessibility modifiers
.
But when I in the user project create a class in the right namespace with the right name, the CS8795 error goes away but is replaced with a CS0759 No defining declaration found for implementing declaration of partial method 'MyClass.MeMethod(CancellationToken)'
.
So that leads me to think that this approach is not possible?
public int Try() {
int sum=0;
try{
for (int i=0; i<100; i++)
sum+=i;
} catch{}
return sum;
}
public int NoTry() {
int sum=0;
for (int i=0; i<100; i++)
sum+=i;
return sum;
}
adding a try{...}catch{} around a trivial for loop can strongly affect its optimisation ; is this expected?