You've already forked linux-packaging-mono
Imported Upstream version 4.6.0.125
Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
parent
a569aebcfd
commit
e79aa3c0ed
@@ -0,0 +1,41 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="ExceptionHelpers.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
using System.Text;
|
||||
using System.Data.Mapping.ViewGeneration.Structures;
|
||||
using System.Diagnostics;
|
||||
using System.Data.Common.Utils;
|
||||
|
||||
namespace System.Data.Mapping.ViewGeneration.Utils
|
||||
{
|
||||
|
||||
// Miscellaneous helper routines for generating mapping exceptions
|
||||
internal static class ExceptionHelpers
|
||||
{
|
||||
internal static void ThrowMappingException(ErrorLog.Record errorRecord, ConfigViewGenerator config)
|
||||
{
|
||||
InternalMappingException exception = new InternalMappingException(errorRecord.ToUserString(), errorRecord);
|
||||
if (config.IsNormalTracing)
|
||||
{
|
||||
exception.ErrorLog.PrintTrace();
|
||||
}
|
||||
throw exception;
|
||||
}
|
||||
|
||||
internal static void ThrowMappingException(ErrorLog errorLog, ConfigViewGenerator config)
|
||||
{
|
||||
InternalMappingException exception = new InternalMappingException(errorLog.ToUserString(), errorLog);
|
||||
if (config.IsNormalTracing)
|
||||
{
|
||||
exception.ErrorLog.PrintTrace();
|
||||
}
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="ExternalCalls.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
|
||||
using System.Data.Mapping.ViewGeneration.Structures;
|
||||
using System.Data.Common;
|
||||
using System.Data.Common.CommandTrees;
|
||||
using System.Data.Common.CommandTrees.ExpressionBuilder;
|
||||
using System.Data.Common.EntitySql;
|
||||
using System.Data.Common.Utils;
|
||||
using System.Data.Metadata.Edm;
|
||||
using System.Diagnostics;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace System.Data.Mapping.ViewGeneration.Utils
|
||||
{
|
||||
/// <summary>
|
||||
/// This class encapsulates "external" calls from view/MDF generation to other System.Data.Entity features.
|
||||
/// </summary>
|
||||
internal static class ExternalCalls
|
||||
{
|
||||
static internal bool IsReservedKeyword(string name)
|
||||
{
|
||||
return CqlLexer.IsReservedKeyword(name);
|
||||
}
|
||||
|
||||
static internal DbCommandTree CompileView(
|
||||
string viewDef,
|
||||
StorageMappingItemCollection mappingItemCollection,
|
||||
ParserOptions.CompilationMode compilationMode)
|
||||
{
|
||||
Debug.Assert(!String.IsNullOrEmpty(viewDef), "!String.IsNullOrEmpty(viewDef)");
|
||||
Debug.Assert(mappingItemCollection != null, "mappingItemCollection != null");
|
||||
|
||||
Perspective perspective = new TargetPerspective(mappingItemCollection.Workspace);
|
||||
ParserOptions parserOptions = new ParserOptions();
|
||||
parserOptions.ParserCompilationMode = compilationMode;
|
||||
DbCommandTree expr = CqlQuery.Compile(viewDef, perspective, parserOptions, null).CommandTree;
|
||||
Debug.Assert(expr != null, "Compile returned empty tree?");
|
||||
|
||||
return expr;
|
||||
}
|
||||
|
||||
static internal DbExpression CompileFunctionView(
|
||||
string viewDef,
|
||||
StorageMappingItemCollection mappingItemCollection,
|
||||
ParserOptions.CompilationMode compilationMode,
|
||||
IEnumerable<DbParameterReferenceExpression> parameters)
|
||||
{
|
||||
Debug.Assert(!String.IsNullOrEmpty(viewDef), "!String.IsNullOrEmpty(viewDef)");
|
||||
Debug.Assert(mappingItemCollection != null, "mappingItemCollection != null");
|
||||
|
||||
Perspective perspective = new TargetPerspective(mappingItemCollection.Workspace);
|
||||
ParserOptions parserOptions = new ParserOptions();
|
||||
parserOptions.ParserCompilationMode = compilationMode;
|
||||
|
||||
// Parameters have to be accessible in the body as regular scope variables, not as command parameters.
|
||||
// Hence compile view as lambda with parameters as lambda vars, then invoke the lambda specifying
|
||||
// command parameters as values of the lambda vars.
|
||||
DbLambda functionBody = CqlQuery.CompileQueryCommandLambda(
|
||||
viewDef,
|
||||
perspective,
|
||||
parserOptions,
|
||||
null /* parameters */,
|
||||
parameters.Select(pInfo => pInfo.ResultType.Variable(pInfo.ParameterName)));
|
||||
Debug.Assert(functionBody != null, "functionBody != null");
|
||||
DbExpression expr = functionBody.Invoke(parameters);
|
||||
|
||||
return expr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compiles eSQL <paramref name="functionDefinition"/> and returns <see cref="DbLambda"/>.
|
||||
/// Guarantees type match of lambda variables and <paramref name="functionParameters"/>.
|
||||
/// Passes thru all excepions coming from <see cref="CqlQuery"/>.
|
||||
/// </summary>
|
||||
static internal DbLambda CompileFunctionDefinition(
|
||||
string functionFullName,
|
||||
string functionDefinition,
|
||||
IList<FunctionParameter> functionParameters,
|
||||
EdmItemCollection edmItemCollection)
|
||||
{
|
||||
Debug.Assert(!String.IsNullOrEmpty(functionFullName), "!String.IsNullOrEmpty(functionFullName)");
|
||||
Debug.Assert(!String.IsNullOrEmpty(functionDefinition), "!String.IsNullOrEmpty(functionDefinition)");
|
||||
Debug.Assert(functionParameters != null, "functionParameters != null");
|
||||
Debug.Assert(edmItemCollection != null, "edmItemCollection != null");
|
||||
|
||||
MetadataWorkspace workspace = new MetadataWorkspace();
|
||||
workspace.RegisterItemCollection(edmItemCollection);
|
||||
Perspective perspective = new ModelPerspective(workspace);
|
||||
|
||||
// Since we compile lambda expression and generate variables from the function parameter definitions,
|
||||
// the returned DbLambda will contain variable types that match function parameter types.
|
||||
DbLambda functionBody = CqlQuery.CompileQueryCommandLambda(
|
||||
functionDefinition,
|
||||
perspective,
|
||||
null /* use default parser options */,
|
||||
null /* parameters */,
|
||||
functionParameters.Select(pInfo => pInfo.TypeUsage.Variable(pInfo.Name)));
|
||||
Debug.Assert(functionBody != null, "functionBody != null");
|
||||
|
||||
return functionBody;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="ViewGenErrorCode.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner srimand
|
||||
// @backupOwner cmeek
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace System.Data.Mapping.ViewGeneration.Utils
|
||||
{
|
||||
|
||||
// This file contains an enum for the errors generated by ViewGen
|
||||
|
||||
// There is almost a one-to-one correspondence between these error codes
|
||||
// and the resource strings - so if you need more insight into what the
|
||||
// error code means, please see the code that uses the particular enum
|
||||
// AND the corresponding resource string
|
||||
|
||||
// error numbers end up being hard coded in test cases; they can be removed, but should not be changed.
|
||||
// reusing error numbers is probably OK, but not recommended.
|
||||
//
|
||||
// The acceptable range for this enum is
|
||||
// 3000 - 3999
|
||||
//
|
||||
// The Range 10,000-15,000 is reserved for tools
|
||||
//
|
||||
internal enum ViewGenErrorCode
|
||||
{
|
||||
|
||||
Value = 3000, // ViewGenErrorBase
|
||||
|
||||
// Filter condition on cell is invalid
|
||||
InvalidCondition = Value + 1,
|
||||
// Key constraint violation: C does not imply S
|
||||
KeyConstraintViolation = Value + 2,
|
||||
// Key constraint violation due to update's requirements: S does not
|
||||
// imply C approximately
|
||||
KeyConstraintUpdateViolation = Value + 3,
|
||||
// Some attributes of an extent are not present in the cells
|
||||
AttributesUnrecoverable = Value + 4,
|
||||
// The partitions (from multiconstants) cannot be differentiated
|
||||
AmbiguousMultiConstants = Value + 5,
|
||||
//Unused: 6
|
||||
// Non-key projected multiple times (denormalzed)
|
||||
NonKeyProjectedWithOverlappingPartitions = Value + 7,
|
||||
// New concurrency tokens defined in derived class
|
||||
ConcurrencyDerivedClass = Value + 8,
|
||||
// Concurrency token has a condition on it
|
||||
ConcurrencyTokenHasCondition = Value + 9,
|
||||
//Unused: 10
|
||||
// Domain constraint violated
|
||||
DomainConstraintViolation = Value + 12,
|
||||
// Foreign key constraint - child or parent table is not mapped
|
||||
ForeignKeyMissingTableMapping = Value + 13,
|
||||
// Foreign key constraint - C-space does not ensure that child is
|
||||
// contained in parent
|
||||
ForeignKeyNotGuaranteedInCSpace = Value + 14,
|
||||
// Expected foreign key to be mapped to some relationship
|
||||
ForeignKeyMissingRelationshipMapping = Value + 15,
|
||||
// Foreign key mapped to relationship - expected upper bound to be 1
|
||||
ForeignKeyUpperBoundMustBeOne = Value + 16,
|
||||
// Foreign key mapped to relationship - expected low bound to be 1
|
||||
ForeignKeyLowerBoundMustBeOne = Value + 17,
|
||||
// Foreign key mapped to relationship - but parent table not mapped
|
||||
// to any end of relationship
|
||||
ForeignKeyParentTableNotMappedToEnd = Value + 18,
|
||||
// Foreign key mapping to C-space does not preserve colum order
|
||||
ForeignKeyColumnOrderIncorrect = Value + 19,
|
||||
// Disjointness constraint violated in C-space
|
||||
DisjointConstraintViolation = Value + 20,
|
||||
// Columns of a table mapped to multiple C-side properties
|
||||
DuplicateCPropertiesMapped = Value + 21,
|
||||
// Field has not null condition but is not mapped
|
||||
NotNullNoProjectedSlot = Value + 22,
|
||||
// Column is not nullable and has no default value
|
||||
NoDefaultValue = Value + 23,
|
||||
// All key properties of association set or entity set not mapped
|
||||
KeyNotMappedForCSideExtent = Value + 24,
|
||||
// All key properties of table not mapped
|
||||
KeyNotMappedForTable = Value + 25,
|
||||
// Partition constraint violated in C-space
|
||||
PartitionConstraintViolation = Value + 26,
|
||||
// Mapping for C-side extent not specified
|
||||
MissingExtentMapping = Value + 27,
|
||||
//Unused: 28
|
||||
//Unused: 29
|
||||
// Mapping condition that is not possible according to S-side constraints
|
||||
ImpopssibleCondition = Value + 30,
|
||||
// NonNullable S-Side member is mapped to nullable C-Side member
|
||||
NullableMappingForNonNullableColumn = Value + 31,
|
||||
//Error specifiying Conditions, caught during Error Pattern Matching
|
||||
ErrorPatternConditionError = Value + 32,
|
||||
//Invalid ways of splitting Extents, caught during Error Pattern Matching
|
||||
ErrorPatternSplittingError = Value + 33,
|
||||
//Invalid mapping in terms of equality/disjointness constraint, caught during Error Pattern Matching
|
||||
ErrorPatternInvalidPartitionError = Value + 34,
|
||||
//Some type does not have mapping specified
|
||||
ErrorPatternMissingMappingError = Value + 35,
|
||||
//Mapping fragments don't overlap on a key or foreign key under read-only scenario
|
||||
NoJoinKeyOrFKProvidedInMapping = Value + 36,
|
||||
//If there is a fragment with distinct flag, there should be no othe fragment between that C and S extent
|
||||
MultipleFragmentsBetweenCandSExtentWithDistinct = Value + 37,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user