@@ -558,69 +558,45 @@ public static IEnumerable<object[]> ByValueMarshalAttributeOnValueTypes()
558
558
559
559
// [In] is default for all non-pinned marshalled types
560
560
yield return new object [ ] { ID ( ) , codeSnippets . ByValueMarshallingOfType ( inAttribute , "int" , paramNameWithLocation ) , new DiagnosticResult [ ] {
561
- inAttributeIsDefaultDiagnostic ,
562
- //https://github.com/dotnet/runtime/issues/88540
563
561
inAttributeIsDefaultDiagnostic } } ;
564
562
yield return new object [ ] { ID ( ) , codeSnippets . ByValueMarshallingOfType ( inAttribute , "byte" , paramNameWithLocation ) , new DiagnosticResult [ ] {
565
- inAttributeIsDefaultDiagnostic ,
566
- //https://github.com/dotnet/runtime/issues/88540
567
563
inAttributeIsDefaultDiagnostic } } ;
568
564
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
571
565
inAttributeIsDefaultDiagnostic } } ;
572
566
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
575
567
inAttributeIsDefaultDiagnostic } } ;
576
568
577
569
// [Out] is not allowed on value types passed by value - there is no indirection for the callee to make visible modifications.
578
570
var outAttributeNotSupportedOnValueParameters = new DiagnosticResult ( GeneratorDiagnostics . ParameterTypeNotSupportedWithDetails )
579
571
. WithLocation ( 0 )
580
572
. WithArguments ( SR . OutAttributeNotSupportedOnByValueParameters , paramName ) ;
581
573
yield return new object [ ] { ID ( ) , codeSnippets . ByValueMarshallingOfType ( outAttribute , "int" , paramNameWithLocation ) , new DiagnosticResult [ ] {
582
- outAttributeNotSupportedOnValueParameters ,
583
- //https://github.com/dotnet/runtime/issues/88540
584
574
outAttributeNotSupportedOnValueParameters } } ;
585
575
yield return new object [ ] {
586
576
ID ( ) ,
587
577
codeSnippets . ByValueMarshallingOfType ( outAttribute , "IntStruct" , paramNameWithLocation ) + CodeSnippets . IntStructAndMarshaller ,
588
578
new DiagnosticResult [ ] {
589
- outAttributeNotSupportedOnValueParameters ,
590
- //https://github.com/dotnet/runtime/issues/88540
591
- outAttributeNotSupportedOnValueParameters ,
579
+ outAttributeNotSupportedOnValueParameters
592
580
} } ;
593
581
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
596
582
outAttributeNotSupportedOnValueParameters
597
583
} } ;
598
584
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
601
585
outAttributeNotSupportedOnValueParameters
602
586
} } ;
603
587
// [In,Out] should only warn for Out attribute
604
588
yield return new object [ ] { ID ( ) , codeSnippets . ByValueMarshallingOfType ( inAttribute + outAttribute , "int" , paramNameWithLocation ) , new DiagnosticResult [ ] {
605
- outAttributeNotSupportedOnValueParameters ,
606
- //https://github.com/dotnet/runtime/issues/88540
607
589
outAttributeNotSupportedOnValueParameters } } ;
608
590
yield return new object [ ] {
609
591
ID ( ) ,
610
592
codeSnippets . ByValueMarshallingOfType ( inAttribute + outAttribute , "IntStruct" , paramNameWithLocation ) + CodeSnippets . IntStructAndMarshaller ,
611
593
new DiagnosticResult [ ] {
612
- outAttributeNotSupportedOnValueParameters ,
613
- //https://github.com/dotnet/runtime/issues/88540
614
- outAttributeNotSupportedOnValueParameters ,
594
+ outAttributeNotSupportedOnValueParameters
615
595
} } ;
616
596
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
619
597
outAttributeNotSupportedOnValueParameters
620
598
} } ;
621
599
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
624
600
outAttributeNotSupportedOnValueParameters
625
601
} } ;
626
602
@@ -688,12 +664,12 @@ public static IEnumerable<object[]> ByValueMarshalAttributeOnReferenceTypes()
688
664
yield return new object [ ] {
689
665
ID ( ) ,
690
666
codeSnippets . ByValueMarshallingOfType ( inAttribute , "string" , paramNameWithLocation , ( StringMarshalling . Utf8 , null ) ) ,
691
- new DiagnosticResult [ ] { inAttributeIsDefaultDiagnostic , inAttributeIsDefaultDiagnostic }
667
+ new DiagnosticResult [ ] { inAttributeIsDefaultDiagnostic }
692
668
} ;
693
669
yield return new object [ ] {
694
670
ID ( ) ,
695
671
codeSnippets . ByValueMarshallingOfType ( inAttribute , "IntClass" , paramNameWithLocation ) + CodeSnippets . IntClassAndMarshaller ,
696
- new DiagnosticResult [ ] { inAttributeIsDefaultDiagnostic , inAttributeIsDefaultDiagnostic }
672
+ new DiagnosticResult [ ] { inAttributeIsDefaultDiagnostic }
697
673
} ;
698
674
699
675
var outNotAllowedOnRefTypes = new DiagnosticResult ( GeneratorDiagnostics . ParameterTypeNotSupportedWithDetails )
@@ -704,21 +680,21 @@ public static IEnumerable<object[]> ByValueMarshalAttributeOnReferenceTypes()
704
680
yield return new object [ ] {
705
681
ID ( ) ,
706
682
codeSnippets . ByValueMarshallingOfType ( outAttribute , "string" , paramNameWithLocation , ( StringMarshalling . Utf8 , null ) ) ,
707
- new DiagnosticResult [ ] { outNotAllowedOnRefTypes , outNotAllowedOnRefTypes }
683
+ new DiagnosticResult [ ] { outNotAllowedOnRefTypes }
708
684
} ;
709
685
710
686
// [Out] warns on by value reference types
711
687
yield return new object [ ] {
712
688
ID ( ) ,
713
689
codeSnippets . ByValueMarshallingOfType ( outAttribute , "IntClass" , paramNameWithLocation ) + CodeSnippets . IntClassAndMarshaller ,
714
- new DiagnosticResult [ ] { outNotAllowedOnRefTypes , outNotAllowedOnRefTypes }
690
+ new DiagnosticResult [ ] { outNotAllowedOnRefTypes }
715
691
} ;
716
692
717
693
// [In,Out] is fine on classes
718
694
yield return new object [ ] {
719
695
ID ( ) ,
720
696
codeSnippets . ByValueMarshallingOfType ( inAttribute + outAttribute , "IntClass" , paramNameWithLocation ) + CodeSnippets . IntClassAndMarshaller ,
721
- new DiagnosticResult [ ] { outNotAllowedOnRefTypes , outNotAllowedOnRefTypes }
697
+ new DiagnosticResult [ ] { outNotAllowedOnRefTypes }
722
698
} ;
723
699
724
700
// All refkinds are okay on classes and strings
@@ -774,11 +750,10 @@ public static IEnumerable<object[]> ByValueMarshalAttributeOnPinnedMarshalledTyp
774
750
. WithLocation ( 0 )
775
751
. WithArguments ( SR . InAttributeOnlyNotSupportedOnPinnedParameters , paramName ) ;
776
752
yield return new object [ ] { ID ( ) , codeSnippets . ByValueMarshallingOfType ( inAttribute + constElementCount , "int[]" , paramNameWithLocation ) , new DiagnosticResult [ ] {
777
- inAttributeNotSupportedOnPinnedParameter ,
778
- //https://github.com/dotnet/runtime/issues/88540
779
753
inAttributeNotSupportedOnPinnedParameter
780
754
} } ;
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.
782
757
yield return new object [ ] {
783
758
ID ( ) ,
784
759
codeSnippets . ByValueMarshallingOfType ( inAttribute + constElementCount , "char[]" , paramNameWithLocation , ( StringMarshalling . Utf16 , null ) ) ,
@@ -793,13 +768,13 @@ public static IEnumerable<object[]> ByValueMarshalAttributeOnPinnedMarshalledTyp
793
768
"bool[]" ,
794
769
paramNameWithLocation ,
795
770
( StringMarshalling . Utf16 , null ) ) ,
796
- new DiagnosticResult [ ] { inAttributeIsDefaultDiagnostic , inAttributeIsDefaultDiagnostic }
771
+ new DiagnosticResult [ ] { inAttributeIsDefaultDiagnostic }
797
772
} ;
798
773
// Overriding marshalling with a custom marshaller makes it not pinned
799
774
yield return new object [ ] {
800
775
ID ( ) ,
801
776
codeSnippets . ByValueMarshallingOfType ( inAttribute , "[MarshalUsing(typeof(IntMarshaller), ElementIndirectionDepth = 1), MarshalUsing(ConstantElementCount = 10)]int[]" , paramNameWithLocation ) + CodeSnippets . IntMarshaller ,
802
- new DiagnosticResult [ ] { inAttributeIsDefaultDiagnostic , inAttributeIsDefaultDiagnostic }
777
+ new DiagnosticResult [ ] { inAttributeIsDefaultDiagnostic }
803
778
} ;
804
779
805
780
// [In, Out] is default
@@ -811,12 +786,12 @@ public static IEnumerable<object[]> ByValueMarshalAttributeOnPinnedMarshalledTyp
811
786
yield return new object [ ] {
812
787
ID ( ) ,
813
788
codeSnippets . ByValueMarshallingOfType ( inAttribute + outAttribute + constElementCount , "int[]" , paramNameWithLocation ) ,
814
- new DiagnosticResult [ ] { inOutAttributeIsDefaultDiagnostic , inOutAttributeIsDefaultDiagnostic }
789
+ new DiagnosticResult [ ] { inOutAttributeIsDefaultDiagnostic }
815
790
} ;
816
791
yield return new object [ ] {
817
792
ID ( ) ,
818
793
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
820
795
new DiagnosticResult [ ] { inOutAttributeIsDefaultDiagnostic }
821
796
} ;
822
797
@@ -847,7 +822,7 @@ public async Task VerifyByValueMarshallingAttributeUsage(string id, string sourc
847
822
{
848
823
TestCode = source ,
849
824
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
851
826
CompilerDiagnostics = diagnostics . Length != 0 ? CompilerDiagnostics . None : CompilerDiagnostics . Errors ,
852
827
} ;
853
828
test . ExpectedDiagnostics . AddRange ( diagnostics ) ;
0 commit comments