Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,41 @@ public void TestMethod([MemberGen(nameof(TestMethod_x))] int x)
await Verifier.Verify(code, codeProvidingRefactorPosition, expectedRefactoredCode, expectedRefactoringTitle);
}

[Fact]
public async Task ItRefactorsMethodsDecoratedWithTheSampleAttribute()
{
var code = @"
using GalaxyCheck;

public class TestClass
{
[Sample]
public void TestMethod(int x)
{
}
}
";
var codeProvidingRefactorPosition = new LinePosition(7, 28);

var expectedRefactoredCode = @"
using GalaxyCheck;

public class TestClass
{
private static IGen<int> TestMethod_x => Gen.Int32();

[Sample]
public void TestMethod([MemberGen(nameof(TestMethod_x))] int x)
{
}
}
";

var expectedRefactoringTitle = $"Configure generation of parameter with MemberGenAttribute";

await Verifier.Verify(code, codeProvidingRefactorPosition, expectedRefactoredCode, expectedRefactoringTitle);
}

[Theory]
[InlineData(7, 27)]
[InlineData(7, 33)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public override async Task ComputeRefactoringsAsync(CodeRefactoringContext conte
.FirstOrDefault(a =>
{
var attributeSymbol = semanticModel.GetSymbolInfo(a);
return SymbolEqualityComparer.Default.Equals(attributeSymbol.Symbol?.ContainingType, propertyAttributeType);
return attributeSymbol.Symbol != null && propertyAttributeType.IsAssignableFrom(attributeSymbol.Symbol.ContainingType);
});
if (propertyAttribute is null) return;

Expand Down