Skip to content
Closed
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
Correctly handle the existence of TestContext in base class
  • Loading branch information
Youssef1313 committed Jul 27, 2025
commit 1771ac8efdb6e40dca52189a2e1ff468579e8366
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
partial class Derived
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Verify.MSTest.SourceGenerator", "1.0.0.0")]
public sealed override global::Microsoft.VisualStudio.TestTools.UnitTesting.TestContext TestContext
public new global::Microsoft.VisualStudio.TestTools.UnitTesting.TestContext TestContext
{
get => base.TestContext;
set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public partial class Derived : Base
}
""";

return VerifyGenerator(TestDriver.Run(source), ["CS0506"]);
return VerifyGenerator(TestDriver.Run(source));
}

[Fact]
Expand Down
1 change: 1 addition & 0 deletions src/Verify.MSTest.SourceGenerator/ClassToGenerate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public enum PropertyFlags
None = 0b00,
Override = 0b01,
CallBase = 0b10,
New = 0b100,
}

public string? Namespace { get; } = Namespace;
Expand Down
2 changes: 1 addition & 1 deletion src/Verify.MSTest.SourceGenerator/Emitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,5 @@ static string GetterBody(PropertyFlags flags) =>
static string GetModifiers(PropertyFlags flags) =>
flags.HasFlag(PropertyFlags.Override)
? "sealed override "
: string.Empty;
: (flags.HasFlag(PropertyFlags.New) ? "new " : string.Empty);
}
5 changes: 2 additions & 3 deletions src/Verify.MSTest.SourceGenerator/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ static PropertyFlags GetDerivedPropertyFlagsGiven(IPropertySymbol? baseClassProp
baseClassProperty?.IsAbstract switch
{
true => PropertyFlags.Override,
false => PropertyFlags.Override |
PropertyFlags.CallBase,
null => PropertyFlags.None
false => baseClassProperty.IsVirtual ? PropertyFlags.Override | PropertyFlags.CallBase : PropertyFlags.New | PropertyFlags.CallBase,
null => PropertyFlags.None,
};

static IEnumerable<IPropertySymbol> BaseTestContextProperties(INamedTypeSymbol typeSymbol) =>
Expand Down
2 changes: 1 addition & 1 deletion src/Verify.Xunit/Verifier_Object.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace VerifyXunit;
namespace VerifyXunit;

public static partial class Verifier
{
Expand Down