12345678910111213141516171819202122232425262728293031323334353637383940 |
- using System;
- namespace TBL.CSharp.Base
- {
- public static partial class Extension
- {
- #if DEBUG
-
- /// <summary>
- /// 获取调用时的源代码行数
- /// </summary>
- public static int SourceLineNumber([System.Runtime.CompilerServices.CallerLineNumber] int lineNumber = 0)
- {
- return lineNumber;
- }
- /// <summary>
- /// 获取调用时的文件路径
- /// </summary>
- public static string SourceFilePath([System.Runtime.CompilerServices.CallerFilePath] string fileName = "")
- {
- return fileName;
- }
- /// <summary>
- /// 源文件名变为生成源码文件名
- /// </summary>
- public static string SourceFileGeneratePath(string path)
- {
- var pi = path.LastIndexOf(".cs", StringComparison.Ordinal);
- if (pi >= 0)
- {
- return $"{path.Substring(0, pi)}.Generated.cs";
- }
- return $"{path}.Generated";
- }
- #endif
- }
- }
|