1
1
using System ;
2
2
using System . Collections . Generic ;
3
3
using System . Collections . ObjectModel ;
4
+ using System . Diagnostics . CodeAnalysis ;
4
5
using System . Linq ;
5
6
using Newtonsoft . Json ;
6
7
using Newtonsoft . Json . Linq ;
@@ -31,14 +32,14 @@ public static Collection<T> ToCollectionOf<T>(this VkResponse response, Func<VkR
31
32
{
32
33
if ( response is null )
33
34
{
34
- return new ( new List < T > ( ) ) ;
35
+ return new ( [ ] ) ;
35
36
}
36
37
37
38
var responseArray = ( VkResponseArray ) response ;
38
39
39
40
if ( responseArray is null ) //TODO: V3022 http://www.viva64.com/en/w/V3022 Expression 'responseArray == null' is always false.
40
41
{
41
- return new ( new List < T > ( ) ) ;
42
+ return new ( [ ] ) ;
42
43
}
43
44
44
45
return responseArray . Select ( selector )
@@ -67,14 +68,14 @@ public static ReadOnlyCollection<T>
67
68
{
68
69
if ( response is null )
69
70
{
70
- return new ( new List < T > ( ) ) ;
71
+ return new ( [ ] ) ;
71
72
}
72
73
73
74
var responseArray = ( VkResponseArray ) response ;
74
75
75
76
if ( responseArray is null ) //TODO: V3022 http://www.viva64.com/en/w/V3022 Expression 'responseArray == null' is always false.
76
77
{
77
- return new ( new List < T > ( ) ) ;
78
+ return new ( [ ] ) ;
78
79
}
79
80
80
81
return responseArray . Select ( selector )
@@ -94,14 +95,14 @@ public static ReadOnlyCollection<T>
94
95
{
95
96
if ( response is null )
96
97
{
97
- return new ( new List < T > ( ) ) ;
98
+ return new ( [ ] ) ;
98
99
}
99
100
100
101
var responseArray = ( VkResponseArray ) response ;
101
102
102
103
if ( responseArray is null ) //TODO: V3022 http://www.viva64.com/en/w/V3022 Expression 'responseArray == null' is always false.
103
104
{
104
- return new ( new List < T > ( ) ) ;
105
+ return new ( [ ] ) ;
105
106
}
106
107
107
108
return responseArray . Select ( x => x as T )
@@ -118,7 +119,7 @@ public static ReadOnlyCollection<T>
118
119
/// <returns> Коллекция данных только для чтения. </returns>
119
120
public static ReadOnlyCollection < T > ToReadOnlyCollectionOf < T > ( this IEnumerable < VkResponse > responses , Func < VkResponse , T > selector ) =>
120
121
responses is null
121
- ? new ( new List < T > ( ) )
122
+ ? new ( [ ] )
122
123
: responses . Select ( selector )
123
124
. ToReadOnlyCollection ( ) ;
124
125
@@ -136,14 +137,14 @@ public static List<T> ToListOf<T>(this VkResponse response, Func<VkResponse, T>
136
137
{
137
138
if ( response is null )
138
139
{
139
- return new ( ) ;
140
+ return [ ] ;
140
141
}
141
142
142
143
var responseArray = ( VkResponseArray ) response ;
143
144
144
145
if ( responseArray is null ) //TODO: V3022 http://www.viva64.com/en/w/V3022 Expression 'responseArray == null' is always false.
145
146
{
146
- return new ( ) ;
147
+ return [ ] ;
147
148
}
148
149
149
150
return responseArray . Select ( selector )
@@ -181,7 +182,7 @@ public static VkCollection<T> ToVkCollectionOf<T>(this VkResponse response
181
182
{
182
183
if ( response is null )
183
184
{
184
- return new ( 0 , Enumerable . Empty < T > ( ) ) ;
185
+ return new ( 0 , [ ] ) ;
185
186
}
186
187
187
188
VkResponseArray data = response . ContainsKey ( arrayName )
@@ -217,6 +218,7 @@ public static T ToEnum<T>(this VkResponse response)
217
218
/// <returns>
218
219
/// Признак валидности json
219
220
/// </returns>
221
+ [ SuppressMessage ( "Performance" , "CA1866:Использовать перегрузку символов" , Justification = "Не поддерживается в netstandard2.0" ) ]
220
222
public static bool IsValidJson ( string input )
221
223
{
222
224
input = input . Trim ( ) ;
0 commit comments