1
ļ»æ// Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
3
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
4
// software and associated documentation files (the "Software"), to deal in the Software
5
// without restriction, including without limitation the rights to use, copy, modify, merge,
6
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7
// to whom the Software is furnished to do so, subject to the following conditions:
9
// The above copyright notice and this permission notice shall be included in all copies or
10
// substantial portions of the Software.
12
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17
// DEALINGS IN THE SOFTWARE.
20
using ICSharpCode.NRefactory.CSharp;
21
using ICSharpCode.NRefactory.CSharp.Parser;
22
using ICSharpCode.NRefactory.TypeSystem;
23
using NUnit.Framework;
25
namespace ICSharpCode.NRefactory.Documentation
28
public class CSharpCrefParserTests
33
ParseUtilCSharp.AssertDocumentationReference(
35
new DocumentationReference {
44
ParseUtilCSharp.AssertDocumentationReference(
46
new DocumentationReference {
47
EntityType = EntityType.Indexer
52
[Ignore("mcs bug (Unexpected symbol `this', expecting `explicit', `implicit', `operator', or `type')")]
53
public void ThisWithParameter()
55
ParseUtilCSharp.AssertDocumentationReference(
57
new DocumentationReference {
58
EntityType = EntityType.Indexer,
59
HasParameterList = true,
60
Parameters = { new ParameterDeclaration { Type = new PrimitiveType("int") } }
65
public void ThisWithDeclaringType()
67
ParseUtilCSharp.AssertDocumentationReference(
69
new DocumentationReference {
70
EntityType = EntityType.Indexer,
71
DeclaringType = new SimpleType("List", new SimpleType("T"))
76
public void NestedTypeInGenericType()
78
ParseUtilCSharp.AssertDocumentationReference(
80
new DocumentationReference {
81
DeclaringType = new SimpleType("List", new SimpleType("T")),
82
MemberName = "Enumerator"
87
public void GenericTypeWithFullNamespace()
89
ParseUtilCSharp.AssertDocumentationReference(
90
"System.Collections.Generic.List{T}",
91
new DocumentationReference {
92
DeclaringType = new SimpleType("System").MemberType("Collections").MemberType("Generic"),
94
TypeArguments = { new SimpleType("T") }
99
public void PrimitiveType()
101
ParseUtilCSharp.AssertDocumentationReference(
103
new DocumentationReference {
104
EntityType = EntityType.TypeDefinition,
105
DeclaringType = new PrimitiveType("int")
110
public void VerbatimIdentifier()
112
ParseUtilCSharp.AssertDocumentationReference(
114
new DocumentationReference {
120
public void IntParse()
122
ParseUtilCSharp.AssertDocumentationReference(
124
new DocumentationReference {
125
DeclaringType = new PrimitiveType("int"),
126
MemberName = "Parse",
127
HasParameterList = true,
129
new ParameterDeclaration { Type = new PrimitiveType("string") }
135
public void Generic()
137
ParseUtilCSharp.AssertDocumentationReference(
139
new DocumentationReference {
140
MemberName = "IGeneric",
141
TypeArguments = { new SimpleType("X"), new SimpleType("Y") }
146
public void MixedGeneric()
148
ParseUtilCSharp.AssertDocumentationReference(
150
new DocumentationReference {
151
MemberName = "IGeneric",
152
TypeArguments = { new SimpleType("X"), new SimpleType("Y") }
157
public void MethodInGeneric()
159
ParseUtilCSharp.AssertDocumentationReference(
160
"IGeneric{X, Y}.Test",
161
new DocumentationReference {
162
DeclaringType = new SimpleType("IGeneric", new SimpleType("X"), new SimpleType("Y")),
168
public void GenericMethodInGeneric()
170
ParseUtilCSharp.AssertDocumentationReference(
171
"IGeneric{X, Y}.Test{Z}",
172
new DocumentationReference {
173
DeclaringType = new SimpleType("IGeneric", new SimpleType("X"), new SimpleType("Y")),
175
TypeArguments = { new SimpleType("Z") }
180
public void GenericMethodInGenericWithParameterList()
182
ParseUtilCSharp.AssertDocumentationReference(
183
"IGeneric{X, Y}.Test{Z}(ref Z[,])",
184
new DocumentationReference {
185
DeclaringType = new SimpleType("IGeneric", new SimpleType("X"), new SimpleType("Y")),
187
TypeArguments = { new SimpleType("Z") },
188
HasParameterList = true,
190
new ParameterDeclaration {
191
ParameterModifier = ParameterModifier.Ref,
192
Type = new SimpleType("Z").MakeArrayType(2)
198
public void EmptyParameterList()
200
ParseUtilCSharp.AssertDocumentationReference(
202
new DocumentationReference {
203
MemberName = "Window1",
204
HasParameterList = true
209
public void OperatorPlus()
211
ParseUtilCSharp.AssertDocumentationReference(
213
new DocumentationReference {
214
EntityType = EntityType.Operator,
215
OperatorType = OperatorType.Addition
220
[Ignore("mcs bug (Unexpected symbol `operator', expecting `identifier' or `this')")]
221
public void OperatorPlusWithDeclaringType()
223
ParseUtilCSharp.AssertDocumentationReference(
225
new DocumentationReference {
226
DeclaringType = new SimpleType("Test"),
227
EntityType = EntityType.Operator,
228
OperatorType = OperatorType.Addition
233
public void OperatorPlusWithParameterList()
235
ParseUtilCSharp.AssertDocumentationReference(
236
"operator +(Test, int)",
237
new DocumentationReference {
238
EntityType = EntityType.Operator,
239
OperatorType = OperatorType.Addition,
240
HasParameterList = true,
242
new ParameterDeclaration { Type = new SimpleType("Test") },
243
new ParameterDeclaration { Type = new PrimitiveType("int") }
248
public void ImplicitOperator()
250
ParseUtilCSharp.AssertDocumentationReference(
251
"implicit operator int",
252
new DocumentationReference {
253
EntityType = EntityType.Operator,
254
OperatorType = OperatorType.Implicit,
255
ConversionOperatorReturnType = new PrimitiveType("int")
260
public void ExplicitOperatorWithParameterList()
262
ParseUtilCSharp.AssertDocumentationReference(
263
"explicit operator int(Test)",
264
new DocumentationReference {
265
EntityType = EntityType.Operator,
266
OperatorType = OperatorType.Explicit,
267
ConversionOperatorReturnType = new PrimitiveType("int"),
268
HasParameterList = true,
270
new ParameterDeclaration { Type = new SimpleType("Test") },
276
[Ignore("mcs bug (Unexpected symbol `explicit', expecting `identifier' or `this')")]
277
public void ExplicitOperatorWithParameterListAndDeclaringType()
279
ParseUtilCSharp.AssertDocumentationReference(
280
"Test.explicit operator int(Test)",
281
new DocumentationReference {
282
EntityType = EntityType.Operator,
283
OperatorType = OperatorType.Explicit,
284
DeclaringType = new SimpleType("Test"),
285
ConversionOperatorReturnType = new PrimitiveType("int"),
286
HasParameterList = true,
288
new ParameterDeclaration { Type = new SimpleType("Test") },