public bool CanDeleteType(DataTypeDescriptor dataTypeDescriptor, out string errorMessage) { CompatibilityCheckResult compatibilityCheckResult = CodeCompatibilityChecker.CheckIfAppCodeDependsOnInterface(dataTypeDescriptor); if (!compatibilityCheckResult.Successful) { errorMessage = "Cannot delete the type since it will cause a build error for App_Code files. " + compatibilityCheckResult.ErrorMessage; return(false); } errorMessage = string.Empty; return(true); }
/// <exclude /> public bool ValidateByCompile(out string errorMessage) { var dataTypeDescriptor = _oldDataTypeDescriptor == null?CreateNewDataTypeDescriptor() : CreateUpdatedDataTypeDescriptor(); string classFullName = (dataTypeDescriptor.Namespace + "." + dataTypeDescriptor.Name).Replace(" ", string.Empty); string classFullNameWithDot = classFullName + "."; foreach (var reservedNamespace in ReservedNamespaces) { if (classFullNameWithDot.StartsWith(reservedNamespace + ".", StringComparison.InvariantCultureIgnoreCase)) { errorMessage = Texts.NamespaceIsReserved; return(false); } } foreach (string namePart in classFullName.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries)) { if (!IsCSharpValidIdentifier(namePart)) { errorMessage = Texts.TypeNameIsInvalidIdentifier(classFullName); return(false); } } foreach (DataFieldDescriptor dataField in dataTypeDescriptor.Fields) { if (!IsCSharpValidIdentifier(dataField.Name)) { errorMessage = Texts.FieldNameCannotBeUsed(dataField.Name); return(false); } } // Checking for name collisions with Composite.dll if (classFullName.StartsWith(CompositeNamespace + ".", StringComparison.InvariantCultureIgnoreCase)) { foreach (var type in typeof(IData).Assembly.GetTypes()) { string typeNameWithDot = type.FullName + "."; if (classFullNameWithDot.StartsWith(typeNameWithDot, StringComparison.InvariantCultureIgnoreCase) || typeNameWithDot.StartsWith(classFullNameWithDot, StringComparison.InvariantCultureIgnoreCase)) { errorMessage = Texts.CompileErrorWhileAddingType; return(false); } } } CompatibilityCheckResult compatibilityCheckResult = CodeCompatibilityChecker.CheckCompatibilityWithAppCodeFolder(dataTypeDescriptor); if (!compatibilityCheckResult.Successful) { errorMessage = _oldDataTypeDescriptor == null ? Texts.CompileErrorWhileAddingType : Texts.CompileErrorWhileChangingType; errorMessage += compatibilityCheckResult.ErrorMessage; return(false); } errorMessage = string.Empty; return(true); }