提交 7d5017d2 编写于 作者: M Marcin Wachulski

Add CFG check for branch extensions.

上级 c11bdeaa
......@@ -1081,6 +1081,15 @@ internal class CodeAnalysisResources {
}
}
/// <summary>
/// Looks up a localized string similar to The provided operation must not be part of a Control Flow Graph..
/// </summary>
internal static string OperationMustNotBeControlFlowGraphPart {
get {
return ResourceManager.GetString("OperationMustNotBeControlFlowGraphPart", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Output kind not supported..
/// </summary>
......
......@@ -630,4 +630,7 @@
<data name="InvalidBranchKindForFindingCorrespondingSwitch" xml:space="preserve">
<value>Invalid branch kind. Finding a corresponding switch requires 'break' kind, but the current branch kind provided is '{0}'.</value>
</data>
<data name="OperationMustNotBeControlFlowGraphPart" xml:space="preserve">
<value>The provided operation must not be part of a Control Flow Graph.</value>
</data>
</root>
\ No newline at end of file
......@@ -330,7 +330,8 @@ internal static IOperation GetRootOperation(this IOperation operation)
/// <returns>The corresponding loop operation or <c>null</c> in case not found (e.g. no loop syntax or the branch
/// belongs to switch instead of loop operation)</returns>
/// <exception cref="ArgumentNullException"><paramref name="branchOperation"/> is null</exception>
/// <exception cref="InvalidOperationException">Invalid branch kind. Applicable kinds: <see cref="BranchKind.Break"/> and <see cref="BranchKind.Continue"/>.</exception>
/// <exception cref="InvalidOperationException">The operation is a part of Control Flow Graph or it has an invalid branch kind.
/// Applicable kinds: <see cref="BranchKind.Break"/> and <see cref="BranchKind.Continue"/>.</exception>
public static ILoopOperation GetCorrespondingLoop(this IBranchOperation branchOperation)
{
if (branchOperation == null)
......@@ -338,6 +339,11 @@ public static ILoopOperation GetCorrespondingLoop(this IBranchOperation branchOp
throw new ArgumentNullException(nameof(branchOperation));
}
if (branchOperation.SemanticModel == null)
{
throw new InvalidOperationException(CodeAnalysisResources.OperationMustNotBeControlFlowGraphPart);
}
if (branchOperation.BranchKind != BranchKind.Break && branchOperation.BranchKind != BranchKind.Continue)
{
throw new InvalidOperationException(
......@@ -355,7 +361,8 @@ public static ILoopOperation GetCorrespondingLoop(this IBranchOperation branchOp
/// <returns>The corresponding switch operation or <c>null</c> in case not found (e.g. no switch syntax or the branch
/// belongs to loop instead of switch operation)</returns>
/// <exception cref="ArgumentNullException"><paramref name="branchOperation"/> is null</exception>
/// <exception cref="InvalidOperationException">Invalid branch kind. Applicable kinds: <see cref="BranchKind.Break"/>.</exception>
/// <exception cref="InvalidOperationException">The operation is a part of Control Flow Graph or it has an invalid branch kind.
/// Applicable kinds: <see cref="BranchKind.Break"/>.</exception>
public static ISwitchOperation GetCorrespondingSwitch(this IBranchOperation branchOperation)
{
if (branchOperation == null)
......@@ -363,6 +370,11 @@ public static ISwitchOperation GetCorrespondingSwitch(this IBranchOperation bran
throw new ArgumentNullException(nameof(branchOperation));
}
if (branchOperation.SemanticModel == null)
{
throw new InvalidOperationException(CodeAnalysisResources.OperationMustNotBeControlFlowGraphPart);
}
if (branchOperation.BranchKind != BranchKind.Break)
{
throw new InvalidOperationException(
......
......@@ -34,6 +34,11 @@
<target state="new">Given operation has a null semantic model.</target>
<note />
</trans-unit>
<trans-unit id="OperationMustNotBeControlFlowGraphPart">
<source>The provided operation must not be part of a Control Flow Graph.</source>
<target state="new">The provided operation must not be part of a Control Flow Graph.</target>
<note />
</trans-unit>
<trans-unit id="OutputKindNotSupported">
<source>Output kind not supported.</source>
<target state="translated">Druh výstupu se nepodporuje.</target>
......
......@@ -34,6 +34,11 @@
<target state="new">Given operation has a null semantic model.</target>
<note />
</trans-unit>
<trans-unit id="OperationMustNotBeControlFlowGraphPart">
<source>The provided operation must not be part of a Control Flow Graph.</source>
<target state="new">The provided operation must not be part of a Control Flow Graph.</target>
<note />
</trans-unit>
<trans-unit id="OutputKindNotSupported">
<source>Output kind not supported.</source>
<target state="translated">Ausgabetyp wird nicht unterstützt.</target>
......
......@@ -34,6 +34,11 @@
<target state="new">Given operation has a null semantic model.</target>
<note />
</trans-unit>
<trans-unit id="OperationMustNotBeControlFlowGraphPart">
<source>The provided operation must not be part of a Control Flow Graph.</source>
<target state="new">The provided operation must not be part of a Control Flow Graph.</target>
<note />
</trans-unit>
<trans-unit id="OutputKindNotSupported">
<source>Output kind not supported.</source>
<target state="translated">Tipo de salida no admitida.</target>
......
......@@ -34,6 +34,11 @@
<target state="new">Given operation has a null semantic model.</target>
<note />
</trans-unit>
<trans-unit id="OperationMustNotBeControlFlowGraphPart">
<source>The provided operation must not be part of a Control Flow Graph.</source>
<target state="new">The provided operation must not be part of a Control Flow Graph.</target>
<note />
</trans-unit>
<trans-unit id="OutputKindNotSupported">
<source>Output kind not supported.</source>
<target state="translated">Type de sortie non pris en charge.</target>
......
......@@ -34,6 +34,11 @@
<target state="new">Given operation has a null semantic model.</target>
<note />
</trans-unit>
<trans-unit id="OperationMustNotBeControlFlowGraphPart">
<source>The provided operation must not be part of a Control Flow Graph.</source>
<target state="new">The provided operation must not be part of a Control Flow Graph.</target>
<note />
</trans-unit>
<trans-unit id="OutputKindNotSupported">
<source>Output kind not supported.</source>
<target state="translated">Il tipo di output non è supportato.</target>
......
......@@ -34,6 +34,11 @@
<target state="new">Given operation has a null semantic model.</target>
<note />
</trans-unit>
<trans-unit id="OperationMustNotBeControlFlowGraphPart">
<source>The provided operation must not be part of a Control Flow Graph.</source>
<target state="new">The provided operation must not be part of a Control Flow Graph.</target>
<note />
</trans-unit>
<trans-unit id="OutputKindNotSupported">
<source>Output kind not supported.</source>
<target state="translated">出力の種類がサポートされていません。</target>
......
......@@ -34,6 +34,11 @@
<target state="new">Given operation has a null semantic model.</target>
<note />
</trans-unit>
<trans-unit id="OperationMustNotBeControlFlowGraphPart">
<source>The provided operation must not be part of a Control Flow Graph.</source>
<target state="new">The provided operation must not be part of a Control Flow Graph.</target>
<note />
</trans-unit>
<trans-unit id="OutputKindNotSupported">
<source>Output kind not supported.</source>
<target state="translated">출력 종류가 지원되지 않습니다.</target>
......
......@@ -34,6 +34,11 @@
<target state="new">Given operation has a null semantic model.</target>
<note />
</trans-unit>
<trans-unit id="OperationMustNotBeControlFlowGraphPart">
<source>The provided operation must not be part of a Control Flow Graph.</source>
<target state="new">The provided operation must not be part of a Control Flow Graph.</target>
<note />
</trans-unit>
<trans-unit id="OutputKindNotSupported">
<source>Output kind not supported.</source>
<target state="translated">Rodzaj wyjścia nie jest obsługiwany.</target>
......
......@@ -34,6 +34,11 @@
<target state="new">Given operation has a null semantic model.</target>
<note />
</trans-unit>
<trans-unit id="OperationMustNotBeControlFlowGraphPart">
<source>The provided operation must not be part of a Control Flow Graph.</source>
<target state="new">The provided operation must not be part of a Control Flow Graph.</target>
<note />
</trans-unit>
<trans-unit id="OutputKindNotSupported">
<source>Output kind not supported.</source>
<target state="translated">Tipo de saída sem suporte.</target>
......
......@@ -34,6 +34,11 @@
<target state="new">Given operation has a null semantic model.</target>
<note />
</trans-unit>
<trans-unit id="OperationMustNotBeControlFlowGraphPart">
<source>The provided operation must not be part of a Control Flow Graph.</source>
<target state="new">The provided operation must not be part of a Control Flow Graph.</target>
<note />
</trans-unit>
<trans-unit id="OutputKindNotSupported">
<source>Output kind not supported.</source>
<target state="translated">Неподдерживаемый тип выходных данных.</target>
......
......@@ -34,6 +34,11 @@
<target state="new">Given operation has a null semantic model.</target>
<note />
</trans-unit>
<trans-unit id="OperationMustNotBeControlFlowGraphPart">
<source>The provided operation must not be part of a Control Flow Graph.</source>
<target state="new">The provided operation must not be part of a Control Flow Graph.</target>
<note />
</trans-unit>
<trans-unit id="OutputKindNotSupported">
<source>Output kind not supported.</source>
<target state="translated">Çıkış türü desteklenmiyor.</target>
......
......@@ -34,6 +34,11 @@
<target state="new">Given operation has a null semantic model.</target>
<note />
</trans-unit>
<trans-unit id="OperationMustNotBeControlFlowGraphPart">
<source>The provided operation must not be part of a Control Flow Graph.</source>
<target state="new">The provided operation must not be part of a Control Flow Graph.</target>
<note />
</trans-unit>
<trans-unit id="OutputKindNotSupported">
<source>Output kind not supported.</source>
<target state="translated">输出类型不受支持。</target>
......
......@@ -34,6 +34,11 @@
<target state="new">Given operation has a null semantic model.</target>
<note />
</trans-unit>
<trans-unit id="OperationMustNotBeControlFlowGraphPart">
<source>The provided operation must not be part of a Control Flow Graph.</source>
<target state="new">The provided operation must not be part of a Control Flow Graph.</target>
<note />
</trans-unit>
<trans-unit id="OutputKindNotSupported">
<source>Output kind not supported.</source>
<target state="translated">輸出種類不支援。</target>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册