blob: daddbf02a3d2f92fdbafc598d9a1190f18e1aadf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeGeneration;
using Microsoft.CodeAnalysis.Text;
namespace ICSharpCode.NRefactory6.CSharp
{
static class IParameterSymbolExtensions
{
public static bool IsRefOrOut(this IParameterSymbol symbol)
{
return symbol.RefKind != RefKind.None;
}
public static IParameterSymbol RenameParameter(this IParameterSymbol parameter, string parameterName)
{
return parameter.Name == parameterName
? parameter
: CodeGenerationSymbolFactory.CreateParameterSymbol(
parameter.GetAttributes(),
parameter.RefKind,
parameter.IsParams,
parameter.Type,
parameterName,
parameter.IsOptional,
parameter.HasExplicitDefaultValue,
parameter.HasExplicitDefaultValue ? parameter.ExplicitDefaultValue : null);
}
public static IList<IParameterSymbol> RenameParameters(this IList<IParameterSymbol> parameters, IList<string> parameterNames)
{
var result = new List<IParameterSymbol>();
for (int i = 0; i < parameterNames.Count; i++)
{
result.Add(parameters[i].RenameParameter(parameterNames[i]));
}
return result;
}
}
}
|