Skip to content

Commit

Permalink
Fix tests after reverting
Browse files Browse the repository at this point in the history
  • Loading branch information
angularsen committed Oct 6, 2022
1 parent ef2e452 commit 59f4e90
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 47 deletions.
63 changes: 32 additions & 31 deletions AssignAll/AssignAll.Test/UnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -533,15 +533,15 @@ public async Task FileWithTopLevelStatements_AddsDiagnostic()
{
var test = @"
// AssignAll enable
var foo = {|#0:new Foo
var foo = {|#0:new Program.Foo
{
// PropInt and PropString not assigned, diagnostic error
}|#0};
// Add methods and nested types available to top level statements via a partial Program class.
public static partial class Program
{
private class Foo
internal class Foo
{
public int PropInt { get; set; }
public string PropString { get; set; }
Expand Down Expand Up @@ -673,39 +673,40 @@ public async Task Inheritance_AnalyzesMembersOfBaseTypes()
var test = @"
// AssignAll enable
// EXAMPLE 004 - Analyzer should also consider public members from any base types.
namespace Samples.ConsoleNet6;
public static class Example004_Inheritance
namespace Samples.ConsoleNet6
{
public static void Irrelevant()
public static class Example004_Inheritance
{
// This should give analyzer error:
// Missing member assignments in object initializer for type 'Derived'. Properties: BasePropUnassigned, DerivedPropUnassigned
var foo = {|#0:new Derived
{
// Commented assignments after opening brace.
// BasePropCommented = ,
// DerivedPropCommented = ,
// Assigned property, OK by analyzer
BasePropAssigned = 1,
DerivedPropAssigned = 1,
}|#0};
}
}
public static void Irrelevant()
{
// This should give analyzer error:
// Missing member assignments in object initializer for type 'Derived'. Properties: BasePropUnassigned, DerivedPropUnassigned
var foo = {|#0:new Derived
{
// Commented assignments after opening brace.
// BasePropCommented = ,
// DerivedPropCommented = ,
internal class Base
{
public int BasePropAssigned { get; set; }
public int BasePropCommented { get; set; }
public int BasePropUnassigned { get; set; }
}
// Assigned property, OK by analyzer
BasePropAssigned = 1,
DerivedPropAssigned = 1,
}|#0};
}
internal class Derived : Base
{
public int DerivedPropAssigned { get; set; }
public int DerivedPropCommented { get; set; }
public int DerivedPropUnassigned { get; set; }
private class Base
{
public int BasePropAssigned { get; set; }
public int BasePropCommented { get; set; }
public int BasePropUnassigned { get; set; }
}
private class Derived : Base
{
public int DerivedPropAssigned { get; set; }
public int DerivedPropCommented { get; set; }
public int DerivedPropUnassigned { get; set; }
}
}
}
";

Expand Down
8 changes: 0 additions & 8 deletions Samples.ConsoleNet6/Base.cs

This file was deleted.

8 changes: 0 additions & 8 deletions Samples.ConsoleNet6/Derived.cs

This file was deleted.

14 changes: 14 additions & 0 deletions Samples.ConsoleNet6/Example004_Inheritance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,18 @@ public static void Irrelevant()
DerivedPropAssigned = 1,
};
}

private class Base
{
public int BasePropAssigned { get; set; }
public int BasePropCommented { get; set; }
public int BasePropUnassigned { get; set; }
}

private class Derived : Base
{
public int DerivedPropAssigned { get; set; }
public int DerivedPropCommented { get; set; }
public int DerivedPropUnassigned { get; set; }
}
}

0 comments on commit 59f4e90

Please sign in to comment.