/
githubmirror
/
Files
Обзор
Документация
Войти
/
githubmirror
/
Files
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Files.Core.SourceGenerator/Extensions/StringBuilderExtensions.cs
50 строк
2 KB
Lamparter
GitHub: Updated license headers (#16714)
21 янв 2025, 04:19
Не верифицирован
21 янв 2025, 04:19
7c23ac0
Код
Авторство
О чём код?
// Copyright (c) Files Community // Licensed under the MIT License. namespace Files.Core.SourceGenerator.Extensions { /// <summary> /// Provides extension methods for the <see cref="StringBuilder"/> class. /// </summary> internal static class StringBuilderExtensions { /// <summary> /// Appends an auto-generated header to the <see cref="StringBuilder"/> instance. /// </summary> /// <param name="sb">The <see cref="StringBuilder"/> instance to append to.</param> /// <param name="fromData">Optional data to include in the header. If null or empty, only the closing tag is appended.</param> /// <returns>The <see cref="StringBuilder"/> instance with the appended header.</returns> internal static StringBuilder AppendAutoGeneratedHeader(this StringBuilder sb, string? fromData = null) { return string.IsNullOrEmpty(fromData) ? sb.AppendLine("/// <auto-generated/>") : sb.AppendLine("/// <auto-generated>") .AppendLine($"/// From: {fromData}") .AppendLine("/// </auto-generated>"); } /// <summary> /// Appends a license header to the <see cref="StringBuilder"/> instance. /// </summary> /// <param name="sb">The <see cref="StringBuilder"/> instance to append to.</param> /// <returns>The <see cref="StringBuilder"/> instance with the appended license header.</returns> internal static StringBuilder AppendLicenceHeader(this StringBuilder sb) { return sb.AppendLine($"// Copyright (c) Files Community") .AppendLine("// Licensed under the MIT License."); } /// <summary> /// Appends a full header, including auto-generated and license information, to the <see cref="StringBuilder"/> instance. /// </summary> /// <param name="sb">The <see cref="StringBuilder"/> instance to append to.</param> /// <param name="fromData">Optional data to include in the auto-generated header. If null or empty, only the closing tag is appended.</param> /// <returns>The <see cref="StringBuilder"/> instance with the appended full header.</returns> internal static StringBuilder AppendFullHeader(this StringBuilder sb, string? fromData = null) { return sb.AppendAutoGeneratedHeader(fromData) .AppendLine() .AppendLicenceHeader(); } } }