Skip to content

Commit

Permalink
housekeeping: prep for testing project source scanning (#425)
Browse files Browse the repository at this point in the history
* prep to inject test config + mahapps

* logic for injecting build property config in test

* change split to comma

* prep test for project source scanning

* initial logic for checking the concept of project source code scanning

* fix build
  • Loading branch information
dpvreony authored Jun 17, 2024
1 parent ed79d7a commit e950c30
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using Vetuviem.Avalonia.SourceGenerator;
using Vetuviem.SourceGenerator.Features.ControlBindingModels;
using Vetuviem.Testing;
using Vetuviem.Winforms.SourceGenerator;
using Xunit.Abstractions;

namespace Vetuviem.IntegrationTests.ReactiveUI.Avalonia
Expand All @@ -32,6 +31,12 @@ public ExecuteMethod(ITestOutputHelper output)
{
}

/// <inheritdoc />
protected override string GetProjectSourceCode()
{
return string.Empty;
}

/// <inheritdoc />
protected override AnalyzerConfigOptionsProvider? GetAnalyzerConfigOptionsProvider()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022 DPVreony and Contributors. All rights reserved.
// Copyright (c) 2022 DPVreony and Contributors. All rights reserved.
// DPVreony and Contributors licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

Expand Down Expand Up @@ -31,6 +31,20 @@ public ExecuteMethod(ITestOutputHelper output)
{
}

/// <inheritdoc />
protected override string GetProjectSourceCode()
{
return """
public sealed class MainWindow : MahApps.Metro.Controls.MetroWindow
{
public MainWindow()
{
InitializeComponent();
}
}
""";
}

/// <inheritdoc />
protected override AnalyzerConfigOptionsProvider? GetAnalyzerConfigOptionsProvider()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ public ExecuteMethod(ITestOutputHelper output)
{
}

/// <inheritdoc />
protected override string GetProjectSourceCode()
{
return string.Empty;
}

/// <inheritdoc />
protected override AnalyzerConfigOptionsProvider? GetAnalyzerConfigOptionsProvider()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ public ExecuteMethod(ITestOutputHelper output)
{
}

/// <inheritdoc />
protected override string GetProjectSourceCode()
{
return string.Empty;
}

/// <inheritdoc />
protected override AnalyzerConfigOptionsProvider? GetAnalyzerConfigOptionsProvider()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022 DPVreony and Contributors. All rights reserved.
// Copyright (c) 2022 DPVreony and Contributors. All rights reserved.
// DPVreony and Contributors licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

Expand Down Expand Up @@ -31,6 +31,12 @@ public ExecuteMethod(ITestOutputHelper output)
{
}

/// <inheritdoc />
protected override string GetProjectSourceCode()
{
return string.Empty;
}

/// <inheritdoc />
protected override AnalyzerConfigOptionsProvider? GetAnalyzerConfigOptionsProvider()
{
Expand Down
6 changes: 5 additions & 1 deletion src/Vetuviem.Testing/BaseGeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ public void GeneratesCode()

AddReferenceAssemblies(references);

var comp = CreateCompilation(string.Empty, references);
var source = GetProjectSourceCode();

var comp = CreateCompilation(source, references);

var analyzerConfigOptionsProvider = GetAnalyzerConfigOptionsProvider();

Expand Down Expand Up @@ -92,6 +94,8 @@ public void GeneratesCode()

}

protected abstract string GetProjectSourceCode();

Check warning on line 97 in src/Vetuviem.Testing/BaseGeneratorTests.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Missing XML comment for publicly visible type or member 'BaseGeneratorTests.BaseExecuteMethod<TGenerator, TGeneratorProcessor>.GetProjectSourceCode()'

Check warning on line 97 in src/Vetuviem.Testing/BaseGeneratorTests.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'BaseGeneratorTests.BaseExecuteMethod<TGenerator, TGeneratorProcessor>.GetProjectSourceCode()'

/// <summary>
/// Gets the analyzer config options provider to test with.
/// </summary>
Expand Down

0 comments on commit e950c30

Please sign in to comment.