diff --git a/src/Microsoft.Windows.CsWin32/Generator.FriendlyOverloads.cs b/src/Microsoft.Windows.CsWin32/Generator.FriendlyOverloads.cs index 82d66f85..a0634618 100644 --- a/src/Microsoft.Windows.CsWin32/Generator.FriendlyOverloads.cs +++ b/src/Microsoft.Windows.CsWin32/Generator.FriendlyOverloads.cs @@ -284,7 +284,7 @@ private IEnumerable DeclareFriendlyOverloads(MethodDefi { remainsRefType = false; parameters[param.SequenceNumber - 1] = parameters[param.SequenceNumber - 1] - .WithType((isIn && isConst ? MakeReadOnlySpanOfT(elementType) : MakeSpanOfT(elementType)).WithTrailingTrivia(TriviaList(Space))); + .WithType((isIn ? MakeReadOnlySpanOfT(elementType) : MakeSpanOfT(elementType)).WithTrailingTrivia(TriviaList(Space))); fixedBlocks.Add(VariableDeclaration(externParam.Type).AddVariables( VariableDeclarator(localName.Identifier).WithInitializer(EqualsValueClause(origName)))); arguments[param.SequenceNumber - 1] = Argument(localName); @@ -323,7 +323,7 @@ private IEnumerable DeclareFriendlyOverloads(MethodDefi // Accept a span instead of a pointer. parameters[param.SequenceNumber - 1] = parameters[param.SequenceNumber - 1] - .WithType((isIn && isConst ? MakeReadOnlySpanOfT(elementType) : MakeSpanOfT(elementType)).WithTrailingTrivia(TriviaList(Space))); + .WithType((isIn ? MakeReadOnlySpanOfT(elementType) : MakeSpanOfT(elementType)).WithTrailingTrivia(TriviaList(Space))); fixedBlocks.Add(VariableDeclaration(externParam.Type).AddVariables( VariableDeclarator(localName.Identifier).WithInitializer(EqualsValueClause(origName)))); arguments[param.SequenceNumber - 1] = Argument(localName); diff --git a/test/Microsoft.Windows.CsWin32.Tests/FriendlyOverloadTests.cs b/test/Microsoft.Windows.CsWin32.Tests/FriendlyOverloadTests.cs index 6a284180..bacc16be 100644 --- a/test/Microsoft.Windows.CsWin32.Tests/FriendlyOverloadTests.cs +++ b/test/Microsoft.Windows.CsWin32.Tests/FriendlyOverloadTests.cs @@ -47,6 +47,16 @@ public void SpecializedRAIIFree_OutParameter() Assert.Equal("DsGetDcCloseWSafeHandle", Assert.IsType(method.ParameterList.Parameters.Last().Type).Identifier.ValueText); } + [Fact] + public void InAttributeOnArraysProjectedAsReadOnlySpan() + { + const string Method = "RmRegisterResources"; + this.GenerateApi(Method); + + MethodDeclarationSyntax method = Assert.Single(this.FindGeneratedMethod(Method), m => !IsOrContainsExternMethod(m)); + Assert.Equal(3, method.ParameterList.Parameters.Count(p => p.Type is GenericNameSyntax { Identifier.ValueText: "ReadOnlySpan" })); + } + private void Generate(string name) { this.compilation = this.compilation.WithOptions(this.compilation.Options.WithPlatform(Platform.X64));