/// <remarks> /// Full backup action sequence, from https://technet.microsoft.com/en-us/magazine/2009.07.sqlbackup.aspx : /// 1. Force a database checkpoint and make a note of the log sequence number at this point. This flushes all updated-in-memory pages to disk /// before anything is read by the backup to help minimize the amount of work the recovery part of restore has to do. /// 2. Start reading from the data files in the database. /// 3. Stop reading from the data files and make a note of the log sequence number of the start of the oldest active transaction at that point /// (see my article "Understanding Logging and Recovery in SQL Server" for an explanation of these terms). /// 4. Read as much transaction log as is necessary. /// ... /// Backing up enough of the transaction log is required so that recovery can successfully run during the restore and so that all pages in /// the database are at the same point in timeāthe time at which the data reading portion of the backup operation completed (Point 7). /// </remarks> public List <BackupItem> GetBackupItems(FileInfo file) { var fileInfo = FileNamingConvention.GetBackupFileInfo(file); List <BackupItem> result; if (fileInfo.IsLog) { // first backup in a day is diff or full result = new List <BackupItem>(LogBackupsPerDay); for (var pos = 1; pos <= LogBackupsPerDay; ++pos) { var backupTime = fileInfo.StartTime.Date.Add(FirstBackupTime).AddMinutes(pos * BackupIntervalMinutes); var item = new BackupItem() { BackupEndTime = backupTime.AddSeconds(LogBackupDurationSeconds), BackupStartTime = backupTime, BackupType = BackupType.Log, DatabaseName = DatabaseName, DatabaseBackupLsn = GetDatabaseBackupLsn(backupTime), Position = pos, FirstLsn = GetLogBackupFirstLsn(backupTime), LastLsn = GetLogBackupLastLsn(backupTime), RecoveryModel = Microsoft.SqlServer.Management.Smo.RecoveryModel.Full, FileInfo = file }; item.CheckpointLsn = item.FirstLsn; result.Add(item); } } else { var backupTime = fileInfo.StartTime.Date.Add(FirstBackupTime); var backupEndTime = backupTime.AddSeconds(fileInfo.IsFull ? FullBackupDurationSeconds : DiffBackupDurationSeconds); var item = new BackupItem() { BackupEndTime = backupEndTime, BackupStartTime = backupTime, BackupType = fileInfo.IsFull ? BackupType.Full : BackupType.DifferentialDatabase, DatabaseName = DatabaseName, DatabaseBackupLsn = GetDatabaseBackupLsn(backupTime), Position = 1, FirstLsn = GetLastLsn(backupTime), LastLsn = GetLastLsn(backupEndTime), RecoveryModel = Microsoft.SqlServer.Management.Smo.RecoveryModel.Full, FileInfo = file }; item.CheckpointLsn = item.FirstLsn; result = new List <BackupItem>(1); result.Add(item); } return(result); }
internal static string GetConventionalFileName(TypeDeclarationSyntax typeDeclaration, FileNamingConvention convention) { if (typeDeclaration.TypeParameterList == null) { return GetSimpleFileName(typeDeclaration); } switch (convention) { case FileNamingConvention.Metadata: return GetMetadataFileName(typeDeclaration); default: return GetStyleCopFileName(typeDeclaration); } }
protected internal DocumentationSettings() { this.companyName = DefaultCompanyName; this.copyrightText = DefaultCopyrightText; this.variables = ImmutableDictionary <string, string> .Empty.ToBuilder(); this.xmlHeader = true; this.documentExposedElements = true; this.documentInternalElements = true; this.documentPrivateElements = false; this.documentInterfaces = true; this.documentPrivateFields = false; this.fileNamingConvention = FileNamingConvention.StyleCop; }
/// <summary> /// Initializes a new instance of the <see cref="DocumentationSettings"/> class during JSON deserialization. /// </summary> protected internal DocumentationSettings() { this.companyName = DefaultCompanyName; this.copyrightText = DefaultCopyrightText; this.headerDecoration = null; this.variables = ImmutableDictionary <string, string> .Empty; this.xmlHeader = true; this.documentExposedElements = true; this.documentInternalElements = true; this.documentPrivateElements = false; this.documentInterfaces = true; this.documentPrivateFields = false; this.fileNamingConvention = FileNamingConvention.StyleCop; this.documentationCulture = DefaultDocumentationCulture; this.excludeFromPunctuationCheck = DefaultExcludeFromPunctuationCheck; }
/// <summary> /// Initializes a new instance of the <see cref="DocumentationSettings"/> class. /// </summary> /// <param name="documentationSettingsObject">The JSON object containing the settings.</param> protected internal DocumentationSettings(JsonObject documentationSettingsObject) : this() { foreach (var kvp in documentationSettingsObject) { switch (kvp.Key) { case "documentExposedElements": this.documentExposedElements = kvp.ToBooleanValue(); break; case "documentInternalElements": this.documentInternalElements = kvp.ToBooleanValue(); break; case "documentPrivateElements": this.documentPrivateElements = kvp.ToBooleanValue(); break; case "documentInterfaces": this.documentInterfaces = kvp.ToBooleanValue(); break; case "documentPrivateFields": this.documentPrivateFields = kvp.ToBooleanValue(); break; case "companyName": this.companyName = kvp.ToStringValue(); break; case "copyrightText": this.copyrightText = kvp.ToStringValue(); break; case "headerDecoration": this.headerDecoration = kvp.ToStringValue(); break; case "variables": kvp.AssertIsObject(); foreach (var child in kvp.Value.AsJsonObject) { string name = child.Key; if (!Regex.IsMatch(name, "^[a-zA-Z0-9]+$")) { continue; } string value = child.ToStringValue(); this.variables.Add(name, value); } break; case "xmlHeader": this.xmlHeader = kvp.ToBooleanValue(); break; case "fileNamingConvention": this.fileNamingConvention = kvp.ToEnumValue <FileNamingConvention>(); break; case "documentationCulture": this.documentationCulture = kvp.ToStringValue(); break; default: break; } } }
protected internal DocumentationSettings() { this.companyName = DefaultCompanyName; this.copyrightText = DefaultCopyrightText; this.headerDecoration = null; this.variables = ImmutableDictionary<string, string>.Empty.ToBuilder(); this.xmlHeader = true; this.documentExposedElements = true; this.documentInternalElements = true; this.documentPrivateElements = false; this.documentInterfaces = true; this.documentPrivateFields = false; this.fileNamingConvention = FileNamingConvention.StyleCop; }
protected internal DocumentationSettings(JsonObject documentationSettingsObject, AnalyzerConfigOptionsWrapper analyzerConfigOptions) { bool? documentExposedElements = null; bool? documentInternalElements = null; bool? documentPrivateElements = null; bool? documentInterfaces = null; bool? documentPrivateFields = null; string companyName = null; string copyrightText = null; string headerDecoration = null; ImmutableDictionary <string, string> .Builder variables = null; bool?xmlHeader = null; FileNamingConvention?fileNamingConvention = null; string documentationCulture = null; ImmutableArray <string> .Builder excludeFromPunctuationCheck = null; foreach (var kvp in documentationSettingsObject) { switch (kvp.Key) { case "documentExposedElements": documentExposedElements = kvp.ToBooleanValue(); break; case "documentInternalElements": documentInternalElements = kvp.ToBooleanValue(); break; case "documentPrivateElements": documentPrivateElements = kvp.ToBooleanValue(); break; case "documentInterfaces": documentInterfaces = kvp.ToBooleanValue(); break; case "documentPrivateFields": documentPrivateFields = kvp.ToBooleanValue(); break; case "companyName": companyName = kvp.ToStringValue(); break; case "copyrightText": copyrightText = kvp.ToStringValue(); break; case "headerDecoration": headerDecoration = kvp.ToStringValue(); break; case "variables": kvp.AssertIsObject(); variables = ImmutableDictionary.CreateBuilder <string, string>(); foreach (var child in kvp.Value.AsJsonObject) { string name = child.Key; if (!Regex.IsMatch(name, "^[a-zA-Z0-9]+$")) { continue; } string value = child.ToStringValue(); variables.Add(name, value); } break; case "xmlHeader": xmlHeader = kvp.ToBooleanValue(); break; case "fileNamingConvention": fileNamingConvention = kvp.ToEnumValue <FileNamingConvention>(); break; case "documentationCulture": documentationCulture = kvp.ToStringValue(); break; case "excludeFromPunctuationCheck": kvp.AssertIsArray(); excludeFromPunctuationCheck = ImmutableArray.CreateBuilder <string>(); foreach (var value in kvp.Value.AsJsonArray) { excludeFromPunctuationCheck.Add(value.AsString); } break; default: break; } } documentExposedElements ??= AnalyzerConfigHelper.TryGetBooleanValue(analyzerConfigOptions, "stylecop.documentation.documentExposedElements"); documentInternalElements ??= AnalyzerConfigHelper.TryGetBooleanValue(analyzerConfigOptions, "stylecop.documentation.documentInternalElements"); documentPrivateElements ??= AnalyzerConfigHelper.TryGetBooleanValue(analyzerConfigOptions, "stylecop.documentation.documentPrivateElements"); documentInterfaces ??= AnalyzerConfigHelper.TryGetBooleanValue(analyzerConfigOptions, "stylecop.documentation.documentInterfaces"); documentPrivateFields ??= AnalyzerConfigHelper.TryGetBooleanValue(analyzerConfigOptions, "stylecop.documentation.documentPrivateFields"); companyName ??= AnalyzerConfigHelper.TryGetStringValue(analyzerConfigOptions, "stylecop.documentation.companyName"); copyrightText ??= AnalyzerConfigHelper.TryGetStringValue(analyzerConfigOptions, "stylecop.documentation.copyrightText") ?? AnalyzerConfigHelper.TryGetStringValue(analyzerConfigOptions, "file_header_template"); headerDecoration ??= AnalyzerConfigHelper.TryGetStringValue(analyzerConfigOptions, "stylecop.documentation.headerDecoration"); xmlHeader ??= AnalyzerConfigHelper.TryGetBooleanValue(analyzerConfigOptions, "stylecop.documentation.xmlHeader"); fileNamingConvention ??= AnalyzerConfigHelper.TryGetStringValue(analyzerConfigOptions, "stylecop.documentation.fileNamingConvention") switch { "stylecop" => FileNamingConvention.StyleCop, "metadata" => FileNamingConvention.Metadata, _ => null, }; documentationCulture ??= AnalyzerConfigHelper.TryGetStringValue(analyzerConfigOptions, "stylecop.documentation.documentationCulture"); excludeFromPunctuationCheck ??= AnalyzerConfigHelper.TryGetStringListValue(analyzerConfigOptions, "stylecop.documentation.excludeFromPunctuationCheck")?.ToBuilder(); this.documentExposedElements = documentExposedElements.GetValueOrDefault(true); this.documentInternalElements = documentInternalElements.GetValueOrDefault(true); this.documentPrivateElements = documentPrivateElements.GetValueOrDefault(false); this.documentInterfaces = documentInterfaces.GetValueOrDefault(true); this.documentPrivateFields = documentPrivateFields.GetValueOrDefault(false); this.companyName = companyName ?? DefaultCompanyName; this.copyrightText = copyrightText ?? DefaultCopyrightText; this.headerDecoration = headerDecoration; this.variables = variables?.ToImmutable() ?? ImmutableDictionary <string, string> .Empty; this.xmlHeader = xmlHeader.GetValueOrDefault(true); this.fileNamingConvention = fileNamingConvention.GetValueOrDefault(FileNamingConvention.StyleCop); this.documentationCulture = documentationCulture ?? DefaultDocumentationCulture; this.documentationCultureInfo = this.documentationCulture == DefaultDocumentationCulture ? CultureInfo.InvariantCulture : new CultureInfo(this.documentationCulture); this.excludeFromPunctuationCheck = excludeFromPunctuationCheck?.ToImmutable() ?? DefaultExcludeFromPunctuationCheck; }
public Analyzer(AnalyzerOptions options, CancellationToken cancellationToken) { StyleCopSettings settings = options.GetStyleCopSettings(cancellationToken); this.fileNamingConvention = settings.DocumentationRules.FileNamingConvention; }
internal static string GetConventionalFileName(MemberDeclarationSyntax declaration, FileNamingConvention convention) { if (declaration is TypeDeclarationSyntax typeDeclaration) { if (typeDeclaration.TypeParameterList == null) { return(GetSimpleFileName(typeDeclaration)); } switch (convention) { case FileNamingConvention.Metadata: return(GetMetadataFileName(typeDeclaration)); default: return(GetStyleCopFileName(typeDeclaration)); } } else if (declaration is DelegateDeclarationSyntax delegateDeclaration) { if (delegateDeclaration.TypeParameterList == null) { return(GetSimpleFileName(delegateDeclaration)); } switch (convention) { case FileNamingConvention.Metadata: return(GetMetadataFileName(delegateDeclaration)); default: return(GetStyleCopFileName(delegateDeclaration)); } } return(GetSimpleFileName(declaration)); }
public Analyzer(AnalyzerOptions options) { StyleCopSettings settings = options.GetStyleCopSettings(); this.fileNamingConvention = settings.DocumentationRules.FileNamingConvention; }