@@ -558,69 +558,45 @@ public static IEnumerable<object[]> ByValueMarshalAttributeOnValueTypes()
558558
559559 // [In] is default for all non-pinned marshalled types
560560 yield return new object [ ] { ID ( ) , codeSnippets . ByValueMarshallingOfType ( inAttribute , "int" , paramNameWithLocation ) , new DiagnosticResult [ ] {
561- inAttributeIsDefaultDiagnostic ,
562- //https://github.com/dotnet/runtime/issues/88540
563561 inAttributeIsDefaultDiagnostic } } ;
564562 yield return new object [ ] { ID ( ) , codeSnippets . ByValueMarshallingOfType ( inAttribute , "byte" , paramNameWithLocation ) , new DiagnosticResult [ ] {
565- inAttributeIsDefaultDiagnostic ,
566- //https://github.com/dotnet/runtime/issues/88540
567563 inAttributeIsDefaultDiagnostic } } ;
568564 yield return new object [ ] { ID ( ) , codeSnippets . ByValueMarshallingOfType ( inAttribute + "[MarshalAs(UnmanagedType.U4)]" , "bool" , paramNameWithLocation ) , new DiagnosticResult [ ] {
569- inAttributeIsDefaultDiagnostic ,
570- //https://github.com/dotnet/runtime/issues/88540
571565 inAttributeIsDefaultDiagnostic } } ;
572566 yield return new object [ ] { ID ( ) , codeSnippets . ByValueMarshallingOfType ( inAttribute + "[MarshalAs(UnmanagedType.U2)]" , "char" , paramNameWithLocation ) , new DiagnosticResult [ ] {
573- inAttributeIsDefaultDiagnostic ,
574- //https://github.com/dotnet/runtime/issues/88540
575567 inAttributeIsDefaultDiagnostic } } ;
576568
577569 // [Out] is not allowed on value types passed by value - there is no indirection for the callee to make visible modifications.
578570 var outAttributeNotSupportedOnValueParameters = new DiagnosticResult ( GeneratorDiagnostics . ParameterTypeNotSupportedWithDetails )
579571 . WithLocation ( 0 )
580572 . WithArguments ( SR . OutAttributeNotSupportedOnByValueParameters , paramName ) ;
581573 yield return new object [ ] { ID ( ) , codeSnippets . ByValueMarshallingOfType ( outAttribute , "int" , paramNameWithLocation ) , new DiagnosticResult [ ] {
582- outAttributeNotSupportedOnValueParameters ,
583- //https://github.com/dotnet/runtime/issues/88540
584574 outAttributeNotSupportedOnValueParameters } } ;
585575 yield return new object [ ] {
586576 ID ( ) ,
587577 codeSnippets . ByValueMarshallingOfType ( outAttribute , "IntStruct" , paramNameWithLocation ) + CodeSnippets . IntStructAndMarshaller ,
588578 new DiagnosticResult [ ] {
589- outAttributeNotSupportedOnValueParameters ,
590- //https://github.com/dotnet/runtime/issues/88540
591- outAttributeNotSupportedOnValueParameters ,
579+ outAttributeNotSupportedOnValueParameters
592580 } } ;
593581 yield return new object [ ] { ID ( ) , codeSnippets . ByValueMarshallingOfType ( outAttribute + "[MarshalAs(UnmanagedType.U4)]" , "bool" , paramNameWithLocation ) , new DiagnosticResult [ ] {
594- outAttributeNotSupportedOnValueParameters ,
595- //https://github.com/dotnet/runtime/issues/88540
596582 outAttributeNotSupportedOnValueParameters
597583 } } ;
598584 yield return new object [ ] { ID ( ) , codeSnippets . ByValueMarshallingOfType ( outAttribute , "[MarshalAs(UnmanagedType.U2)] char" , paramNameWithLocation ) , new DiagnosticResult [ ] {
599- outAttributeNotSupportedOnValueParameters ,
600- //https://github.com/dotnet/runtime/issues/88540
601585 outAttributeNotSupportedOnValueParameters
602586 } } ;
603587 // [In,Out] should only warn for Out attribute
604588 yield return new object [ ] { ID ( ) , codeSnippets . ByValueMarshallingOfType ( inAttribute + outAttribute , "int" , paramNameWithLocation ) , new DiagnosticResult [ ] {
605- outAttributeNotSupportedOnValueParameters ,
606- //https://github.com/dotnet/runtime/issues/88540
607589 outAttributeNotSupportedOnValueParameters } } ;
608590 yield return new object [ ] {
609591 ID ( ) ,
610592 codeSnippets . ByValueMarshallingOfType ( inAttribute + outAttribute , "IntStruct" , paramNameWithLocation ) + CodeSnippets . IntStructAndMarshaller ,
611593 new DiagnosticResult [ ] {
612- outAttributeNotSupportedOnValueParameters ,
613- //https://github.com/dotnet/runtime/issues/88540
614- outAttributeNotSupportedOnValueParameters ,
594+ outAttributeNotSupportedOnValueParameters
615595 } } ;
616596 yield return new object [ ] { ID ( ) , codeSnippets . ByValueMarshallingOfType ( inAttribute + outAttribute + "[MarshalAs(UnmanagedType.U4)]" , "bool" , paramNameWithLocation ) , new DiagnosticResult [ ] {
617- outAttributeNotSupportedOnValueParameters ,
618- //https://github.com/dotnet/runtime/issues/88540
619597 outAttributeNotSupportedOnValueParameters
620598 } } ;
621599 yield return new object [ ] { ID ( ) , codeSnippets . ByValueMarshallingOfType ( inAttribute + outAttribute , "[MarshalAs(UnmanagedType.U2)] char" , paramNameWithLocation ) , new DiagnosticResult [ ] {
622- outAttributeNotSupportedOnValueParameters ,
623- //https://github.com/dotnet/runtime/issues/88540
624600 outAttributeNotSupportedOnValueParameters
625601 } } ;
626602
@@ -688,12 +664,12 @@ public static IEnumerable<object[]> ByValueMarshalAttributeOnReferenceTypes()
688664 yield return new object [ ] {
689665 ID ( ) ,
690666 codeSnippets . ByValueMarshallingOfType ( inAttribute , "string" , paramNameWithLocation , ( StringMarshalling . Utf8 , null ) ) ,
691- new DiagnosticResult [ ] { inAttributeIsDefaultDiagnostic , inAttributeIsDefaultDiagnostic }
667+ new DiagnosticResult [ ] { inAttributeIsDefaultDiagnostic }
692668 } ;
693669 yield return new object [ ] {
694670 ID ( ) ,
695671 codeSnippets . ByValueMarshallingOfType ( inAttribute , "IntClass" , paramNameWithLocation ) + CodeSnippets . IntClassAndMarshaller ,
696- new DiagnosticResult [ ] { inAttributeIsDefaultDiagnostic , inAttributeIsDefaultDiagnostic }
672+ new DiagnosticResult [ ] { inAttributeIsDefaultDiagnostic }
697673 } ;
698674
699675 var outNotAllowedOnRefTypes = new DiagnosticResult ( GeneratorDiagnostics . ParameterTypeNotSupportedWithDetails )
@@ -704,21 +680,21 @@ public static IEnumerable<object[]> ByValueMarshalAttributeOnReferenceTypes()
704680 yield return new object [ ] {
705681 ID ( ) ,
706682 codeSnippets . ByValueMarshallingOfType ( outAttribute , "string" , paramNameWithLocation , ( StringMarshalling . Utf8 , null ) ) ,
707- new DiagnosticResult [ ] { outNotAllowedOnRefTypes , outNotAllowedOnRefTypes }
683+ new DiagnosticResult [ ] { outNotAllowedOnRefTypes }
708684 } ;
709685
710686 // [Out] warns on by value reference types
711687 yield return new object [ ] {
712688 ID ( ) ,
713689 codeSnippets . ByValueMarshallingOfType ( outAttribute , "IntClass" , paramNameWithLocation ) + CodeSnippets . IntClassAndMarshaller ,
714- new DiagnosticResult [ ] { outNotAllowedOnRefTypes , outNotAllowedOnRefTypes }
690+ new DiagnosticResult [ ] { outNotAllowedOnRefTypes }
715691 } ;
716692
717693 // [In,Out] is fine on classes
718694 yield return new object [ ] {
719695 ID ( ) ,
720696 codeSnippets . ByValueMarshallingOfType ( inAttribute + outAttribute , "IntClass" , paramNameWithLocation ) + CodeSnippets . IntClassAndMarshaller ,
721- new DiagnosticResult [ ] { outNotAllowedOnRefTypes , outNotAllowedOnRefTypes }
697+ new DiagnosticResult [ ] { outNotAllowedOnRefTypes }
722698 } ;
723699
724700 // All refkinds are okay on classes and strings
@@ -774,11 +750,10 @@ public static IEnumerable<object[]> ByValueMarshalAttributeOnPinnedMarshalledTyp
774750 . WithLocation ( 0 )
775751 . WithArguments ( SR . InAttributeOnlyNotSupportedOnPinnedParameters , paramName ) ;
776752 yield return new object [ ] { ID ( ) , codeSnippets . ByValueMarshallingOfType ( inAttribute + constElementCount , "int[]" , paramNameWithLocation ) , new DiagnosticResult [ ] {
777- inAttributeNotSupportedOnPinnedParameter ,
778- //https://github.com/dotnet/runtime/issues/88540
779753 inAttributeNotSupportedOnPinnedParameter
780754 } } ;
781- // new issue before merge: char generated code doesn't seem to work well with [In, Out]
755+ // blittable arrays don't support [In] only. Different diagnostics are issued because we can pin in one direction (managed->unmanaged)
756+ // but not the other direction.
782757 yield return new object [ ] {
783758 ID ( ) ,
784759 codeSnippets . ByValueMarshallingOfType ( inAttribute + constElementCount , "char[]" , paramNameWithLocation , ( StringMarshalling . Utf16 , null ) ) ,
@@ -793,13 +768,13 @@ public static IEnumerable<object[]> ByValueMarshalAttributeOnPinnedMarshalledTyp
793768 "bool[]" ,
794769 paramNameWithLocation ,
795770 ( StringMarshalling . Utf16 , null ) ) ,
796- new DiagnosticResult [ ] { inAttributeIsDefaultDiagnostic , inAttributeIsDefaultDiagnostic }
771+ new DiagnosticResult [ ] { inAttributeIsDefaultDiagnostic }
797772 } ;
798773 // Overriding marshalling with a custom marshaller makes it not pinned
799774 yield return new object [ ] {
800775 ID ( ) ,
801776 codeSnippets . ByValueMarshallingOfType ( inAttribute , "[MarshalUsing(typeof(IntMarshaller), ElementIndirectionDepth = 1), MarshalUsing(ConstantElementCount = 10)]int[]" , paramNameWithLocation ) + CodeSnippets . IntMarshaller ,
802- new DiagnosticResult [ ] { inAttributeIsDefaultDiagnostic , inAttributeIsDefaultDiagnostic }
777+ new DiagnosticResult [ ] { inAttributeIsDefaultDiagnostic }
803778 } ;
804779
805780 // [In, Out] is default
@@ -811,12 +786,12 @@ public static IEnumerable<object[]> ByValueMarshalAttributeOnPinnedMarshalledTyp
811786 yield return new object [ ] {
812787 ID ( ) ,
813788 codeSnippets . ByValueMarshallingOfType ( inAttribute + outAttribute + constElementCount , "int[]" , paramNameWithLocation ) ,
814- new DiagnosticResult [ ] { inOutAttributeIsDefaultDiagnostic , inOutAttributeIsDefaultDiagnostic }
789+ new DiagnosticResult [ ] { inOutAttributeIsDefaultDiagnostic }
815790 } ;
816791 yield return new object [ ] {
817792 ID ( ) ,
818793 codeSnippets . ByValueMarshallingOfType ( inAttribute + outAttribute + constElementCount , "char[]" , paramNameWithLocation , ( StringMarshalling . Utf16 , null ) ) ,
819- //https://github.com/dotnet/runtime/issues/88540
794+ //https://github.com/dotnet/runtime/issues/88708
820795 new DiagnosticResult [ ] { inOutAttributeIsDefaultDiagnostic }
821796 } ;
822797
@@ -847,7 +822,7 @@ public async Task VerifyByValueMarshallingAttributeUsage(string id, string sourc
847822 {
848823 TestCode = source ,
849824 TestBehaviors = TestBehaviors . SkipGeneratedSourcesCheck ,
850- // Our fallback mechanism for invalid code for unmanaged->managed stubs sometimes generates invalid code.
825+ // https://github.com/dotnet/runtime/issues/88708
851826 CompilerDiagnostics = diagnostics . Length != 0 ? CompilerDiagnostics . None : CompilerDiagnostics . Errors ,
852827 } ;
853828 test . ExpectedDiagnostics . AddRange ( diagnostics ) ;
0 commit comments