Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
1d7ac53e
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
1d7ac53e
编写于
7月 13, 2020
作者:
M
Manish Vasani
提交者:
GitHub
7月 13, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #45139 from jrmoreno1/dev3438
#3438, use standard Type Conversion Functions when possible
上级
4d0c2c0d
60d00834
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
298 addition
and
11 deletion
+298
-11
src/EditorFeatures/Test2/Expansion/ExtensionMethodExpansionRewriteTests.vb
...s/Test2/Expansion/ExtensionMethodExpansionRewriteTests.vb
+3
-3
src/EditorFeatures/VisualBasicTest/Diagnostics/AddExplicitCast/AddExplicitCastTests.vb
...cTest/Diagnostics/AddExplicitCast/AddExplicitCastTests.vb
+290
-5
src/EditorFeatures/VisualBasicTest/Diagnostics/AddExplicitCast/AddExplicitCastTests_FixAllTests.vb
...stics/AddExplicitCast/AddExplicitCastTests_FixAllTests.vb
+3
-3
src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ITypeSymbolExtensions.vb
...Workspace/VisualBasic/Extensions/ITypeSymbolExtensions.vb
+2
-0
未找到文件。
src/EditorFeatures/Test2/Expansion/ExtensionMethodExpansionRewriteTests.vb
浏览文件 @
1d7ac53e
...
...
@@ -88,7 +88,7 @@ Imports System.Runtime.CompilerServices
Public
Class
Program
Public
Sub
Main
(
args
As
String
())
Dim
p
As
Program
=
Nothing
Dim
ss
=
Global
.
ProgramExtensions
.
goo
((
CType
((
p
),
Global
.
Program
)),
(
C
Type
((
""
),
System
.
String
)))
Dim
ss
=
Global
.
ProgramExtensions
.
goo
((
CType
((
p
),
Global
.
Program
)),
(
C
Str
((
""
)
)))
End
Sub
End
Class
...
...
@@ -182,7 +182,7 @@ Imports System.Runtime.CompilerServices
Public
Class
Program
Public
Sub
Main
(
args
As
String
())
Dim
p
As
Program
=
Nothing
Dim
ss
=
Global
.
ProgramExtensions
.
goo
((
CType
((
Global
.
ProgramExtensions
.
goo
((
CType
((
p
),
Global
.
Program
)),
(
C
Type
((
""
),
System
.
String
)))),
Global
.
Program
)),
(
CType
((
""
),
System
.
String
)))
Dim
ss
=
Global
.
ProgramExtensions
.
goo
((
CType
((
Global
.
ProgramExtensions
.
goo
((
CType
((
p
),
Global
.
Program
)),
(
C
Str
((
""
))))),
Global
.
Program
)),
(
CStr
((
""
)
)))
End
Sub
End
Class
...
...
@@ -229,7 +229,7 @@ Imports System.Runtime.CompilerServices
Public
Class
Program
Public
Sub
Main
(
args
As
String
())
Dim
p
As
Program
=
Nothing
Dim
ss
=
Global
.
ProgramExtensions
.
goo
((
CType
((
Global
.
ProgramExtensions
.
goo
((
CType
((
p
),
Global
.
Program
)),
(
C
Type
((
""
),
System
.
String
)),
(
CType
((
""
),
System
.
String
)),
(
CType
((
""
),
System
.
String
)))),
Global
.
Program
)),
(
CType
((
""
),
System
.
String
)),
(
CType
((
""
),
System
.
String
)),
(
CType
((
""
),
System
.
String
)))
Dim
ss
=
Global
.
ProgramExtensions
.
goo
((
CType
((
Global
.
ProgramExtensions
.
goo
((
CType
((
p
),
Global
.
Program
)),
(
C
Str
((
""
))),
(
CStr
((
""
))),
(
CStr
((
""
))))),
Global
.
Program
)),
(
CStr
((
""
))),
(
CStr
((
""
))),
(
CStr
((
""
)
)))
End
Sub
End
Class
...
...
src/EditorFeatures/VisualBasicTest/Diagnostics/AddExplicitCast/AddExplicitCastTests.vb
浏览文件 @
1d7ac53e
...
...
@@ -21,7 +21,26 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Diagnostics.AddExp
End
Function
<
Fact
(),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsAddExplicitCast
)
>
Public
Async
Function
TestPredefinedAssignment
()
As
Task
Public
Async
Function
TestPredefinedAssignmentCBool
()
As
Task
Await
TestInRegularAndScriptAsync
(
"Option Strict On
Module M1
Sub Main()
Dim i As Integer = 0
Dim b As Boolean = [|i|]
End Sub
End Module"
,
"Option Strict On
Module M1
Sub Main()
Dim i As Integer = 0
Dim b As Boolean = CBool(i)
End Sub
End Module"
)
End
Function
<
Fact
(),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsAddExplicitCast
)
>
Public
Async
Function
TestPredefinedAssignmentCByte
()
As
Task
Await
TestInRegularAndScriptAsync
(
"Option Strict On
Module M1
...
...
@@ -41,6 +60,272 @@ Module M1
End Module"
)
End
Function
<
Fact
(),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsAddExplicitCast
)
>
Public
Async
Function
TestPredefinedAssignmentCChar
()
As
Task
Await
TestInRegularAndScriptAsync
(
"Option Strict On
Module M1
Sub Main()
Dim s As String = 0.ToString()
Dim ch As Char = [|s|]
End Sub
End Module"
,
"Option Strict On
Module M1
Sub Main()
Dim s As String = 0.ToString()
Dim ch As Char = CChar(s)
End Sub
End Module"
)
End
Function
<
Fact
(),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsAddExplicitCast
)
>
Public
Async
Function
TestPredefinedAssignmentCDate
()
As
Task
Await
TestInRegularAndScriptAsync
(
"Option Strict On
Module M1
Sub Main()
Dim s As String = #2006-06-13#.ToString()
Dim dt As Date = [|s|]
End Sub
End Module"
,
"Option Strict On
Module M1
Sub Main()
Dim s As String = #2006-06-13#.ToString()
Dim dt As Date = CDate(s)
End Sub
End Module"
)
End
Function
<
Fact
(),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsAddExplicitCast
)
>
Public
Async
Function
TestPredefinedAssignmentCDbl
()
As
Task
Await
TestInRegularAndScriptAsync
(
"Option Strict On
Module M1
Sub Main()
Dim s As String = 1.0R.ToString()
Dim db As Double = [|s|]
End Sub
End Module"
,
"Option Strict On
Module M1
Sub Main()
Dim s As String = 1.0R.ToString()
Dim db As Double = CDbl(s)
End Sub
End Module"
)
End
Function
<
Fact
(),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsAddExplicitCast
)
>
Public
Async
Function
TestPredefinedAssignmentCDec
()
As
Task
Await
TestInRegularAndScriptAsync
(
"Option Strict On
Module M1
Sub Main()
Dim db As Double = 1.0R
Dim dc As Decimal = [|db|]
End Sub
End Module"
,
"Option Strict On
Module M1
Sub Main()
Dim db As Double = 1.0R
Dim dc As Decimal = CDec(db)
End Sub
End Module"
)
End
Function
<
Fact
(),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsAddExplicitCast
)
>
Public
Async
Function
TestPredefinedAssignmentCInt
()
As
Task
Await
TestInRegularAndScriptAsync
(
"Option Strict On
Module M1
Sub Main()
Dim db As Double = 1.0R
Dim i As Integer = [|db|]
End Sub
End Module"
,
"Option Strict On
Module M1
Sub Main()
Dim db As Double = 1.0R
Dim i As Integer = CInt(db)
End Sub
End Module"
)
End
Function
<
Fact
(),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsAddExplicitCast
)
>
Public
Async
Function
TestPredefinedAssignmentCLng
()
As
Task
Await
TestInRegularAndScriptAsync
(
"Option Strict On
Module M1
Sub Main()
Dim db As Double = 1.0R
Dim lg As Long = [|db|]
End Sub
End Module"
,
"Option Strict On
Module M1
Sub Main()
Dim db As Double = 1.0R
Dim lg As Long = CLng(db)
End Sub
End Module"
)
End
Function
<
Fact
(),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsAddExplicitCast
)
>
Public
Async
Function
TestPredefinedAssignmentCSByte
()
As
Task
Await
TestInRegularAndScriptAsync
(
"Option Strict On
Module M1
Sub Main()
Dim dc As Decimal = -14.02D
Dim sb As SByte = [|dc|]
End Sub
End Module"
,
"Option Strict On
Module M1
Sub Main()
Dim dc As Decimal = -14.02D
Dim sb As SByte = CSByte(dc)
End Sub
End Module"
)
End
Function
<
Fact
(),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsAddExplicitCast
)
>
Public
Async
Function
TestPredefinedAssignmentCShort
()
As
Task
Await
TestInRegularAndScriptAsync
(
"Option Strict On
Module M1
Sub Main()
Dim i As Integer = 2
Dim sh As Short = [|i|]
End Sub
End Module"
,
"Option Strict On
Module M1
Sub Main()
Dim i As Integer = 2
Dim sh As Short = CShort(i)
End Sub
End Module"
)
End
Function
<
Fact
(),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsAddExplicitCast
)
>
Public
Async
Function
TestPredefinedAssignmentCSng
()
As
Task
Await
TestInRegularAndScriptAsync
(
"Option Strict On
Module M1
Sub Main()
Dim db As Double = 1.0R
Dim sn As Single = [|db|]
End Sub
End Module"
,
"Option Strict On
Module M1
Sub Main()
Dim db As Double = 1.0R
Dim sn As Single = CSng(db)
End Sub
End Module"
)
End
Function
<
Fact
(),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsAddExplicitCast
)
>
Public
Async
Function
TestPredefinedAssignmentCStr
()
As
Task
Await
TestInRegularAndScriptAsync
(
"Option Strict On
Module M1
Sub Main()
Dim i As Integer = 1
Dim s As String = [|i|]
End Sub
End Module"
,
"Option Strict On
Module M1
Sub Main()
Dim i As Integer = 1
Dim s As String = CStr(i)
End Sub
End Module"
)
End
Function
<
Fact
(),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsAddExplicitCast
)
>
Public
Async
Function
TestPredefinedAssignmentObjectToStringCStr
()
As
Task
Await
TestInRegularAndScriptAsync
(
"Option Strict On
Module M1
Sub Main()
Dim o As Object = 1.ToString()
Dim s As String = [|o|]
End Sub
End Module"
,
"Option Strict On
Module M1
Sub Main()
Dim o As Object = 1.ToString()
Dim s As String = CStr(o)
End Sub
End Module"
)
End
Function
<
Fact
(),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsAddExplicitCast
)
>
Public
Async
Function
TestPredefinedAssignmentCUInt
()
As
Task
Await
TestInRegularAndScriptAsync
(
"Option Strict On
Module M1
Sub Main()
Dim i As Integer = -1
Dim ui As UInteger = [|i|]
End Sub
End Module"
,
"Option Strict On
Module M1
Sub Main()
Dim i As Integer = -1
Dim ui As UInteger = CUInt(i)
End Sub
End Module"
)
End
Function
<
Fact
(),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsAddExplicitCast
)
>
Public
Async
Function
TestPredefinedAssignmentCULng
()
As
Task
Await
TestInRegularAndScriptAsync
(
"Option Strict On
Module M1
Sub Main()
Dim l As Long = -1
Dim ul As ULong =[|l|]
End Sub
End Module"
,
"Option Strict On
Module M1
Sub Main()
Dim l As Long = -1
Dim ul As ULong = CULng(l)
End Sub
End Module"
)
End
Function
<
Fact
(),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsAddExplicitCast
)
>
Public
Async
Function
TestPredefinedAssignmentCUShort
()
As
Task
Await
TestInRegularAndScriptAsync
(
"Option Strict On
Module M1
Sub Main()
Dim i As Integer = -2
Dim us As UShort = [|i|]
End Sub
End Module"
,
"Option Strict On
Module M1
Sub Main()
Dim i As Integer = -2
Dim us As UShort = CUShort(i)
End Sub
End Module"
)
End
Function
<
Fact
(),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsAddExplicitCast
)
>
Public
Async
Function
TestAssignment
()
As
Task
Await
TestInRegularAndScriptAsync
(
...
...
@@ -2930,17 +3215,17 @@ Class Program
Private Sub M()
Dim b As Base = New Base()
Foo(s:=
""""
, i:=1, d:=
CType(b, {0})
)
Foo(s:=
""""
, i:=1, d:=
{0}
)
End Sub
End Class"
Await
TestInRegularAndScriptAsync
(
initialMarkup
,
String
.
Format
(
expect_format
,
"
String
"
),
index
:
=
0
,
Await
TestInRegularAndScriptAsync
(
initialMarkup
,
String
.
Format
(
expect_format
,
"
CStr(b)
"
),
index
:
=
0
,
title
:
=
String
.
Format
(
FeaturesResources
.
Convert_type_to_0
,
"String"
))
Await
TestInRegularAndScriptAsync
(
initialMarkup
,
String
.
Format
(
expect_format
,
"
Derived
"
),
index
:
=
1
,
Await
TestInRegularAndScriptAsync
(
initialMarkup
,
String
.
Format
(
expect_format
,
"
CType(b, Derived)
"
),
index
:
=
1
,
title
:
=
String
.
Format
(
FeaturesResources
.
Convert_type_to_0
,
"Derived"
))
Await
TestInRegularAndScriptAsync
(
initialMarkup
,
String
.
Format
(
expect_format
,
"
Derived2
"
),
index
:
=
2
,
Await
TestInRegularAndScriptAsync
(
initialMarkup
,
String
.
Format
(
expect_format
,
"
CType(b, Derived2)
"
),
index
:
=
2
,
title
:
=
String
.
Format
(
FeaturesResources
.
Convert_type_to_0
,
"Derived2"
))
End
Function
...
...
src/EditorFeatures/VisualBasicTest/Diagnostics/AddExplicitCast/AddExplicitCastTests_FixAllTests.vb
浏览文件 @
1d7ac53e
...
...
@@ -1270,7 +1270,7 @@ Public Class Program1
Foo4
(
i
:
=
1
,
j
:
=
""
,
CType
(
b1
,
Derived1
))
Foo5
(
""
,
1
,
b1
)
Foo5
(
d
:
=
CType
(
b1
,
Derived2
),
i
:
=
1
,
j
:
=
""
,
x
:
=
1
)
Foo5
(
C
Type
(
1
,
String
),
""
,
x
:
=
1
,
d
:
=
b1
)
Foo5
(
C
Str
(
1
),
""
,
x
:
=
1
,
d
:
=
b1
)
Foo5
(
1
,
""
,
d
:
=
b1
,
b2
,
b3
,
d1
)
Foo5
(
""
,
1
,
d
:
=
b1
,
b2
,
b3
,
d1
)
Dim
d2list
=
New
Derived2
()
{}
...
...
@@ -1475,7 +1475,7 @@ Public Class Program1
Foo4
(
i
:
=
1
,
j
:
=
""
,
CType
(
b1
,
Derived1
))
Foo5
(
""
,
1
,
b1
)
Foo5
(
d
:
=
CType
(
b1
,
Derived2
),
i
:
=
1
,
j
:
=
""
,
x
:
=
1
)
Foo5
(
C
Type
(
1
,
String
),
""
,
x
:
=
1
,
d
:
=
b1
)
Foo5
(
C
Str
(
1
),
""
,
x
:
=
1
,
d
:
=
b1
)
Foo5
(
1
,
""
,
d
:
=
b1
,
b2
,
b3
,
d1
)
Foo5
(
""
,
1
,
d
:
=
b1
,
b2
,
b3
,
d1
)
Dim
d2list
=
New
Derived2
()
{}
...
...
@@ -1680,7 +1680,7 @@ Public Class Program1
Foo4
(
i
:
=
1
,
j
:
=
""
,
CType
(
b1
,
Derived1
))
Foo5
(
""
,
1
,
b1
)
Foo5
(
d
:
=
CType
(
b1
,
Derived2
),
i
:
=
1
,
j
:
=
""
,
x
:
=
1
)
Foo5
(
C
Type
(
1
,
String
),
""
,
x
:
=
1
,
d
:
=
b1
)
Foo5
(
C
Str
(
1
),
""
,
x
:
=
1
,
d
:
=
b1
)
Foo5
(
1
,
""
,
d
:
=
b1
,
b2
,
b3
,
d1
)
Foo5
(
""
,
1
,
d
:
=
b1
,
b2
,
b3
,
d1
)
Dim
d2list
=
New
Derived2
()
{}
...
...
src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ITypeSymbolExtensions.vb
浏览文件 @
1d7ac53e
...
...
@@ -42,6 +42,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions
Return
SyntaxKind
.
CSngKeyword
Case
specialType
.
System_Int16
Return
SyntaxKind
.
CShortKeyword
Case
SpecialType
.
System_String
Return
SyntaxKind
.
CStrKeyword
Case
specialType
.
System_UInt32
Return
SyntaxKind
.
CUIntKeyword
Case
specialType
.
System_UInt64
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录