take parameter attributes into account in CreateOptionalRefArg
#1122
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
#1048: Interop method invocations with OptionalAttribute aren't converted
Solution
I decided to leave compiler errors in code, so that
BC30455: Argument not specified for parameter...
becomesCS7036: There is no argument given that corresponds to the required formal parameter...
.Optional
parameter (because it doesn't need to, I guess), so we have 3 compiler errors in the VB.NET code instead of 1 should we reference a C# assembly. This means the output generated looses some compiler errors -- I'm not quite sure if that's ok. We'd need to setup two different projects to have a proper test, which I'm not too keen on doing because of the problems with Handle C#ref return
when converting VB->C# #1116.DefaultParameterValueAttribute
, I usedefault
as initializer. I think this is ok..._semanticModel.Compilation.GetTypeByMetadataName("System.Runtime.InteropServices.DefaultParameterValueAttribute");
to get the attribute class (to keep it consistent with other places). If it fails to find one, I'm assuming it's not present -- which isn't necessarily true, I think, if at all possible. Alternative would be something like this:GetTypeByMetadataName
, but is maybe uglier.