/
githubmirror
/
roslyn
Обзор
Документация
Войти
/
githubmirror
/
roslyn
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/RelaxedShiftOperatorTests.vb
69 строк
2 KB
Tomáš Matoušek
Refactoring of extension methods in source packages (#78620) - take 2 (#78894)
26 июн 2025, 18:42
Не верифицирован
26 июн 2025, 18:42
05fc006
Код
Авторство
О чём код?
' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. Imports Microsoft.CodeAnalysis.Test.Utilities Imports Roslyn.Test.Utilities Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests Public Class RelaxedShiftOperatorTests Inherits BasicTestBase <Fact> Public Sub Consumption_01() Dim csSource = " public class C1 { public static C1 operator <<(C1 x, C1 y) { System.Console.WriteLine(""<<""); return x; } } " Dim csCompilation = CreateCSharpCompilation(csSource, parseOptions:=CSharp.CSharpParseOptions.Default.WithLanguageVersion(CSharp.LanguageVersion.Preview), referencedAssemblies:=TargetFrameworkUtil.GetReferences(TargetFramework.Standard)).EmitToImageReference() Dim source1 = <compilation> <file name="c.vb"><![CDATA[ Public Class C Shared Sub Main() Dim c1 As New C1() Dim x = c1 << c1 End Sub End Class ]]></file> </compilation> Dim comp1 = CreateCompilation(source1, references:={csCompilation}) comp1.AssertTheseDiagnostics( <errors><![CDATA[ BC30452: Operator '<<' is not defined for types 'C1' and 'C1'. Dim x = c1 << c1 ~~~~~~~~ ]]></errors> ) Dim source2 = <compilation> <file name="c.vb"><![CDATA[ Public Class C Shared Sub Main() Dim c1 As New C1() C1.op_LeftShift(c1, c1) End Sub End Class ]]></file> </compilation> Dim comp2 = CreateCompilation(source2, references:={csCompilation}, options:=TestOptions.DebugExe) CompileAndVerify(comp2, expectedOutput:="<<").VerifyDiagnostics() End Sub End Class End Namespace