Skip to content
Permalink
Browse files

fixed a fault effect normalization bug where partial parts of compone…

…nts without a base list caused a null reference exception
  • Loading branch information...
axel-habermaier committed Oct 10, 2016
1 parent 0f175bc commit 1f9df63af15d1107edbbbfa7b090857b3bf06e28
@@ -136,6 +136,7 @@ THE SOFTWARE.
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002EJavaScript_002ECodeStyle_002ESettingsUpgrade_002EJsCodeFormatterSettingsUpgrader/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002EJavaScript_002ECodeStyle_002ESettingsUpgrade_002EJsParsFormattingSettingsUpgrader/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002EJavaScript_002ECodeStyle_002ESettingsUpgrade_002EJsWrapperSettingsUpgrader/@EntryIndexedValue">True</s:Boolean>
<s:Int64 x:Key="/Default/Environment/UnitTesting/ParallelProcessesCount/@EntryValue">8</s:Int64>
<s:Boolean x:Key="/Default/Environment/UnitTesting/ShadowCopy/@EntryValue">False</s:Boolean>
@@ -24,6 +24,7 @@ namespace SafetySharp.Compiler.Normalization
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using CompilerServices;
@@ -354,6 +355,9 @@ private ClassDeclarationSyntax ChangeFaultEffectBaseType(INamedTypeSymbol classS
/// </summary>
private ClassDeclarationSyntax ChangeComponentBaseType(INamedTypeSymbol classSymbol, ClassDeclarationSyntax classDeclaration)
{
if (classDeclaration.BaseList == null)
return classDeclaration;

if (classSymbol.BaseType.Equals(SemanticModel.GetTypeSymbol<Component>()))
return classDeclaration;

@@ -0,0 +1,89 @@
// The MIT License (MIT)
//
// Copyright (c) 2014-2016, Institute for Software & Systems Engineering
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

namespace Tests.Execution.Faults.ProvidedPorts
{
using SafetySharp.Modeling;
using Shouldly;
using Utilities;

internal class PartialClass : TestModel
{
protected sealed override void Check()
{
Create(new D());
var d = (D)RootComponents[0];

d.F1.Activation = Activation.Forced;
d.F2.Activation = Activation.Forced;
d.M().ShouldBe(1100);
d.N().ShouldBe(2222);

d.F1.Activation = Activation.Suppressed;
d.F2.Activation = Activation.Forced;
d.M().ShouldBe(1100);
d.N().ShouldBe(2202);

d.F1.Activation = Activation.Forced;
d.F2.Activation = Activation.Suppressed;
d.M().ShouldBe(100);
d.N().ShouldBe(222);

d.F1.Activation = Activation.Suppressed;
d.F2.Activation = Activation.Suppressed;
d.M().ShouldBe(100);
d.N().ShouldBe(202);
}

private abstract class C : Component
{
public readonly TransientFault F1 = new TransientFault();

public abstract int M();
public virtual int N() => 2;

[FaultEffect(Fault = nameof(F1))]
public abstract class F1Effect : C
{
public override int N() => 20 + base.N();
}
}

private partial class D : C
{
public readonly TransientFault F2 = new TransientFault();

public override int M() => 100;
public override int N() => 200 + base.N();
}

private partial class D
{
[FaultEffect(Fault = nameof(F2))]
public class F2Effect : D
{
public override int M() => base.M() + 1000;
public override int N() => base.N() + 2000;
}
}
}
}
@@ -269,6 +269,7 @@
<Compile Include="Execution\Faults\Binding\inherited fault.cs" />
<Compile Include="Execution\Faults\Binding\generics.cs" />
<Compile Include="Execution\Faults\Binding\non nested.cs" />
<Compile Include="Execution\Faults\ProvidedPorts\effect in partial class.cs" />
<Compile Include="Execution\Faults\ProvidedPorts\multiple effects same type.cs" />
<Compile Include="Execution\Faults\ProvidedPorts\multiple effects.cs" />
<Compile Include="Execution\Faults\ProvidedPorts\multiple inactive effects.cs" />

0 comments on commit 1f9df63

Please sign in to comment.
You can’t perform that action at this time.