Skip to content

Commit

Permalink
Port FunctionalTests to .NET Core 3
Browse files Browse the repository at this point in the history
Part of dotnet#271
  • Loading branch information
bricelam committed May 31, 2019
1 parent 4343381 commit daec698
Show file tree
Hide file tree
Showing 99 changed files with 603 additions and 1,119 deletions.
9 changes: 9 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,13 @@
<!-- HACK: Work around dotnet/sdk#2976 in dependencies -->
<BundledNETCorePlatformsPackageVersion>$(MicrosoftNETCorePlatformsPackageVersion)</BundledNETCorePlatformsPackageVersion>
</PropertyGroup>

<ItemGroup>
<!-- HACK: Use the latest version instead of the one bundled with the SDK -->
<KnownFrameworkReference Update="Microsoft.NETCore.App">
<LatestRuntimeFrameworkVersion Condition="'%(TargetFramework)' == 'netcoreapp3.0'">$(MicrosoftNETCoreAppPackageVersion)</LatestRuntimeFrameworkVersion>
<DefaultRuntimeFrameworkVersion Condition="'%(TargetFramework)' == 'netcoreapp3.0'">$(MicrosoftNETCoreAppPackageVersion)</DefaultRuntimeFrameworkVersion>
<TargetingPackVersion Condition="'%(TargetFramework)' == 'netcoreapp3.0'">$(MicrosoftNETCoreAppPackageVersion)</TargetingPackVersion>
</KnownFrameworkReference>
</ItemGroup>
</Project>
7 changes: 0 additions & 7 deletions EntityFramework.sln
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FunctionalTests.Transitiona
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FunctionalTests.ProviderAgnostic", "test\EntityFramework\FunctionalTests.ProviderAgnostic\FunctionalTests.ProviderAgnostic.csproj", "{C0B5124C-0133-4E0B-BF36-A32CE5AD9DAA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FunctionalTests.netcoreapp3.0", "test\EntityFramework\FunctionalTests.netcoreapp3.0\FunctionalTests.netcoreapp3.0.csproj", "{64CCAE09-6683-4FF5-91B0-C713864AA6E4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -93,10 +91,6 @@ Global
{C0B5124C-0133-4E0B-BF36-A32CE5AD9DAA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C0B5124C-0133-4E0B-BF36-A32CE5AD9DAA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C0B5124C-0133-4E0B-BF36-A32CE5AD9DAA}.Release|Any CPU.Build.0 = Release|Any CPU
{64CCAE09-6683-4FF5-91B0-C713864AA6E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{64CCAE09-6683-4FF5-91B0-C713864AA6E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{64CCAE09-6683-4FF5-91B0-C713864AA6E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{64CCAE09-6683-4FF5-91B0-C713864AA6E4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -108,7 +102,6 @@ Global
{CF1C27F8-D603-4960-BE99-BCF348545368} = {24A9C4D1-E189-4D3A-A2D7-36D3ED51D277}
{3D65611F-E8FB-4A33-9196-7836969D6378} = {24A9C4D1-E189-4D3A-A2D7-36D3ED51D277}
{C0B5124C-0133-4E0B-BF36-A32CE5AD9DAA} = {24A9C4D1-E189-4D3A-A2D7-36D3ED51D277}
{64CCAE09-6683-4FF5-91B0-C713864AA6E4} = {24A9C4D1-E189-4D3A-A2D7-36D3ED51D277}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D7045317-2675-4853-926A-4D4354176EEE}
Expand Down
28 changes: 16 additions & 12 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<Dependencies>
<ProductDependencies>
<Dependency Name="Microsoft.CSharp" Version="4.6.0-preview6.19278.7">
<Dependency Name="Microsoft.CSharp" Version="4.6.0-preview6.19279.8" CoherentParentDependency="Microsoft.NETCore.App">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>c7d48ca7732b7717e84d8375588d83866104ef58</Sha>
<Sha>e23119d577e644d2c2a25419c88c1181681358e0</Sha>
</Dependency>
<Dependency Name="Microsoft.NETCore.Platforms" Version="3.0.0-preview6.19278.7">
<Dependency Name="Microsoft.NETCore.App" Version="3.0.0-preview6-27730-01">
<Uri>https://github.com/dotnet/core-setup</Uri>
<Sha>63abc77da6d99470caa5bfa0465afe244105e595</Sha>
</Dependency>
<Dependency Name="Microsoft.NETCore.Platforms" Version="3.0.0-preview6.19279.8" CoherentParentDependency="Microsoft.NETCore.App">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>c7d48ca7732b7717e84d8375588d83866104ef58</Sha>
<Sha>e23119d577e644d2c2a25419c88c1181681358e0</Sha>
</Dependency>
<Dependency Name="System.CodeDom" Version="4.6.0-preview6.19278.7">
<Dependency Name="System.CodeDom" Version="4.6.0-preview6.19279.8" CoherentParentDependency="Microsoft.NETCore.App">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>c7d48ca7732b7717e84d8375588d83866104ef58</Sha>
<Sha>e23119d577e644d2c2a25419c88c1181681358e0</Sha>
</Dependency>
<Dependency Name="System.ComponentModel.Annotations" Version="4.6.0-preview6.19278.7">
<Dependency Name="System.ComponentModel.Annotations" Version="4.6.0-preview6.19279.8" CoherentParentDependency="Microsoft.NETCore.App">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>c7d48ca7732b7717e84d8375588d83866104ef58</Sha>
<Sha>e23119d577e644d2c2a25419c88c1181681358e0</Sha>
</Dependency>
<Dependency Name="System.Configuration.ConfigurationManager" Version="4.6.0-preview6.19278.7">
<Dependency Name="System.Configuration.ConfigurationManager" Version="4.6.0-preview6.19279.8" CoherentParentDependency="Microsoft.NETCore.App">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>c7d48ca7732b7717e84d8375588d83866104ef58</Sha>
<Sha>e23119d577e644d2c2a25419c88c1181681358e0</Sha>
</Dependency>
<Dependency Name="System.Data.SqlClient" Version="4.7.0-preview6.19278.7">
<Dependency Name="System.Data.SqlClient" Version="4.7.0-preview6.19279.8" CoherentParentDependency="Microsoft.NETCore.App">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>c7d48ca7732b7717e84d8375588d83866104ef58</Sha>
<Sha>e23119d577e644d2c2a25419c88c1181681358e0</Sha>
</Dependency>
</ProductDependencies>
<ToolsetDependencies>
Expand Down
15 changes: 9 additions & 6 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@
<VSLangProjVersion>7.0.3301</VSLangProjVersion>
</PropertyGroup>
<PropertyGroup Label="Dependencies from dotnet/corefx">
<MicrosoftCSharpVersion>4.6.0-preview6.19278.7</MicrosoftCSharpVersion>
<MicrosoftNETCorePlatformsPackageVersion>3.0.0-preview6.19278.7</MicrosoftNETCorePlatformsPackageVersion>
<SystemCodeDomVersion>4.6.0-preview6.19278.7</SystemCodeDomVersion>
<SystemComponentModelAnnotationsVersion>4.6.0-preview6.19278.7</SystemComponentModelAnnotationsVersion>
<SystemConfigurationConfigurationManagerVersion>4.6.0-preview6.19278.7</SystemConfigurationConfigurationManagerVersion>
<SystemDataSqlClientVersion>4.7.0-preview6.19278.7</SystemDataSqlClientVersion>
<MicrosoftCSharpVersion>4.6.0-preview6.19279.8</MicrosoftCSharpVersion>
<MicrosoftNETCorePlatformsPackageVersion>3.0.0-preview6.19279.8</MicrosoftNETCorePlatformsPackageVersion>
<SystemCodeDomVersion>4.6.0-preview6.19279.8</SystemCodeDomVersion>
<SystemComponentModelAnnotationsVersion>4.6.0-preview6.19279.8</SystemComponentModelAnnotationsVersion>
<SystemConfigurationConfigurationManagerVersion>4.6.0-preview6.19279.8</SystemConfigurationConfigurationManagerVersion>
<SystemDataSqlClientVersion>4.7.0-preview6.19279.8</SystemDataSqlClientVersion>
</PropertyGroup>
<PropertyGroup Label="Dependencies from dotnet/core-setup">
<MicrosoftNETCoreAppPackageVersion>3.0.0-preview6-27730-01</MicrosoftNETCoreAppPackageVersion>
</PropertyGroup>
</Project>
7 changes: 6 additions & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"tools": {
"dotnet": "3.0.100-preview5-011568"
"dotnet": "3.0.100-preview5-011568",
"runtimes": {
"dotnet": [
"$(MicrosoftNETCoreAppPackageVersion)"
]
}
},
"sdk": {
"version": "3.0.100-preview5-011568"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
<ItemGroup>
<Compile Update="Properties\Resources.SqlServerCompact.cs">
<DependentUpon>Resources.SqlServerCompact.tt</DependentUpon>
<SubType>Code</SubType>
<AutoGen>True</AutoGen>
</Compile>
<Compile Update="SqlCeMultiCommand.cs">
Expand Down
71 changes: 29 additions & 42 deletions src/EntityFramework/Core/EntitySqlException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ namespace System.Data.Entity.Core
using System.Data.Entity.Core.Common.EntitySql;
using System.Data.Entity.Resources;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Runtime.Serialization;
using System.Text;
Expand All @@ -18,15 +17,13 @@ namespace System.Data.Entity.Core
/// not accurate or not present, type validation errors, scoping rule violations, user of undefined variables, etc.
/// For more information, see eSQL Language Spec.
/// </summary>
[SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors",
Justification = "SerializeObjectState used instead")]
[Serializable]
public sealed class EntitySqlException : EntityException
{
private const int HResultInvalidQuery = -2146232006;

[NonSerialized]
private EntitySqlExceptionState _state;
private readonly string _errorDescription;
private readonly string _errorContext;

/// <summary>
/// Initializes a new instance of <see cref="T:System.Data.Entity.Core.EntitySqlException" />.
Expand All @@ -44,8 +41,6 @@ public EntitySqlException(string message)
: base(message)
{
HResult = HResultInvalidQuery;

SubscribeToSerializeObjectState();
}

/// <summary>
Expand All @@ -57,8 +52,15 @@ public EntitySqlException(string message, Exception innerException)
: base(message, innerException)
{
HResult = HResultInvalidQuery;
}

SubscribeToSerializeObjectState();
private EntitySqlException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
_errorDescription = info.GetString("ErrorDescription");
_errorContext = info.GetString("ErrorContext");
Line = info.GetInt32("Line");
Column = info.GetInt32("Column");
}

// <summary>
Expand Down Expand Up @@ -99,43 +101,35 @@ private EntitySqlException(
string message, string errorDescription, string errorContext, int line, int column, Exception innerException)
: base(message, innerException)
{
_state.ErrorDescription = errorDescription;
_state.ErrorContext = errorContext;
_state.Line = line;
_state.Column = column;
_errorDescription = errorDescription;
_errorContext = errorContext;
Line = line;
Column = column;

HResult = HResultInvalidQuery;

SubscribeToSerializeObjectState();
}

/// <summary>Gets a description of the error.</summary>
/// <returns>A string that describes the error.</returns>
public string ErrorDescription
{
get { return _state.ErrorDescription ?? String.Empty; }
get { return _errorDescription ?? String.Empty; }
}

/// <summary>Gets the approximate context where the error occurred, if available.</summary>
/// <returns>A string that describes the approximate context where the error occurred, if available.</returns>
public string ErrorContext
{
get { return _state.ErrorContext ?? String.Empty; }
get { return _errorContext ?? String.Empty; }
}

/// <summary>Gets the approximate line number where the error occurred.</summary>
/// <returns>An integer that describes the line number where the error occurred.</returns>
public int Line
{
get { return _state.Line; }
}
public int Line { get; }

/// <summary>Gets the approximate column number where the error occurred.</summary>
/// <returns>An integer that describes the column number where the error occurred.</returns>
public int Column
{
get { return _state.Column; }
}
public int Column { get; }

internal static string GetGenericErrorMessage(string commandText, int position)
{
Expand Down Expand Up @@ -239,26 +233,19 @@ private static string FormatQueryError(string errorMessage, string errorContext)
return sb.Append(".").ToString();
}

private void SubscribeToSerializeObjectState()
{
SerializeObjectState += (_, a) => a.AddSerializedState(_state);
}

[Serializable]
private struct EntitySqlExceptionState : ISafeSerializationData
/// <summary>
/// Sets the <see cref="SerializationInfo" /> with information about the exception.
/// </summary>
/// <param name="info"> The <see cref="SerializationInfo" /> that holds the serialized object data about the exception being thrown. </param>
/// <param name="context"> The <see cref="StreamingContext" /> that contains contextual information about the source or destination. </param>
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
public string ErrorDescription { get; set; }
public string ErrorContext { get; set; }
public int Line { get; set; }
public int Column { get; set; }
base.GetObjectData(info, context);

public void CompleteDeserialization(object deserialized)
{
var entitySqlException = (EntitySqlException)deserialized;

entitySqlException._state = this;
entitySqlException.SubscribeToSerializeObjectState();
}
info.AddValue("ErrorDescription", _errorDescription);
info.AddValue("ErrorContext", _errorContext);
info.AddValue("Line", Line);
info.AddValue("Column", Column);
}
}
}
49 changes: 16 additions & 33 deletions src/EntityFramework/Core/PropertyConstraintException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,20 @@
namespace System.Data.Entity.Core
{
using System.Data.Entity.Utilities;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.Serialization;

/// <summary>
/// Property constraint exception class. Note that this class has state - so if you change even
/// its internals, it can be a breaking change
/// </summary>
[SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors",
Justification = "SerializeObjectState used instead")]
[Serializable]
public sealed class PropertyConstraintException : ConstraintException
{
[NonSerialized]
private PropertyConstraintExceptionState _state;

/// <summary>
/// Initializes a new instance of the <see cref="T:System.Data.Entity.Core.PropertyConstraintException" /> class with default message.
/// </summary>
public PropertyConstraintException() // required ctor
{
SubscribeToSerializeObjectState();
}

/// <summary>
Expand All @@ -33,7 +26,6 @@ public PropertyConstraintException() // required ctor
public PropertyConstraintException(string message) // required ctor
: base(message)
{
SubscribeToSerializeObjectState();
}

/// <summary>
Expand All @@ -44,7 +36,6 @@ public PropertyConstraintException(string message) // required ctor
public PropertyConstraintException(string message, Exception innerException) // required ctor
: base(message, innerException)
{
SubscribeToSerializeObjectState();
}

/// <summary>
Expand All @@ -56,9 +47,7 @@ public PropertyConstraintException(string message, string propertyName) // requi
: base(message)
{
Check.NotEmpty(propertyName, "propertyName");
_state.PropertyName = propertyName;

SubscribeToSerializeObjectState();
PropertyName = propertyName;
}

/// <summary>
Expand All @@ -71,35 +60,29 @@ public PropertyConstraintException(string message, string propertyName, Exceptio
: base(message, innerException)
{
Check.NotEmpty(propertyName, "propertyName");
_state.PropertyName = propertyName;

SubscribeToSerializeObjectState();
PropertyName = propertyName;
}

/// <summary>Gets the name of the property that violated the constraint.</summary>
/// <returns>The name of the property that violated the constraint.</returns>
public string PropertyName
private PropertyConstraintException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
get { return _state.PropertyName; }
PropertyName = info.GetString("PropertyName");
}

private void SubscribeToSerializeObjectState()
{
SerializeObjectState += (_, a) => a.AddSerializedState(_state);
}
/// <summary>Gets the name of the property that violated the constraint.</summary>
/// <returns>The name of the property that violated the constraint.</returns>
public string PropertyName { get; }

[Serializable]
private struct PropertyConstraintExceptionState : ISafeSerializationData
/// <summary>
/// Sets the <see cref="SerializationInfo" /> with information about the exception.
/// </summary>
/// <param name="info"> The <see cref="SerializationInfo" /> that holds the serialized object data about the exception being thrown. </param>
/// <param name="context"> The <see cref="StreamingContext" /> that contains contextual information about the source or destination. </param>
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
public string PropertyName { get; set; }
base.GetObjectData(info, context);

public void CompleteDeserialization(object deserialized)
{
var propertyConstraintException = (PropertyConstraintException)deserialized;

propertyConstraintException._state = this;
propertyConstraintException.SubscribeToSerializeObjectState();
}
info.AddValue("PropertyName", PropertyName);
}
}
}
Loading

0 comments on commit daec698

Please sign in to comment.