-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Override Copy method conversion to Unknown, when type conversion is P…
…artial, fixes #68
- Loading branch information
Showing
5 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
Source/AsyncGenerator.Tests/ConfigurationOverride/Fixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using AsyncGenerator.Analyzation; | ||
using AsyncGenerator.Core; | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.CSharp.Syntax; | ||
using NUnit.Framework; | ||
using AsyncGenerator.Tests.ConfigurationOverride.Input; | ||
|
||
namespace AsyncGenerator.Tests.ConfigurationOverride | ||
{ | ||
[TestFixture] | ||
public class Fixture : BaseFixture | ||
{ | ||
[Test] | ||
public Task TestAfterTransformation() | ||
{ | ||
var copy = GetMethodName<PartialCopy>(o => o.Copy); | ||
return ReadonlyTest(nameof(PartialCopy), p => p | ||
.ConfigureAnalyzation(a => a | ||
.MethodConversion(symbol => symbol.Name == copy ? MethodConversion.Copy : MethodConversion.Smart) | ||
) | ||
.ConfigureTransformation(t => t | ||
.AfterTransformation(result => | ||
{ | ||
AssertValidAnnotations(result); | ||
Assert.AreEqual(1, result.Documents.Count); | ||
var document = result.Documents[0]; | ||
Assert.NotNull(document.OriginalModified); | ||
Assert.AreEqual(GetOutputFile(nameof(PartialCopy)), document.Transformed.ToFullString()); | ||
}) | ||
) | ||
); | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
Source/AsyncGenerator.Tests/ConfigurationOverride/Input/PartialCopy.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using AsyncGenerator.TestCases; | ||
|
||
namespace AsyncGenerator.Tests.ConfigurationOverride.Input | ||
{ | ||
public class PartialCopy | ||
{ | ||
public void Read() | ||
{ | ||
Copy(); | ||
SimpleFile.Read(); | ||
} | ||
|
||
public void Copy() | ||
{ | ||
|
||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
Source/AsyncGenerator.Tests/ConfigurationOverride/Output/PartialCopy.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
//------------------------------------------------------------------------------ | ||
// <auto-generated> | ||
// This code was generated by AsyncGenerator. | ||
// | ||
// Changes to this file may cause incorrect behavior and will be lost if | ||
// the code is regenerated. | ||
// </auto-generated> | ||
//------------------------------------------------------------------------------ | ||
|
||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using AsyncGenerator.TestCases; | ||
|
||
namespace AsyncGenerator.Tests.ConfigurationOverride.Input | ||
{ | ||
public partial class PartialCopy | ||
{ | ||
public Task ReadAsync() | ||
{ | ||
try | ||
{ | ||
Copy(); | ||
return SimpleFile.ReadAsync(); | ||
} | ||
catch (Exception ex) | ||
{ | ||
return Task.FromException<object>(ex); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters