Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
c2614c63
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,发现更多精彩内容 >>
提交
c2614c63
编写于
5月 15, 2015
作者:
D
dino
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
https://github.com/dotnet/roslyn
上级
4dccc948
7bc76375
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
83 addition
and
23 deletion
+83
-23
src/.nuget/packages.config
src/.nuget/packages.config
+2
-2
src/Diagnostics/FxCop/System.Runtime.Analyzers/Test/Design/TypesThatOwnDisposableFieldsShouldBeDisposableTests.Fixer.cs
...esThatOwnDisposableFieldsShouldBeDisposableTests.Fixer.cs
+3
-6
src/Tools/Microsoft.CodeAnalysis.Toolset.Open/Targets/VSL.Settings.targets
...ft.CodeAnalysis.Toolset.Open/Targets/VSL.Settings.targets
+2
-2
src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs
...s/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs
+43
-9
src/Workspaces/CSharpTest/CodeGeneration/SymbolEditorTests.cs
...Workspaces/CSharpTest/CodeGeneration/SymbolEditorTests.cs
+1
-2
src/Workspaces/CSharpTest/CodeGeneration/SyntaxGeneratorTests.cs
...kspaces/CSharpTest/CodeGeneration/SyntaxGeneratorTests.cs
+32
-2
未找到文件。
src/.nuget/packages.config
浏览文件 @
c2614c63
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<!--
Copyright
(
c
)
Microsoft
Open
Technologies
,
Inc
.
All
Rights
Reserved
.
Licensed
under
the
Apache
License
,
Version
2
.
0
.
See
License
.
txt
in
the
project
root
for
license
information
. -->
<
packages
>
<
package
id
=
"Microsoft.Net.ToolsetCompilers"
version
=
"1.0.0-rc
2-20150415-05
"
targetFramework
=
"net45"
/>
<
package
id
=
"Microsoft.Net.RoslynDiagnostics"
version
=
"1.0.0-rc
2-20150415-05
"
targetFramework
=
"net45"
/>
<
package
id
=
"Microsoft.Net.ToolsetCompilers"
version
=
"1.0.0-rc
3-20150510-01
"
targetFramework
=
"net45"
/>
<
package
id
=
"Microsoft.Net.RoslynDiagnostics"
version
=
"1.0.0-rc
3-20150510-01
"
targetFramework
=
"net45"
/>
<
package
id
=
"System.Collections.Immutable"
version
=
"1.1.36"
targetFramework
=
"net45"
/>
<
package
id
=
"System.Reflection.Metadata"
version
=
"1.0.21"
targetFramework
=
"net45"
/>
<
package
id
=
"FakeSign"
version
=
"0.9.2"
targetFramework
=
"net45"
/>
...
...
src/Diagnostics/FxCop/System.Runtime.Analyzers/Test/Design/TypesThatOwnDisposableFieldsShouldBeDisposableTests.Fixer.cs
浏览文件 @
c2614c63
...
...
@@ -53,8 +53,7 @@ public NoDisposeClass()
using System.IO;
// This class violates the rule.
public class NoDisposeClass
: IDisposable
public class NoDisposeClass : IDisposable
{
FileStream newFile;
...
...
@@ -132,8 +131,7 @@ public class NoDisposeClass
using System.IO;
// This class violates the rule.
public class NoDisposeClass
: IDisposable
public class NoDisposeClass : IDisposable
{
FileStream newFile;
...
...
@@ -166,8 +164,7 @@ public partial class NoDisposeClass
using System.IO;
// This class violates the rule.
public partial class NoDisposeClass
: IDisposable
public partial class NoDisposeClass : IDisposable
{
FileStream newFile;
...
...
src/Tools/Microsoft.CodeAnalysis.Toolset.Open/Targets/VSL.Settings.targets
浏览文件 @
c2614c63
...
...
@@ -62,8 +62,8 @@
<!-- Import the global NuGet packages -->
<PropertyGroup>
<ToolsetCompilerPackageName>Microsoft.Net.ToolsetCompilers</ToolsetCompilerPackageName>
<ToolsetCompilerPropsFilePath>$(NuGetPackagesPath)\Microsoft.Net.ToolsetCompilers.1.0.0-rc
2-20150415-05
\build\Microsoft.Net.ToolsetCompilers.props</ToolsetCompilerPropsFilePath>
<RoslynDiagnosticsPropsFilePath>$(NuGetPackagesPath)\Microsoft.Net.RoslynDiagnostics.1.0.0-rc
2-20150415-05
\build\Microsoft.Net.RoslynDiagnostics.props</RoslynDiagnosticsPropsFilePath>
<ToolsetCompilerPropsFilePath>$(NuGetPackagesPath)\Microsoft.Net.ToolsetCompilers.1.0.0-rc
3-20150510-01
\build\Microsoft.Net.ToolsetCompilers.props</ToolsetCompilerPropsFilePath>
<RoslynDiagnosticsPropsFilePath>$(NuGetPackagesPath)\Microsoft.Net.RoslynDiagnostics.1.0.0-rc
3-20150510-01
\build\Microsoft.Net.RoslynDiagnostics.props</RoslynDiagnosticsPropsFilePath>
<AdditionalFileItemNames>$(AdditionalFileItemNames);PublicAPI</AdditionalFileItemNames>
</PropertyGroup>
...
...
src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs
浏览文件 @
c2614c63
...
...
@@ -2907,22 +2907,36 @@ public override SyntaxNode AddBaseType(SyntaxNode declaration, SyntaxNode baseTy
{
var
baseList
=
this
.
GetBaseList
(
declaration
);
var
newBaseList
=
(
baseList
!=
null
)
?
baseList
.
WithTypes
(
baseList
.
Types
.
Insert
(
0
,
SyntaxFactory
.
SimpleBaseType
((
TypeSyntax
)
baseType
)))
:
SyntaxFactory
.
BaseList
(
SyntaxFactory
.
SingletonSeparatedList
<
BaseTypeSyntax
>(
SyntaxFactory
.
SimpleBaseType
((
TypeSyntax
)
baseType
)));
return
this
.
WithBaseList
(
declaration
,
newBaseList
);
if
(
baseList
!=
null
)
{
return
this
.
WithBaseList
(
declaration
,
baseList
.
WithTypes
(
baseList
.
Types
.
Insert
(
0
,
SyntaxFactory
.
SimpleBaseType
((
TypeSyntax
)
baseType
))));
}
else
{
return
this
.
AddBaseList
(
declaration
,
SyntaxFactory
.
BaseList
(
SyntaxFactory
.
SingletonSeparatedList
<
BaseTypeSyntax
>(
SyntaxFactory
.
SimpleBaseType
((
TypeSyntax
)
baseType
))));
}
}
public
override
SyntaxNode
AddInterfaceType
(
SyntaxNode
declaration
,
SyntaxNode
interfaceType
)
{
var
baseList
=
this
.
GetBaseList
(
declaration
);
var
newBaseList
=
(
baseList
!=
null
)
?
baseList
.
WithTypes
(
baseList
.
Types
.
Insert
(
baseList
.
Types
.
Count
,
SyntaxFactory
.
SimpleBaseType
((
TypeSyntax
)
interfaceType
)))
:
SyntaxFactory
.
BaseList
(
SyntaxFactory
.
SingletonSeparatedList
<
BaseTypeSyntax
>(
SyntaxFactory
.
SimpleBaseType
((
TypeSyntax
)
interfaceType
)));
if
(
baseList
!=
null
)
{
return
this
.
WithBaseList
(
declaration
,
baseList
.
WithTypes
(
baseList
.
Types
.
Insert
(
baseList
.
Types
.
Count
,
SyntaxFactory
.
SimpleBaseType
((
TypeSyntax
)
interfaceType
))));
}
else
{
return
this
.
AddBaseList
(
declaration
,
SyntaxFactory
.
BaseList
(
SyntaxFactory
.
SingletonSeparatedList
<
BaseTypeSyntax
>(
SyntaxFactory
.
SimpleBaseType
((
TypeSyntax
)
interfaceType
))));
}
}
private
SyntaxNode
AddBaseList
(
SyntaxNode
declaration
,
BaseListSyntax
baseList
)
{
var
newDecl
=
this
.
WithBaseList
(
declaration
,
baseList
);
return
this
.
WithBaseList
(
declaration
,
newBaseList
);
// move trivia from type identifier to after base list
return
this
.
ShiftTrivia
(
newDecl
,
this
.
GetBaseList
(
newDecl
));
}
private
BaseListSyntax
GetBaseList
(
SyntaxNode
declaration
)
...
...
@@ -3237,6 +3251,26 @@ private SyntaxNode RemoveNodeInternal(SyntaxNode root, SyntaxNode declaration)
return
base
.
RemoveNode
(
root
,
declaration
);
}
/// <summary>
/// Moves the trailing trivia from the node's previous token to the end of the node
/// </summary>
private
SyntaxNode
ShiftTrivia
(
SyntaxNode
root
,
SyntaxNode
node
)
{
var
firstToken
=
node
.
GetFirstToken
();
var
previousToken
=
firstToken
.
GetPreviousToken
();
if
(
previousToken
!=
default
(
SyntaxToken
)
&&
root
.
Contains
(
previousToken
.
Parent
))
{
var
newNode
=
node
.
WithTrailingTrivia
(
node
.
GetTrailingTrivia
().
AddRange
(
previousToken
.
TrailingTrivia
));
var
newPreviousToken
=
previousToken
.
WithTrailingTrivia
(
default
(
SyntaxTriviaList
));
return
root
.
ReplaceSyntax
(
nodes
:
new
[]
{
node
},
computeReplacementNode
:
(
o
,
r
)
=>
newNode
,
tokens
:
new
[]
{
previousToken
},
computeReplacementToken
:
(
o
,
r
)
=>
newPreviousToken
,
trivia
:
null
,
computeReplacementTrivia
:
null
);
}
return
root
;
}
#endregion
#region Statements and Expressions
...
...
src/Workspaces/CSharpTest/CodeGeneration/SymbolEditorTests.cs
浏览文件 @
c2614c63
...
...
@@ -816,8 +816,7 @@ class A
}"
;
var
expected
=
@"class C
: A
@"class C : A
{
}
...
...
src/Workspaces/CSharpTest/CodeGeneration/SyntaxGeneratorTests.cs
浏览文件 @
c2614c63
...
...
@@ -5,6 +5,7 @@
using
Microsoft.CodeAnalysis.CodeGeneration
;
using
Microsoft.CodeAnalysis.CSharp.Syntax
;
using
Microsoft.CodeAnalysis.Editing
;
using
Microsoft.CodeAnalysis.Formatting
;
using
Microsoft.CodeAnalysis.Test.Utilities
;
using
Microsoft.CodeAnalysis.Text
;
using
Roslyn.Test.Utilities
;
...
...
@@ -14,7 +15,8 @@ namespace Microsoft.CodeAnalysis.CSharp.UnitTests.Editting
{
public
class
SyntaxGeneratorTests
{
private
readonly
SyntaxGenerator
_g
=
SyntaxGenerator
.
GetGenerator
(
new
AdhocWorkspace
(),
LanguageNames
.
CSharp
);
private
readonly
Workspace
_ws
;
private
readonly
SyntaxGenerator
_g
;
private
readonly
CSharpCompilation
_emptyCompilation
=
CSharpCompilation
.
Create
(
"empty"
,
references
:
new
[]
{
TestReferences
.
NetFx
.
v4_0_30319
.
mscorlib
,
TestReferences
.
NetFx
.
v4_0_30319
.
System
});
...
...
@@ -23,6 +25,8 @@ public class SyntaxGeneratorTests
public
SyntaxGeneratorTests
()
{
_ws
=
new
AdhocWorkspace
();
_g
=
SyntaxGenerator
.
GetGenerator
(
_ws
,
LanguageNames
.
CSharp
);
_ienumerableInt
=
_emptyCompilation
.
GetSpecialType
(
SpecialType
.
System_Collections_Generic_IEnumerable_T
).
Construct
(
_emptyCompilation
.
GetSpecialType
(
SpecialType
.
System_Int32
));
}
...
...
@@ -2867,6 +2871,32 @@ public void M()
{
}"
);
}
#endregion
[
WorkItem
(
293
,
"https://github.com/dotnet/roslyn/issues/293"
)]
[
Fact
]
[
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Formatting
)]
public
void
IntroduceBaseList
()
{
var
text
=
@"
public class C
{
}
"
;
var
expected
=
@"
public class C : IDisposable
{
}
"
;
var
root
=
SyntaxFactory
.
ParseCompilationUnit
(
text
);
var
decl
=
root
.
DescendantNodes
().
OfType
<
ClassDeclarationSyntax
>().
First
();
var
newDecl
=
_g
.
AddInterfaceType
(
decl
,
_g
.
IdentifierName
(
"IDisposable"
));
var
newRoot
=
root
.
ReplaceNode
(
decl
,
newDecl
);
var
elasticOnlyFormatted
=
Formatter
.
Format
(
newRoot
,
SyntaxAnnotation
.
ElasticAnnotation
,
_ws
).
ToFullString
();
Assert
.
Equal
(
expected
,
elasticOnlyFormatted
);
}
#
endregion
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录