Skip to content

Commit aba212c

Browse files
authored
AsyncToSyncMethodTransformer: handle array types (#968)
Ref: #967
1 parent 532d4e6 commit aba212c

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/D2L.CodeStyle.Analyzers/Async/Generator/AsyncToSyncMethodTransformer.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ private TypeSyntax TransformType( TypeSyntax typeSynt, bool isReturnType = false
111111
return typeSynt;
112112
}
113113

114+
if( returnTypeInfo.Type is IArrayTypeSymbol ) {
115+
return typeSynt;
116+
}
117+
114118
if( returnTypeInfo.Type.ContainingNamespace.ToString() == "System.Threading.Tasks" ) {
115119
switch( returnTypeInfo.Type.MetadataName ) {
116120
case "Task":

tests/D2L.CodeStyle.Analyzers.Test/Async/Generator/AsyncToSyncMethodTransformerTests.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@ public void VariableDeclaration() {
8484
Assert.AreEqual( "[Blocking] void Bar() { IBaz q = m_bazValidator.Validate( bar ); }", actual.Value.ToFullString() );
8585
}
8686

87+
[Test]
88+
public void ArrayVariableDeclaration() {
89+
var actual = Transform( @"[GenerateSync] async Task BarAsync() { IBaz[] q = await m_bazValidator.ValidateAsync( bar ); }" );
90+
91+
Assert.IsTrue( actual.Success );
92+
Assert.IsEmpty( actual.Diagnostics );
93+
Assert.AreEqual( "[Blocking] void Bar() { IBaz[] q = m_bazValidator.Validate( bar ); }", actual.Value.ToFullString() );
94+
}
95+
8796
[Test]
8897
public void PredefinedType() {
8998
var actual = Transform( @"[GenerateSync] async Task BarAsync() { string.IsNullOrEmpty(""""); }" );

0 commit comments

Comments
 (0)