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
6 changes: 3 additions & 3 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="$(MicrosoftExtensionsConfigurationAbstractionsVersion)" />

<!-- Roslyn dependencies-->
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="$(MicrosoftCodeAnalysisVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="$(MicrosoftCodeAnalysisVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="$(MicrosoftCodeAnalysisVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="$(MicrosoftCodeAnalysisCSharpVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="$(MicrosoftCodeAnalysisCSharpWorkspacesVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="$(MicrosoftCodeAnalysisWorkspacesMSBuildVersion)" />

<!-- analyzer dependencies-->
<GlobalPackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
Expand Down
12 changes: 12 additions & 0 deletions eng/Version.Details.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ This file should be imported by eng/Versions.props
<Project>
<PropertyGroup>
<!-- dotnet/dotnet dependencies -->
<MicrosoftBuildFrameworkPackageVersion>17.15.0-preview-25457-102</MicrosoftBuildFrameworkPackageVersion>
<MicrosoftBuildTasksCorePackageVersion>17.15.0-preview-25457-102</MicrosoftBuildTasksCorePackageVersion>
<MicrosoftBuildUtilitiesCorePackageVersion>17.15.0-preview-25457-102</MicrosoftBuildUtilitiesCorePackageVersion>
<MicrosoftCodeAnalysisCSharpPackageVersion>5.0.0-2.25457.102</MicrosoftCodeAnalysisCSharpPackageVersion>
<MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>5.0.0-2.25457.102</MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>
<MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>5.0.0-2.25457.102</MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>
<MicrosoftDotNetArcadeSdkPackageVersion>10.0.0-beta.25420.121</MicrosoftDotNetArcadeSdkPackageVersion>
<MicrosoftDotNetBuildTasksTemplatingPackageVersion>10.0.0-beta.25420.121</MicrosoftDotNetBuildTasksTemplatingPackageVersion>
<MicrosoftDotNetHelixSdkPackageVersion>10.0.0-beta.25420.121</MicrosoftDotNetHelixSdkPackageVersion>
Expand All @@ -28,6 +34,12 @@ This file should be imported by eng/Versions.props
<!--Property group for alternate package version names-->
<PropertyGroup>
<!-- dotnet/dotnet dependencies -->
<MicrosoftBuildFrameworkVersion>$(MicrosoftBuildFrameworkPackageVersion)</MicrosoftBuildFrameworkVersion>
<MicrosoftBuildTasksCoreVersion>$(MicrosoftBuildTasksCorePackageVersion)</MicrosoftBuildTasksCoreVersion>
<MicrosoftBuildUtilitiesCoreVersion>$(MicrosoftBuildUtilitiesCorePackageVersion)</MicrosoftBuildUtilitiesCoreVersion>
<MicrosoftCodeAnalysisCSharpVersion>$(MicrosoftCodeAnalysisCSharpPackageVersion)</MicrosoftCodeAnalysisCSharpVersion>
<MicrosoftCodeAnalysisCSharpWorkspacesVersion>$(MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion)</MicrosoftCodeAnalysisCSharpWorkspacesVersion>
<MicrosoftCodeAnalysisWorkspacesMSBuildVersion>$(MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion)</MicrosoftCodeAnalysisWorkspacesMSBuildVersion>
<MicrosoftDotNetArcadeSdkVersion>$(MicrosoftDotNetArcadeSdkPackageVersion)</MicrosoftDotNetArcadeSdkVersion>
<MicrosoftDotNetBuildTasksTemplatingVersion>$(MicrosoftDotNetBuildTasksTemplatingPackageVersion)</MicrosoftDotNetBuildTasksTemplatingVersion>
<MicrosoftDotNetHelixSdkVersion>$(MicrosoftDotNetHelixSdkPackageVersion)</MicrosoftDotNetHelixSdkVersion>
Expand Down
7 changes: 1 addition & 6 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,11 @@
<UsingToolXliff>False</UsingToolXliff>
</PropertyGroup>
<PropertyGroup Label="Other dependencies">
<MicrosoftBuildFrameworkVersion>17.14.8</MicrosoftBuildFrameworkVersion>
<MicrosoftBuildUtilitiesCoreVersion>17.14.8</MicrosoftBuildUtilitiesCoreVersion>
<MicrosoftBuildTasksCoreVersion>17.14.8</MicrosoftBuildTasksCoreVersion>
<!-- NB: This version affects Visual Studio compatibility. See https://github.com/dotnet/roslyn/blob/main/docs/wiki/NuGet-packages.md and https://learn.microsoft.com/visualstudio/extensibility/roslyn-version-support -->
<MicrosoftCodeAnalysisVersion>4.14.0</MicrosoftCodeAnalysisVersion>
<MicrosoftCodeAnalysisAnalyzerTestingVersion>1.1.3-beta1.24423.1</MicrosoftCodeAnalysisAnalyzerTestingVersion>
<MicrosoftCodeAnalysisCSharpTestingVersion>1.1.3-beta1.24352.1</MicrosoftCodeAnalysisCSharpTestingVersion>
<AzureIdentityVersion>1.14.2</AzureIdentityVersion>
<AzureResourceManagerCosmosDBVersion>1.3.2</AzureResourceManagerCosmosDBVersion>
<OpenTelemetryExporterInMemoryVersion>1.12.0</OpenTelemetryExporterInMemoryVersion>
<SQLitePCLRawVersion>2.1.11</SQLitePCLRawVersion>
</PropertyGroup>
</Project>
</Project>
4 changes: 0 additions & 4 deletions eng/common/core-templates/job/source-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ parameters:
# container and pool.
platform: {}

# Optional list of directories to ignore for component governance scans.
componentGovernanceIgnoreDirectories: []

is1ESPipeline: ''

# If set to true and running on a non-public project,
Expand Down Expand Up @@ -97,4 +94,3 @@ jobs:
parameters:
is1ESPipeline: ${{ parameters.is1ESPipeline }}
platform: ${{ parameters.platform }}
componentGovernanceIgnoreDirectories: ${{ parameters.componentGovernanceIgnoreDirectories }}
2 changes: 1 addition & 1 deletion eng/common/core-templates/job/source-index-stage1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ jobs:

- template: /eng/common/core-templates/steps/source-index-stage1-publish.yml
parameters:
binLogPath: ${{ parameters.binLogPath }}
binLogPath: ${{ parameters.binLogPath }}
5 changes: 0 additions & 5 deletions eng/common/core-templates/jobs/source-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ parameters:
# one job runs on 'defaultManagedPlatform'.
platforms: []

# Optional list of directories to ignore for component governance scans.
componentGovernanceIgnoreDirectories: []

is1ESPipeline: ''

# If set to true and running on a non-public project,
Expand All @@ -34,7 +31,6 @@ jobs:
is1ESPipeline: ${{ parameters.is1ESPipeline }}
jobNamePrefix: ${{ parameters.jobNamePrefix }}
platform: ${{ platform }}
componentGovernanceIgnoreDirectories: ${{ parameters.componentGovernanceIgnoreDirectories }}
enableInternalSources: ${{ parameters.enableInternalSources }}

- ${{ if eq(length(parameters.platforms), 0) }}:
Expand All @@ -43,5 +39,4 @@ jobs:
is1ESPipeline: ${{ parameters.is1ESPipeline }}
jobNamePrefix: ${{ parameters.jobNamePrefix }}
platform: ${{ parameters.defaultManagedPlatform }}
componentGovernanceIgnoreDirectories: ${{ parameters.componentGovernanceIgnoreDirectories }}
enableInternalSources: ${{ parameters.enableInternalSources }}
4 changes: 0 additions & 4 deletions eng/common/core-templates/steps/source-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ parameters:
# for details. The entire object is described in the 'job' template for simplicity, even though
# the usage of the properties on this object is split between the 'job' and 'steps' templates.
platform: {}

# Optional list of directories to ignore for component governance scans.
componentGovernanceIgnoreDirectories: []

is1ESPipeline: false

steps:
Expand Down
2 changes: 1 addition & 1 deletion eng/common/sdk-task.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ show_usage() {

echo "Advanced settings:"
echo " --excludeCIBinarylog Don't output binary log (short: -nobl)"
echo " --noWarnAsError Do not warn as error
echo " --noWarnAsError Do not warn as error"
echo ""
echo "Command line arguments not listed above are passed thru to msbuild."
}
Expand Down
33 changes: 25 additions & 8 deletions src/EFCore.Design/Design/Internal/DbContextOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Text;
using Microsoft.Build.Locator;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Editing;
using Microsoft.CodeAnalysis.MSBuild;
Expand Down Expand Up @@ -298,23 +297,41 @@ private IReadOnlyList<string> PrecompileQueries(
{
outputDir = Path.GetFullPath(Path.Combine(_projectDir, outputDir ?? "Generated"));

if (!MSBuildLocator.IsRegistered)
// TODO: pass through properties
MSBuildWorkspace workspace = null!;
Project project;

try
{
MSBuildLocator.RegisterDefaults();
workspace = MSBuildWorkspace.Create();
workspace.LoadMetadataForReferencedProjects = true;
workspace.RegisterWorkspaceFailedHandler(e =>
{
_reporter.WriteError(DesignStrings.MSBuildWorkspaceFailure(e.Diagnostic.Kind, e.Diagnostic.Message));
});
project = workspace.OpenProjectAsync(_project).GetAwaiter().GetResult();
}
catch (Exception ex)
{
if (workspace != null && !workspace.Diagnostics.IsEmpty)
{
var diagnosticMessages = Environment.NewLine + string.Join(Environment.NewLine,
workspace.Diagnostics.Select(d => $" {d.Kind}: {d.Message}"));
_reporter.WriteVerbose(DesignStrings.MSBuildWorkspaceDiagnostics(diagnosticMessages));
}

throw new InvalidOperationException(
DesignStrings.QueryPrecompilationProjectLoadFailed(_project, ex.Message), ex);
}

// TODO: pass through properties
var workspace = MSBuildWorkspace.Create();
workspace.LoadMetadataForReferencedProjects = true;
var project = workspace.OpenProjectAsync(_project).GetAwaiter().GetResult();
if (!project.SupportsCompilation)
{
throw new NotSupportedException(DesignStrings.UncompilableProject(_project));
}

var compilation = project.GetCompilationAsync().GetAwaiter().GetResult()!;
var errorDiagnostics = compilation.GetDiagnostics().Where(d => d.Severity == DiagnosticSeverity.Error).ToArray();
if (errorDiagnostics.Any())
if (errorDiagnostics.Length != 0)
{
var errorBuilder = new StringBuilder();
errorBuilder.AppendLine(DesignStrings.CompilationErrors);
Expand Down
3 changes: 1 addition & 2 deletions src/EFCore.Design/EFCore.Design.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@
<ItemGroup>
<PackageReference Include="Humanizer.Core" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" />
<PackageReference Include="Microsoft.Build.Locator" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" PrivateAssets="analyzers;build" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" />
<PackageReference Include="Microsoft.Extensions.HostFactoryResolver.Sources" PrivateAssets="All" />
<PackageReference Include="Mono.TextTemplating" />
Expand Down
24 changes: 24 additions & 0 deletions src/EFCore.Design/Properties/DesignStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions src/EFCore.Design/Properties/DesignStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,12 @@ Consider changing your target project to the DbContext project by using the Pack
Change your migrations assembly by using DbContextOptionsBuilder. E.g. options.UseSqlServer(connection, b =&gt; b.MigrationsAssembly("{assembly}")). By default, the migrations assembly is the assembly containing the DbContext.
Change your target project to the migrations project by using the Package Manager Console's Default project drop-down list, or by executing "dotnet ef" from the directory containing the migrations project.</value>
</data>
<data name="MSBuildWorkspaceDiagnostics" xml:space="preserve">
<value>MSBuild Workspace diagnostics:{diagnostics}</value>
</data>
<data name="MSBuildWorkspaceFailure" xml:space="preserve">
<value>MSBuild Workspace failure: {kind} - {message}</value>
</data>
<data name="MultipleAnnotationConflict" xml:space="preserve">
<value>The annotation '{annotationName}' was specified twice with potentially different values. Specifying the same annotation multiple times for different providers is no longer supported. Review the generated Migration to ensure it is correct and, if necessary, edit the Migration to fix any issues.</value>
</data>
Expand Down Expand Up @@ -384,6 +390,9 @@ Change your target project to the migrations project by using the Package Manage
<data name="QueryPrecompilationErrors" xml:space="preserve">
<value>Query precompilation failed with errors:</value>
</data>
<data name="QueryPrecompilationProjectLoadFailed" xml:space="preserve">
<value>Failed to load project for query precompilation. Project: {project}. Error: {error}</value>
</data>
<data name="ReadOnlyFiles" xml:space="preserve">
<value>No files were generated in directory '{outputDirectoryName}'. The following file(s) already exist(s) and must be made writeable to continue: {readOnlyFiles}.</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<Project ToolsVersion="17.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_TaskTargetFramework Condition="'$(MSBuildRuntimeType)' == 'core'">net10.0</_TaskTargetFramework>
<_TaskTargetFramework Condition="'$(MSBuildRuntimeType)' != 'core'">net472</_TaskTargetFramework>
<_TaskTargetFramework Condition="'$(MSBuildRuntimeType)' == 'Core'">net10.0</_TaskTargetFramework>
<_TaskTargetFramework Condition="'$(MSBuildRuntimeType)' != 'Core'">net472</_TaskTargetFramework>
<_EFCustomTasksAssembly>$([MSBuild]::NormalizePath($(MSBuildThisFileDirectory),'..\tasks\$(_TaskTargetFramework)\$(MSBuildThisFileName).dll'))</_EFCustomTasksAssembly>
<EFScaffoldModelStage Condition="'$(EFScaffoldModelStage)'==''">publish</EFScaffoldModelStage>
<EFPrecompileQueriesStage Condition="'$(EFPrecompileQueriesStage)'==''">publish</EFPrecompileQueriesStage>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
<PropertyGroup>
<_FullOutputPath>$([MSBuild]::NormalizePath('$(MSBuildProjectDirectory)', '$(OutputPath)'))</_FullOutputPath>
<_FullIntermediateOutputPath>$([MSBuild]::NormalizePath('$(MSBuildProjectDirectory)', '$(IntermediateOutputPath)'))</_FullIntermediateOutputPath>
<_FullIntermediateOutputPath Condition="'$(AppendRuntimeIdentifierToOutputPath)' == 'true' And '$(RuntimeIdentifier)' != '' And '$(_UsingDefaultRuntimeIdentifier)' != 'true' And '$(UseArtifactsIntermediateOutput)' != 'true'">
$([MSBuild]::NormalizePath('$(_FullIntermediateOutputPath)',
'../'))
</_FullIntermediateOutputPath>
<_FullIntermediateOutputPath Condition="'$(AppendRuntimeIdentifierToOutputPath)' == 'true' And '$(RuntimeIdentifier)' != '' And '$(_UsingDefaultRuntimeIdentifier)' != 'true' And '$(UseArtifactsIntermediateOutput)' != 'true'">$([MSBuild]::NormalizePath('$(_FullIntermediateOutputPath)', '../'))</_FullIntermediateOutputPath>
<EFGeneratedSourcesBuildFile Condition="'$(EFGeneratedSourcesBuildFile)' == ''">$(_FullIntermediateOutputPath)$(AssemblyName).EFGeneratedSources.Build.txt</EFGeneratedSourcesBuildFile>
<EFGeneratedSourcesPublishFile Condition="'$(EFGeneratedSourcesPublishFile)' == ''">$(_FullIntermediateOutputPath)$(AssemblyName).EFGeneratedSources.Publish.txt</EFGeneratedSourcesPublishFile>
<_AssemblyFullName>$(_FullOutputPath)$(AssemblyName).dll</_AssemblyFullName>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
// 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.Types;
namespace Microsoft.EntityFrameworkCore.Types.Miscellaneous;

public class BoolTypeTest(BoolTypeTest.BoolTypeFixture fixture)
: TypeTestBase<bool, BoolTypeTest.BoolTypeFixture>(fixture)
{
public class BoolTypeFixture() : TypeTestFixture(true, false)
public class BoolTypeFixture : TypeTestFixture
{
public override bool Value { get; } = true;
public override bool OtherValue { get; } = false;

protected override ITestStoreFactory TestStoreFactory => CosmosTestStoreFactory.Instance;

public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder)
Expand All @@ -18,8 +21,11 @@ public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder build
public class StringTypeTest(StringTypeTest.StringTypeFixture fixture)
: TypeTestBase<string, StringTypeTest.StringTypeFixture>(fixture)
{
public class StringTypeFixture() : TypeTestFixture("foo", "bar")
public class StringTypeFixture : TypeTestFixture
{
public override string Value { get; } = "foo";
public override string OtherValue { get; } = "bar";

protected override ITestStoreFactory TestStoreFactory => CosmosTestStoreFactory.Instance;

public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder)
Expand All @@ -30,10 +36,11 @@ public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder build
public class GuidTypeTest(GuidTypeTest.GuidTypeFixture fixture)
: TypeTestBase<Guid, GuidTypeTest.GuidTypeFixture>(fixture)
{
public class GuidTypeFixture() : TypeTestFixture(
new Guid("8f7331d6-cde9-44fb-8611-81fff686f280"),
new Guid("ae192c36-9004-49b2-b785-8be10d169627"))
public class GuidTypeFixture : TypeTestFixture
{
public override Guid Value { get; } = new("8f7331d6-cde9-44fb-8611-81fff686f280");
public override Guid OtherValue { get; } = new("ae192c36-9004-49b2-b785-8be10d169627");

protected override ITestStoreFactory TestStoreFactory => CosmosTestStoreFactory.Instance;

public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder)
Expand All @@ -44,8 +51,11 @@ public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder build
public class ByteArrayTypeTest(ByteArrayTypeTest.ByteArrayTypeFixture fixture)
: TypeTestBase<byte[], ByteArrayTypeTest.ByteArrayTypeFixture>(fixture)
{
public class ByteArrayTypeFixture() : TypeTestFixture([1, 2, 3], [4, 5, 6])
public class ByteArrayTypeFixture : TypeTestFixture
{
public override byte[] Value { get; } = [1, 2, 3];
public override byte[] OtherValue { get; } = [4, 5, 6, 7];

protected override ITestStoreFactory TestStoreFactory => CosmosTestStoreFactory.Instance;

public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder)
Expand Down
Loading
Loading