If this analyzer ever would be a C# language feature then it would have its own syntax for the exception declarations, based on how it's done in Java:
using System;
public class Example
{
public void RiskyMethod()
throws InvalidOperationException, ArgumentException
{
// Omitted: Code that might throw
}
}
Which would be lowered to:
using System;
public class Example
{
[Throws(
typeof(InvalidOperationException),
typeof(ArgumentException))]
public void RiskyMethod()
{
// Omitted: Code that might throw
}
}
But this could be seen as going against it being optional, I think. Since you would be forced to use it if its part of the language and ecosystem.
If this analyzer ever would be a C# language feature then it would have its own syntax for the exception declarations, based on how it's done in Java:
Which would be lowered to:
But this could be seen as going against it being optional, I think. Since you would be forced to use it if its part of the language and ecosystem.