Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,18 @@ public override void Init(AstContext context, ParseTreeNode treeNode)
var grammar = context.GetGrammar();
if (grammar != null)
{
PropertyName = treeNode.GetTheOnlyNode(grammar.AddedPropertyIdentifier.Name).FindTokenAndGetText();
InitValue = treeNode.GetTheOnlyNode(grammar.AddedPropertyInitializer.Name).FindTokenAndGetText();
PropertyName = treeNode.GetTheOnlyNode(grammar.AddedPropertyIdentifier.Name).FindTokenAndGetText();
var asFreeTextLiteral = InitValue = treeNode.GetTheOnlyNode(grammar.AddedPropertyInitializer.Name).FindTokenAndGetText();

if (asFreeTextLiteral.StartsWith("\""))
{
InitValue = $"@{asFreeTextLiteral}";
}
else
{
InitValue = asFreeTextLiteral;
}

MemberName = context.GetContext()?.Declaration?.Name;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,13 @@ public void generics()
CompareOutputs(GetMethodName());
}

[Fact]
public void multiline_pragmas()
{
CompareOutputs(GetMethodName());
}


protected abstract ICompilerOptions CompilerOptions { get; }


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void should_declare_property()
[Fact]
public void should_set_property_string()
{
var expected = "someField.AttributeName = \"This is name\";";
var expected = "someField.AttributeName = @\"This is name\";";
var field = NSubstitute.Substitute.For<IFieldDeclaration>();
field.Name.Returns("someField");
field.Pragmas.Returns(new ReadOnlyCollection<IPragma>(new IPragma[]
Expand Down Expand Up @@ -113,6 +113,28 @@ public void should_set_property_number()
Assert.Equal(expected, actual);
}

[Fact]
public void should_set_property_multiline_string()
{
var expected = "someField.MultilineSet = @\"Line 1 \n Line 2\";";
var field = NSubstitute.Substitute.For<IFieldDeclaration>();
field.Name.Returns("someField");
field.Pragmas.Returns(new ReadOnlyCollection<IPragma>(new IPragma[]
{
new PragmaMock("#ix-set:MultilineSet = \"Line 1 \n Line 2\"")
}));

//var field = new FieldMock("someField",
// new ReadOnlyCollection<IPragma>(new IPragma[]
// {
// new PragmaMock("#ix-set:AttributeMinimum = 10.5f")
// }));

var actual = field.SetProperties();

Assert.Equal(expected, actual);
}

[Fact]
public void should_set_generic_multiple_attributes_no_constraints()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ public Extendee2(AXSharp.Connector.ITwinObject parent, string readableTail, stri
Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail);
PreConstruct(parent, readableTail, symbolTail);
SomeData = new GenericsTests.SomeTypeToBeGeneric(this, "Shared Header", "SomeData");
SomeData.AttributeName = "Shared Header";
SomeData.AttributeName = @"Shared Header";
PostConstruct(parent, readableTail, symbolTail);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
using System;
using AXSharp.Connector;
using AXSharp.Connector.ValueTypes;
using System.Collections.Generic;
using AXSharp.Connector.Localizations;
using AXSharp.Abstractions.Presentation;

namespace MultilinePragmas
{
public partial class Extendee2 : AXSharp.Connector.ITwinObject
{
public OnlinerInt _messge { get; }

partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
public Extendee2(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail)
{
Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail);
this.@SymbolTail = symbolTail;
this.@Connector = parent.GetConnector();
this.@Parent = parent;
HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail);
PreConstruct(parent, readableTail, symbolTail);
_messge = @Connector.ConnectorAdapter.AdapterFactory.CreateINT(this, "_messge", "_messge");
_messge.PlcTextList = @"[1]:'<#Messenger 1: message text for message code 1#>':'<#Messenger 1: help text for message code 1#>';
[2]:'<#Messenger 1: message text for message code 2#>':'<#Messenger 1: help text for message code 2#>';
[3]:'<#Messenger 1: message text for message code 3#>':'<#Messenger 1: help text for message code 3#>';
[4]:'<#Messenger 1: message text for message code 4#>':'<#Messenger 1: help text for message code 4#>';
[5]:'<#Messenger 1: message text for message code 5#>':'<#Messenger 1: help text for message code 5#>';
[6]:'<#Messenger 1: message text for message code 6#>':'<#Messenger 1: help text for message code 6#>';
[7]:'<#Messenger 1: message text for message code 7#>':'<#Messenger 1: help text for message code 7#>';
[8]:'<#Messenger 1: message text for message code 8#>':'<#Messenger 1: help text for message code 8#>';
[9]:'<#Messenger 1: message text for message code 9#>':'<#Messenger 1: help text for message code 9#>';
[10]:'<#Messenger 1: message text for message code 10#>':'<#Messenger 1: help text for message code 10#>';
[11]:'<#Messenger 1: message text for message code 11#>':'<#Messenger 1: help text for message code 11#>'";
parent.AddChild(this);
parent.AddKid(this);
PostConstruct(parent, readableTail, symbolTail);
}

public async virtual Task<T> OnlineToPlain<T>()
{
return await (dynamic)this.OnlineToPlainAsync();
}

public async Task<global::Pocos.MultilinePragmas.Extendee2> OnlineToPlainAsync()
{
global::Pocos.MultilinePragmas.Extendee2 plain = new global::Pocos.MultilinePragmas.Extendee2();
await this.ReadAsync<IgnoreOnPocoOperation>();
plain._messge = _messge.LastValue;
return plain;
}

[Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public async Task<global::Pocos.MultilinePragmas.Extendee2> _OnlineToPlainNoacAsync()
{
global::Pocos.MultilinePragmas.Extendee2 plain = new global::Pocos.MultilinePragmas.Extendee2();
plain._messge = _messge.LastValue;
return plain;
}

[Obsolete("This method should not be used if you indent to access the controllers data. Use `OnlineToPlain` instead.")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
protected async Task<global::Pocos.MultilinePragmas.Extendee2> _OnlineToPlainNoacAsync(global::Pocos.MultilinePragmas.Extendee2 plain)
{
plain._messge = _messge.LastValue;
return plain;
}

public async virtual Task PlainToOnline<T>(T plain)
{
await this.PlainToOnlineAsync((dynamic)plain);
}

public async Task<IEnumerable<ITwinPrimitive>> PlainToOnlineAsync(global::Pocos.MultilinePragmas.Extendee2 plain)
{
#pragma warning disable CS0612
_messge.LethargicWrite(plain._messge);
#pragma warning restore CS0612
return await this.WriteAsync<IgnoreOnPocoOperation>();
}

[Obsolete("This method should not be used if you indent to access the controllers data. Use `PlainToOnline` instead.")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public async Task _PlainToOnlineNoacAsync(global::Pocos.MultilinePragmas.Extendee2 plain)
{
#pragma warning disable CS0612
_messge.LethargicWrite(plain._messge);
#pragma warning restore CS0612
}

public async virtual Task<T> ShadowToPlain<T>()
{
return await (dynamic)this.ShadowToPlainAsync();
}

public async Task<global::Pocos.MultilinePragmas.Extendee2> ShadowToPlainAsync()
{
global::Pocos.MultilinePragmas.Extendee2 plain = new global::Pocos.MultilinePragmas.Extendee2();
plain._messge = _messge.Shadow;
return plain;
}

protected async Task<global::Pocos.MultilinePragmas.Extendee2> ShadowToPlainAsync(global::Pocos.MultilinePragmas.Extendee2 plain)
{
plain._messge = _messge.Shadow;
return plain;
}

public async virtual Task PlainToShadow<T>(T plain)
{
await this.PlainToShadowAsync((dynamic)plain);
}

public async Task<IEnumerable<ITwinPrimitive>> PlainToShadowAsync(global::Pocos.MultilinePragmas.Extendee2 plain)
{
_messge.Shadow = plain._messge;
return this.RetrievePrimitives();
}

///<inheritdoc/>
public async virtual Task<bool> AnyChangeAsync<T>(T plain)
{
return await this.DetectsAnyChangeAsync((dynamic)plain);
}

///<summary>
///Compares if the current plain object has changed from the previous object.This method is used by the framework to determine if the object has changed and needs to be updated.
///[!NOTE] Any member in the hierarchy that is ignored by the compilers (e.g. when CompilerOmitAttribute is used) will not be compared, and therefore will not be detected as changed.
///</summary>
public async Task<bool> DetectsAnyChangeAsync(global::Pocos.MultilinePragmas.Extendee2 plain, global::Pocos.MultilinePragmas.Extendee2 latest = null)
{
if (latest == null)
latest = await this._OnlineToPlainNoacAsync();
var somethingChanged = false;
return await Task.Run(async () =>
{
if (plain._messge != _messge.LastValue)
somethingChanged = true;
plain = latest;
return somethingChanged;
});
}

public void Poll()
{
this.RetrievePrimitives().ToList().ForEach(x => x.Poll());
}

public global::Pocos.MultilinePragmas.Extendee2 CreateEmptyPoco()
{
return new global::Pocos.MultilinePragmas.Extendee2();
}

private IList<AXSharp.Connector.ITwinObject> Children { get; } = new List<AXSharp.Connector.ITwinObject>();

public IEnumerable<AXSharp.Connector.ITwinObject> GetChildren()
{
return Children;
}

private IList<AXSharp.Connector.ITwinElement> Kids { get; } = new List<AXSharp.Connector.ITwinElement>();

public IEnumerable<AXSharp.Connector.ITwinElement> GetKids()
{
return Kids;
}

private IList<AXSharp.Connector.ITwinPrimitive> ValueTags { get; } = new List<AXSharp.Connector.ITwinPrimitive>();

public IEnumerable<AXSharp.Connector.ITwinPrimitive> GetValueTags()
{
return ValueTags;
}

public void AddValueTag(AXSharp.Connector.ITwinPrimitive valueTag)
{
ValueTags.Add(valueTag);
}

public void AddKid(AXSharp.Connector.ITwinElement kid)
{
Kids.Add(kid);
}

public void AddChild(AXSharp.Connector.ITwinObject twinObject)
{
Children.Add(twinObject);
}

protected AXSharp.Connector.Connector @Connector { get; }

public AXSharp.Connector.Connector GetConnector()
{
return this.@Connector;
}

public string GetSymbolTail()
{
return this.SymbolTail;
}

public AXSharp.Connector.ITwinObject GetParent()
{
return this.@Parent;
}

public string Symbol { get; protected set; }

private string _attributeName;
public System.String AttributeName { get => string.IsNullOrEmpty(_attributeName) ? SymbolTail : _attributeName.Interpolate(this).CleanUpLocalizationTokens(); set => _attributeName = value; }

public System.String GetAttributeName(System.Globalization.CultureInfo culture)
{
return this.Translate(_attributeName, culture).Interpolate(this);
}

private string _humanReadable;
public string HumanReadable { get => string.IsNullOrEmpty(_humanReadable) ? SymbolTail : _humanReadable.Interpolate(this).CleanUpLocalizationTokens(); set => _humanReadable = value; }

public System.String GetHumanReadable(System.Globalization.CultureInfo culture)
{
return this.Translate(_humanReadable, culture);
}

protected System.String @SymbolTail { get; set; }
protected AXSharp.Connector.ITwinObject @Parent { get; set; }
public AXSharp.Connector.Localizations.Translator Interpreter => global::units.PlcTranslator.Instance;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ public string GetDescription(System.Globalization.CultureInfo culture)
partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
public SomeAddedProperties(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail)
{
Description = "Some added property name value";
Description = @"Some added property name value";
Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail);
this.@SymbolTail = symbolTail;
this.@Connector = parent.GetConnector();
this.@Parent = parent;
HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail);
PreConstruct(parent, readableTail, symbolTail);
Counter = @Connector.ConnectorAdapter.AdapterFactory.CreateINT(this, "Pocitadlo", "Counter");
Counter.AttributeName = "Pocitadlo";
Counter.AttributeName = @"Pocitadlo";
parent.AddChild(this);
parent.AddKid(this);
PostConstruct(parent, readableTail, symbolTail);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public Extendee2() : base()
{
}

[AXSharp.Connector.AddedPropertiesAttribute("AttributeName", "Shared Header")]
[AXSharp.Connector.AddedPropertiesAttribute("AttributeName", @"Shared Header")]
public GenericsTests.SomeTypeToBeGeneric SomeData { get; set; } = new GenericsTests.SomeTypeToBeGeneric();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using AXSharp.Abstractions.Presentation;
using AXSharp.Connector;

namespace Pocos
{
namespace MultilinePragmas
{
public partial class Extendee2 : AXSharp.Connector.IPlain
{
public Extendee2()
{
}

[AXSharp.Connector.AddedPropertiesAttribute("PlcTextList", @"[1]:'<#Messenger 1: message text for message code 1#>':'<#Messenger 1: help text for message code 1#>';
[2]:'<#Messenger 1: message text for message code 2#>':'<#Messenger 1: help text for message code 2#>';
[3]:'<#Messenger 1: message text for message code 3#>':'<#Messenger 1: help text for message code 3#>';
[4]:'<#Messenger 1: message text for message code 4#>':'<#Messenger 1: help text for message code 4#>';
[5]:'<#Messenger 1: message text for message code 5#>':'<#Messenger 1: help text for message code 5#>';
[6]:'<#Messenger 1: message text for message code 6#>':'<#Messenger 1: help text for message code 6#>';
[7]:'<#Messenger 1: message text for message code 7#>':'<#Messenger 1: help text for message code 7#>';
[8]:'<#Messenger 1: message text for message code 8#>':'<#Messenger 1: help text for message code 8#>';
[9]:'<#Messenger 1: message text for message code 9#>':'<#Messenger 1: help text for message code 9#>';
[10]:'<#Messenger 1: message text for message code 10#>':'<#Messenger 1: help text for message code 10#>';
[11]:'<#Messenger 1: message text for message code 11#>':'<#Messenger 1: help text for message code 11#>'")]
public Int16 _messge { get; set; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ namespace Pocos
{
namespace TypesWithPropertyAttributes
{
[AXSharp.Connector.AddedPropertiesAttribute("Description", "Some added property name value")]
[AXSharp.Connector.AddedPropertiesAttribute("Description", @"Some added property name value")]
public partial class SomeAddedProperties : AXSharp.Connector.IPlain
{
public SomeAddedProperties()
{
}

[AXSharp.Connector.AddedPropertiesAttribute("AttributeName", "Pocitadlo")]
[AXSharp.Connector.AddedPropertiesAttribute("AttributeName", @"Pocitadlo")]
public Int16 Counter { get; set; }
}
}
Expand Down
Loading