Al: Run time exception when missing translation

Created on 18 Jan 2018  路  4Comments  路  Source: microsoft/AL

Using translation file, with December anniversary update, I had a problem during F5

[Error - 10:43:46 AM] Please report this issue to https://github.com/microsoft/al/issues including information on how to reproduce it, if possible.
Processing of message 'al/createPackage' failed with error: 'Value cannot be null.
Parameter name: value'
StackTrace:
   at Microsoft.CodeAnalysis.CSharp.ObjectDisplay.FormatLiteral(String value, ObjectDisplayOptions options)
   at Microsoft.Dynamics.Nav.CodeAnalysis.Emit.CodeGenerator.GetLabelDataTypeFieldInitializer(TypeSymbol typeSymbol) in C:\Agent\_work\40\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Emitter\CodeGen\CodeGenerator_Defaults.cs:line 275
   at Microsoft.Dynamics.Nav.CodeAnalysis.Emit.CodeGenerator.EmitFieldInitializer(TypeSymbol typeSymbol) in C:\Agent\_work\40\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Emitter\CodeGen\CodeGenerator_Defaults.cs:line 115
   at Microsoft.Dynamics.Nav.CodeAnalysis.Emit.ApplicationObjectEmitHelper.EmitGlobalFieldDeclarations(ImmutableArray`1 globalVariables) in C:\Agent\_work\40\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Emitter\Code\ApplicationObjectEmitHelper.cs:line 773
   at Microsoft.Dynamics.Nav.CodeAnalysis.Emit.ApplicationObjectEmitHelper.EmitGlobalVariables(ImmutableArray`1 globalVariables, SyntaxKind onClearAccessModifier, ClassDeclarationSyntax classDeclaration) in C:\Agent\_work\40\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Emitter\Code\ApplicationObjectEmitHelper.cs:line 139
   at Microsoft.Dynamics.Nav.CodeAnalysis.Emit.ObjectCodeEmitter.Emit() in C:\Agent\_work\40\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Emitter\Code\ObjectCodeEmitter.cs:line 30
   at Microsoft.Dynamics.Nav.CodeAnalysis.Emit.ApplicationObjectCodeEmitter.Emit() in C:\Agent\_work\40\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Emitter\Code\ApplicationObjectCodeEmitter.cs:line 30
   at Microsoft.Dynamics.Nav.CodeAnalysis.Emit.ApplicationObjectEmitter.EmitObjectCode() in C:\Agent\_work\40\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Emitter\Code\ApplicationObjectEmitter.cs:line 39
   at Microsoft.Dynamics.Nav.CodeAnalysis.MethodCompiler.EmitObjectCode(ObjectTypeSymbol containingType) in C:\Agent\_work\40\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Compiler\MethodCompiler.cs:line 267
   at Microsoft.Dynamics.Nav.CodeAnalysis.MethodCompiler.CompileObject(ObjectTypeSymbol containingType) in C:\Agent\_work\40\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Compiler\MethodCompiler.cs:line 239
   at Microsoft.Dynamics.Nav.CodeAnalysis.MethodCompiler.<>c__DisplayClass17_0.<CompileObjectAsTask>b__0() in C:\Agent\_work\40\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Compiler\MethodCompiler.cs:line 216
   at Microsoft.Dynamics.Nav.CodeAnalysis.Utilities.UICultureUtilities.<>c__DisplayClass5_0.<WithCurrentUICulture>b__0() in C:\Agent\_work\40\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Utilities\UICultureUtilities.cs:line 152
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Dynamics.Nav.CodeAnalysis.MethodCompiler.WaitForWorkers() in C:\Agent\_work\40\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Compiler\MethodCompiler.cs:line 161
   at Microsoft.Dynamics.Nav.CodeAnalysis.MethodCompiler.CompileMethodBodies(Compilation compilation, ModuleBuilder moduleBeingBuiltOpt, Boolean hasDeclarationErrors, DiagnosticBag diagnostics, Predicate`1 filterOpt, CancellationToken cancellationToken) in C:\Agent\_work\40\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Compiler\MethodCompiler.cs:line 145
   at Microsoft.Dynamics.Nav.CodeAnalysis.Compilation.CompileImpl(ModuleBuilder moduleBuilder, Boolean emittingPdb, DiagnosticBag diagnostics, Predicate`1 filterOpt, CancellationToken cancellationToken) in C:\Agent\_work\40\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Compilation\Compilation.cs:line 810
   at Microsoft.Dynamics.Nav.CodeAnalysis.Compilation.Compile(ModuleBuilder moduleBuilder, Boolean emittingPdb, DiagnosticBag diagnostics, Predicate`1 filterOpt, CancellationToken cancellationToken) in C:\Agent\_work\40\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Compilation\Compilation.cs:line 787
   at Microsoft.Dynamics.Nav.CodeAnalysis.CommandLine.CommonCompiler.PackageTheModule(Compilation compilation, CompilerTextWriter consoleOutput, CancellationToken cancellationToken, ErrorLogger errorLogger, AnalyzerDriver analyzerDriver) in C:\Agent\_work\40\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\CommandLine\CommonCompiler.cs:line 531
   at Microsoft.Dynamics.Nav.CodeAnalysis.CommandLine.CommonCompiler.RunCore(CompilerTextWriter consoleOutput, ErrorLogger errorLogger, CancellationToken cancellationToken) in C:\Agent\_work\40\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\CommandLine\CommonCompiler.cs:line 413
   at Microsoft.Dynamics.Nav.CodeAnalysis.CommandLine.CommonCompiler.Run(CompilerTextWriter consoleOutput, CancellationToken cancellationToken) in C:\Agent\_work\40\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\CommandLine\CommonCompiler.cs:line 312
   at Microsoft.Dynamics.Nav.EditorServices.Protocol.LanguageServer.Extensions.CreatePackageRequestHandler.<HandleAsync>d__3.MoveNext() in C:\Agent\_work\40\s\source\Prod\Microsoft.Dynamics.Nav.EditorServices.Protocol\LanguageServer\Extensions\CreatePackageRequestHandler.cs:line 32
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Dynamics.Nav.EditorServices.Protocol.RequestRegistry.<Process>d__6.MoveNext() in C:\Agent\_work\40\s\source\Prod\Microsoft.Dynamics.Nav.EditorServices.Protocol\Endpoints\RequestRegistry.cs:line 59

This is due to a missing <target>"my translation" </target> on a Label field
I just did a simple Helloword project adding a label

pageextension 50100 CustomerListExt extends "Customer List"
{   


    actions
        {
            addafter(ShipToAddresses)
            {
                Action(OpenCard)
                {
                    ApplicationArea = All;
                    Caption ='My Caption';

                    trigger OnAction();

                    begin
                        Page.Run(Page::"Customer Card" );
                    end;
                }
            }
        }

    var
    text001: label 'App published: Hello world';

    trigger OnOpenPage();
    begin
        Message(text001);
    end;
}

The 2 translation files are the following

<?xml version="1.0" encoding="utf-8"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
  <file datatype="xml" source-language="en-US" original="ALProject1">
    <body>
      <group id="body">
        <trans-unit id="PageExtension 1255613137 - Action 4258600504 - Property 2879900210" maxWidth="999" size-unit="char" translate="yes" xml:space="preserve">
          <source>My Caption</source>
          <note from="Developer" annotates="general" priority="2" />
          <note from="Xliff Generator" annotates="general" priority="3">PageExtension - Action</note>
        </trans-unit>
        <trans-unit id="PageExtension 1255613137 - NamedType 2951775720" maxWidth="999" size-unit="char" translate="yes" xml:space="preserve">
          <source>App published: Hello world</source>
          <note from="Developer" annotates="general" priority="2" />
          <note from="Xliff Generator" annotates="general" priority="3">PageExtension - Label</note>
        </trans-unit>
      </group>
    </body>
  </file>
</xliff>

<?xml version="1.0" encoding="utf-8"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
  <file datatype="xml" source-language="en-US" target-language ="it-IT" original="ALProject1">
    <body>
      <group id="body">
        <trans-unit id="PageExtension 1255613137 - Action 4258600504 - Property 2879900210" maxWidth="999" size-unit="char" translate="yes" xml:space="preserve">
          <source>My Caption</source>
          <note from="Developer" annotates="general" priority="2" />
          <note from="Xliff Generator" annotates="general" priority="3">PageExtension - Action</note>
        </trans-unit>
        <trans-unit id="PageExtension 1255613137 - NamedType 2951775720" maxWidth="999" size-unit="char" translate="yes" xml:space="preserve">
          <source>App published: Hello world</source>

          <note from="Developer" annotates="general" priority="2" />
          <note from="Xliff Generator" annotates="general" priority="3">PageExtension - Label</note>
        </trans-unit>
      </group>
    </body>
  </file>
</xliff>

The problem happens just on Label. If the missing <target> is on Caption, no exception appears.

I think it would be enough adding a compiler message. Thanks

bug shipped

All 4 comments

Hi. Thank you for the repro. I have identified the bug and a fix is on the way. The workaround is to either specify a translation for each label or remove that translation item from the xliff.

Thanks Dominik. Just to add more information about label. A Label with an empty message (or space) can give a similar problem. ie <target></target> . Of course having an empty label is stupid, but I had this case from conversion of the old code. I used an empty TextConst in caption class of a page field, to arrange fields on a special way. In D365 putting a field with Caption ='' do the same

Do you wan't to be able to "translate" a label to be an empty string? Meaning you wan't to make it empty just for some language?

No Dominik, I really don't need it. I used it as a workaround in past version of Nav to arrange fields in card in a different way (ie. to help users to don't change their way to see things). Now I can achieve the same result just putting "Caption = '' ". Anyway, I told you just because It could be a compiler error, and not easy to find

Was this page helpful?
0 / 5 - 0 ratings