Repository navigation
Expand file tree
/
Copy pathFileDiffResultLists.Metadata.cs
More file actions
171 lines (151 loc) · 10.4 KB
/
Copy pathFileDiffResultLists.Metadata.cs
File metadata and controls
171 lines (151 loc) · 10.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading;
namespace FolderDiffIL4DotNet.Models
{
/// <summary>
/// Partial class for analysis metadata: semantic changes, dependency changes, warnings, and disassembler info.
/// 分析メタデータの partial クラス: セマンティック変更、依存関係変更、警告、逆アセンブラ情報。
/// </summary>
public sealed partial class FileDiffResultLists
{
// ──────────────────────────────────────────────
// Disassembler metadata
// 逆アセンブラメタデータ
// ──────────────────────────────────────────────
/// <summary>
/// Disassembler names and versions used during actual tool execution.
/// 実行中に使用された逆アセンブラの名称とバージョン(実ツール実行)。
/// </summary>
public ConcurrentDictionary<string, byte> DisassemblerToolVersions { get; } = new ConcurrentDictionary<string, byte>(StringComparer.OrdinalIgnoreCase);
/// <summary>
/// Disassembler names and versions retrieved via cache.
/// キャッシュ経由で利用された逆アセンブラの名称とバージョン。
/// </summary>
public ConcurrentDictionary<string, byte> DisassemblerToolVersionsFromCache { get; } = new ConcurrentDictionary<string, byte>(StringComparer.OrdinalIgnoreCase);
/// <summary>
/// Disassembler availability results probed at startup (null until probed).
/// 起動時にプローブされた逆アセンブラ利用可否の結果(プローブ前は null)。
/// </summary>
private IReadOnlyList<DisassemblerProbeResult>? _disassemblerAvailability;
/// <summary>
/// Gets or sets the disassembler availability probe results.
/// Thread-safe via <see cref="Volatile"/>.
/// 逆アセンブラ利用可否プローブ結果を取得・設定します。
/// <see cref="Volatile"/> によりスレッドセーフです。
/// </summary>
public IReadOnlyList<DisassemblerProbeResult>? DisassemblerAvailability
{
get => Volatile.Read(ref _disassemblerAvailability);
set => Volatile.Write(ref _disassemblerAvailability, value);
}
/// <summary>
/// Records the disassembler tool name and version used.
/// 使用した逆アセンブラ名とバージョンを記録します。
/// </summary>
public void RecordDisassemblerToolVersion(string toolName, string? version, bool fromCache = false)
{
if (string.IsNullOrWhiteSpace(toolName))
{
return;
}
var label = string.IsNullOrWhiteSpace(version) ? toolName : $"{toolName} (version: {version})";
var target = fromCache ? DisassemblerToolVersionsFromCache : DisassemblerToolVersions;
target[label] = 0;
}
// ──────────────────────────────────────────────
// Timestamp warnings
// タイムスタンプ警告
// ──────────────────────────────────────────────
/// <summary>
/// Warnings for Modified files where the new file's timestamp is older than the old file's.
/// Modified と判定されたファイルのうち、new 側の更新日時が old 側より古いものの警告一覧。
/// </summary>
public ConcurrentDictionary<string, FileTimestampRegressionWarning> NewFileTimestampOlderThanOldWarnings { get; } = new ConcurrentDictionary<string, FileTimestampRegressionWarning>(s_relativePathKeyComparer);
/// <summary>
/// Returns <see langword="true"/> when at least one modified file has a newer-side timestamp older than the older-side.
/// Modified ファイルのうち新側タイムスタンプが旧側より古いものが 1 件以上ある場合に <see langword="true"/> を返します。
/// </summary>
public bool HasAnyNewFileTimestampOlderThanOldWarning => !NewFileTimestampOlderThanOldWarnings.IsEmpty;
/// <summary>
/// Records a warning when a Modified file's new-side timestamp is older than its old-side timestamp.
/// Modified と判定されたファイルについて、new 側の更新日時が old 側より古い場合の警告を記録します。
/// </summary>
public void RecordNewFileTimestampOlderThanOldWarning(string fileRelativePath, string oldTimestamp, string newTimestamp)
{
if (string.IsNullOrWhiteSpace(fileRelativePath))
{
throw new ArgumentException($"{nameof(fileRelativePath)} cannot be null or whitespace.");
}
NewFileTimestampOlderThanOldWarnings[fileRelativePath] = new FileTimestampRegressionWarning(fileRelativePath, oldTimestamp, newTimestamp);
}
// ──────────────────────────────────────────────
// Configured IL substring safety warnings
// 設定された IL 部分文字列の安全性警告
// ──────────────────────────────────────────────
/// <summary>
/// Safety warning messages for configured IL substrings from
/// <c>ILIgnoreLineContainingStrings</c> and <c>ILNormalizeContainingStrings</c>,
/// including short values, duplicates, and containment relationships. Recorded during
/// diff execution and rendered in both Markdown and HTML report Warnings sections.
/// <c>ILIgnoreLineContainingStrings</c> および <c>ILNormalizeContainingStrings</c> で
/// 設定された IL 部分文字列に対する安全性警告メッセージ。短い値、重複、包含関係を含みます。
/// 差分実行時に記録され、Markdown および HTML レポートの警告セクションに表示されます。
/// </summary>
public ConcurrentBag<string> ILFilterWarnings { get; } = new ConcurrentBag<string>();
/// <summary>
/// Returns <see langword="true"/> when at least one configured IL substring safety warning exists.
/// 設定された IL 部分文字列の安全性警告が 1 件以上ある場合に <see langword="true"/> を返します。
/// </summary>
public bool HasAnyILFilterWarning => !ILFilterWarnings.IsEmpty;
// ──────────────────────────────────────────────
// Semantic & dependency analysis
// セマンティック・依存関係分析
// ──────────────────────────────────────────────
/// <summary>
/// Assembly semantic change summaries for ILMismatch files, keyed by file relative path.
/// ILMismatch ファイルに対するアセンブリセマンティック変更要約。キーはファイルの相対パス。
/// </summary>
public ConcurrentDictionary<string, AssemblySemanticChangesSummary> FileRelativePathToAssemblySemanticChanges { get; } = new ConcurrentDictionary<string, AssemblySemanticChangesSummary>(StringComparer.Ordinal);
/// <summary>
/// Dependency change summaries for .deps.json files, keyed by file relative path.
/// .deps.json ファイルに対する依存関係変更要約。キーはファイルの相対パス。
/// </summary>
public ConcurrentDictionary<string, DependencyChangeSummary> FileRelativePathToDependencyChanges { get; } = new ConcurrentDictionary<string, DependencyChangeSummary>(StringComparer.Ordinal);
/// <summary>
/// Estimated change pattern tags per file, keyed by file relative path.
/// ファイルごとの推定変更パターンタグ。キーはファイルの相対パス。
/// </summary>
public ConcurrentDictionary<string, IReadOnlyList<ChangeTag>> FileRelativePathToChangeTags { get; } = new ConcurrentDictionary<string, IReadOnlyList<ChangeTag>>(StringComparer.Ordinal);
/// <summary>
/// Returns the maximum <see cref="ChangeImportance"/> for a file, or <see langword="null"/> if no semantic changes exist.
/// ファイルの最大 <see cref="ChangeImportance"/> を返します。セマンティック変更が存在しない場合は <see langword="null"/>。
/// </summary>
public ChangeImportance? GetMaxImportance(string fileRelativePath)
{
ChangeImportance? max = null;
if (FileRelativePathToAssemblySemanticChanges.TryGetValue(fileRelativePath, out var summary) && summary.HasChanges)
max = summary.MaxImportance;
if (FileRelativePathToDependencyChanges.TryGetValue(fileRelativePath, out var depSummary) && depSummary.HasChanges)
{
var depMax = depSummary.MaxImportance;
max = max == null ? depMax : (depMax > max.Value ? depMax : max.Value);
}
return max;
}
/// <summary>
/// Returns all distinct <see cref="ChangeImportance"/> levels for a file across assembly semantic and dependency changes.
/// ファイルのアセンブリセマンティック変更と依存関係変更にわたる重複のない <see cref="ChangeImportance"/> レベルをすべて返します。
/// </summary>
public HashSet<ChangeImportance> GetAllImportanceLevels(string fileRelativePath)
{
var levels = new HashSet<ChangeImportance>();
if (FileRelativePathToAssemblySemanticChanges.TryGetValue(fileRelativePath, out var summary))
foreach (var e in summary.Entries) levels.Add(e.Importance);
if (FileRelativePathToDependencyChanges.TryGetValue(fileRelativePath, out var depSummary))
foreach (var e in depSummary.Entries) levels.Add(e.Importance);
return levels;
}
}
}