diff --git a/eng/Versions.props b/eng/Versions.props index ea8578f493f..bd1faf3be27 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -25,8 +25,9 @@ 5.0.0 - 1.1.3-beta1.24423.1 - 1.1.3-beta1.24352.1 + + 1.1.3-beta1.25564.1 + 1.1.3-beta1.25564.1 1.14.2 1.3.2 1.12.0 diff --git a/test/Directory.Packages.props b/test/Directory.Packages.props index a8de0f51fad..5f91b30eb58 100644 --- a/test/Directory.Packages.props +++ b/test/Directory.Packages.props @@ -3,11 +3,9 @@ - - - - + + diff --git a/test/EFCore.Analyzers.Tests/EFCore.Analyzers.Tests.csproj b/test/EFCore.Analyzers.Tests/EFCore.Analyzers.Tests.csproj index c763d148fe9..e7ddaa47503 100644 --- a/test/EFCore.Analyzers.Tests/EFCore.Analyzers.Tests.csproj +++ b/test/EFCore.Analyzers.Tests/EFCore.Analyzers.Tests.csproj @@ -45,8 +45,8 @@ - - + + diff --git a/test/EFCore.Analyzers.Tests/InternalUsageDiagnosticAnalyzerTests.cs b/test/EFCore.Analyzers.Tests/InternalUsageDiagnosticAnalyzerTests.cs index 90eed492da1..2b4af91332a 100644 --- a/test/EFCore.Analyzers.Tests/InternalUsageDiagnosticAnalyzerTests.cs +++ b/test/EFCore.Analyzers.Tests/InternalUsageDiagnosticAnalyzerTests.cs @@ -7,8 +7,7 @@ namespace Microsoft.EntityFrameworkCore; using VerifyCS = CSharpAnalyzerVerifier; -//Issue #37106 -internal class InternalUsageDiagnosticAnalyzerTests +public class InternalUsageDiagnosticAnalyzerTests { [ConditionalFact] public Task Invocation_on_type_in_internal_namespace() diff --git a/test/EFCore.Analyzers.Tests/StringConcatenationInRawQueriesAnalyzerTests.cs b/test/EFCore.Analyzers.Tests/StringConcatenationInRawQueriesAnalyzerTests.cs index 48963734feb..7f603b10de5 100644 --- a/test/EFCore.Analyzers.Tests/StringConcatenationInRawQueriesAnalyzerTests.cs +++ b/test/EFCore.Analyzers.Tests/StringConcatenationInRawQueriesAnalyzerTests.cs @@ -7,8 +7,7 @@ namespace Microsoft.EntityFrameworkCore; using Verify = CSharpAnalyzerVerifier; -//Issue #37106 -internal class StringConcatenationInRawQueriesAnalyzerTests +public class StringConcatenationInRawQueriesAnalyzerTests { public static readonly TheoryData DoNotReportData = [ diff --git a/test/EFCore.Analyzers.Tests/StringInterpolationInRawQueriesAnalyzerTests.cs b/test/EFCore.Analyzers.Tests/StringInterpolationInRawQueriesAnalyzerTests.cs index 96ebd077586..692607eb15c 100644 --- a/test/EFCore.Analyzers.Tests/StringInterpolationInRawQueriesAnalyzerTests.cs +++ b/test/EFCore.Analyzers.Tests/StringInterpolationInRawQueriesAnalyzerTests.cs @@ -7,8 +7,7 @@ namespace Microsoft.EntityFrameworkCore; using Verify = CSharpCodeFixVerifier; -//Issue #37106 -internal class StringInterpolationInRawQueriesAnalyzerTests +public class StringInterpolationInRawQueriesAnalyzerTests { public static readonly TheoryData DoNotReportData = [ diff --git a/test/EFCore.Analyzers.Tests/TestUtilities/CSharpAnalyzerVerifier.cs b/test/EFCore.Analyzers.Tests/TestUtilities/CSharpAnalyzerVerifier.cs index 2f5ee948477..db9096a7e30 100644 --- a/test/EFCore.Analyzers.Tests/TestUtilities/CSharpAnalyzerVerifier.cs +++ b/test/EFCore.Analyzers.Tests/TestUtilities/CSharpAnalyzerVerifier.cs @@ -1,14 +1,11 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Collections.Immutable; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Testing; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Testing; -using Microsoft.CodeAnalysis.Testing.Model; -using Microsoft.CodeAnalysis.Testing.Verifiers; using Microsoft.Extensions.DependencyModel; using CompilationOptions = Microsoft.CodeAnalysis.CompilationOptions; @@ -18,9 +15,7 @@ public static class CSharpAnalyzerVerifier where TAnalyzer : DiagnosticAnalyzer, new() { public static DiagnosticResult Diagnostic(string diagnosticId) -#pragma warning disable CS0618 // Type or member is obsolete - => CSharpAnalyzerVerifier.Diagnostic(diagnosticId); -#pragma warning restore CS0618 // Type or member is obsolete + => CSharpAnalyzerVerifier.Diagnostic(diagnosticId); public static Task VerifyAnalyzerAsync(string source, params DiagnosticResult[] expected) { @@ -29,37 +24,31 @@ public static Task VerifyAnalyzerAsync(string source, params DiagnosticResult[] return test.RunAsync(); } -#pragma warning disable CS0618 // Type or member is obsolete - public class Test : CSharpAnalyzerTest -#pragma warning restore CS0618 // Type or member is obsolete + public class Test : CSharpAnalyzerTest { - protected override CompilationOptions CreateCompilationOptions() + public Test() { - var cSharpOptions = (CSharpCompilationOptions)base.CreateCompilationOptions(); - return cSharpOptions - .WithNullableContextOptions(NullableContextOptions.Enable) - .WithSpecificDiagnosticOptions( - new Dictionary - { - { "CS1701", ReportDiagnostic.Suppress }, { "CS1591", ReportDiagnostic.Suppress } - }); - } + ReferenceAssemblies = ReferenceAssemblies.Net.Net100; - protected override async Task CreateProjectImplAsync( - EvaluatedProjectState primaryProject, - ImmutableArray additionalProjects, - CancellationToken cancellationToken) - { - var metadataReferences - = DependencyContext.Load(GetType().Assembly)! + if (NugetConfigFinder.Find() is string nuGetConfigFilePath) + { + ReferenceAssemblies = ReferenceAssemblies.Net.Net100.WithNuGetConfigFilePath(nuGetConfigFilePath); + } + + TestState.AdditionalReferences.AddRange( + DependencyContext.Load(GetType().Assembly)! .CompileLibraries .SelectMany(c => c.ResolveReferencePaths()) .Select(path => MetadataReference.CreateFromFile(path)) - .Cast() - .ToList(); + .Cast()); - var project = await base.CreateProjectImplAsync(primaryProject, additionalProjects, cancellationToken).ConfigureAwait(false); - return project.WithMetadataReferences(metadataReferences); + DisabledDiagnostics.AddRange( + "CS1701", // Assuming assembly reference '...' used by '...' matches identity '...' of '...', you may need to supply runtime policy + "CS1591" // Missing XML comment for publicly visible type or member '...' + ); } + + protected override CompilationOptions CreateCompilationOptions() + => ((CSharpCompilationOptions)base.CreateCompilationOptions()).WithNullableContextOptions(NullableContextOptions.Enable); } } diff --git a/test/EFCore.Analyzers.Tests/TestUtilities/CSharpCodeFixVerifier.cs b/test/EFCore.Analyzers.Tests/TestUtilities/CSharpCodeFixVerifier.cs index 6fda4f4c1f9..923276f8d03 100644 --- a/test/EFCore.Analyzers.Tests/TestUtilities/CSharpCodeFixVerifier.cs +++ b/test/EFCore.Analyzers.Tests/TestUtilities/CSharpCodeFixVerifier.cs @@ -1,15 +1,14 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Collections.Immutable; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CodeFixes; +using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Testing; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Testing; -using Microsoft.CodeAnalysis.Testing.Model; -using Microsoft.CodeAnalysis.Testing.Verifiers; using Microsoft.Extensions.DependencyModel; +using CompilationOptions = Microsoft.CodeAnalysis.CompilationOptions; namespace Microsoft.EntityFrameworkCore.TestUtilities; @@ -18,9 +17,7 @@ public static class CSharpCodeFixVerifier where TCodeFix : CodeFixProvider, new() { public static DiagnosticResult Diagnostic(string diagnosticId) -#pragma warning disable CS0618 // Type or member is obsolete - => CSharpAnalyzerVerifier.Diagnostic(diagnosticId); -#pragma warning restore CS0618 // Type or member is obsolete + => CSharpAnalyzerVerifier.Diagnostic(diagnosticId); public static Task VerifyAnalyzerAsync(string source, params DiagnosticResult[] expected) { @@ -36,25 +33,31 @@ public static async Task VerifyCodeFixAsync(string source, string fixedSource, p await test.RunAsync(); } -#pragma warning disable CS0618 // Type or member is obsolete - public class Test : CSharpCodeFixTest -#pragma warning restore CS0618 // Type or member is obsolete + public class Test : CSharpCodeFixTest { - protected override async Task CreateProjectImplAsync( - EvaluatedProjectState primaryProject, - ImmutableArray additionalProjects, - CancellationToken cancellationToken) + public Test() { - var metadataReferences - = DependencyContext.Load(GetType().Assembly)! + ReferenceAssemblies = ReferenceAssemblies.Net.Net100; + + if (NugetConfigFinder.Find() is string nuGetConfigFilePath) + { + ReferenceAssemblies = ReferenceAssemblies.Net.Net100.WithNuGetConfigFilePath(nuGetConfigFilePath); + } + + TestState.AdditionalReferences.AddRange( + DependencyContext.Load(GetType().Assembly)! .CompileLibraries .SelectMany(c => c.ResolveReferencePaths()) .Select(path => MetadataReference.CreateFromFile(path)) - .Cast() - .ToList(); + .Cast()); - var project = await base.CreateProjectImplAsync(primaryProject, additionalProjects, cancellationToken).ConfigureAwait(false); - return project.WithMetadataReferences(metadataReferences); + DisabledDiagnostics.AddRange( + "CS1701", // Assuming assembly reference '...' used by '...' matches identity '...' of '...', you may need to supply runtime policy + "CS1591" // Missing XML comment for publicly visible type or member '...' + ); } + + protected override CompilationOptions CreateCompilationOptions() + => ((CSharpCompilationOptions)base.CreateCompilationOptions()).WithNullableContextOptions(NullableContextOptions.Enable); } } diff --git a/test/EFCore.Analyzers.Tests/TestUtilities/NugetConfigFinder.cs b/test/EFCore.Analyzers.Tests/TestUtilities/NugetConfigFinder.cs new file mode 100644 index 00000000000..f61789ba900 --- /dev/null +++ b/test/EFCore.Analyzers.Tests/TestUtilities/NugetConfigFinder.cs @@ -0,0 +1,36 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.EntityFrameworkCore.TestUtilities; + +internal static class NugetConfigFinder +{ + private static bool _searched; + private static string? _nugetConfigPath; + + public static string? Find() + { + if (_searched) + { + return _nugetConfigPath; + } + + var path = AppContext.BaseDirectory; + var currentDirectory = path; + while (currentDirectory is not null) + { + var nugetConfigPath = Path.Combine(currentDirectory, "NuGet.config"); + + if (File.Exists(nugetConfigPath)) + { + _nugetConfigPath = nugetConfigPath; + break; + } + + currentDirectory = Directory.GetParent(currentDirectory)?.ToString(); + } + + _searched = true; + return _nugetConfigPath; + } +} diff --git a/test/EFCore.Analyzers.Tests/UninitializedDbSetDiagnosticSuppressorTests.cs b/test/EFCore.Analyzers.Tests/UninitializedDbSetDiagnosticSuppressorTests.cs index 6b4ad43390b..dea9afcd00e 100644 --- a/test/EFCore.Analyzers.Tests/UninitializedDbSetDiagnosticSuppressorTests.cs +++ b/test/EFCore.Analyzers.Tests/UninitializedDbSetDiagnosticSuppressorTests.cs @@ -7,8 +7,7 @@ namespace Microsoft.EntityFrameworkCore; using VerifyCS = CSharpAnalyzerVerifier; -//Issue #37106 -internal class UninitializedDbSetDiagnosticSuppressorTests +public class UninitializedDbSetDiagnosticSuppressorTests { [ConditionalFact] public Task DbSet_property_on_DbContext_is_suppressed()