Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not compile empty namespace #68

Closed
benkinooby opened this issue Nov 19, 2020 · 3 comments
Closed

Can not compile empty namespace #68

benkinooby opened this issue Nov 19, 2020 · 3 comments
Labels

Comments

@benkinooby
Copy link
Contributor

Hi,

I want to compile the ModelDesign of an empty namespace but it fails with

PS C:\UA-ModelCompiler\Bin\Release> .\Opc.Ua.ModelCompiler.exe -d2 C:\opcua-modeling-tutorial\FooFltModel.xml -cg C:\opcua-modeling-tutorial\FooFltModel.csv -o C:\opcua-modeling-tutorial\FooFltModel -console
Object reference not set to an instance of an object.
   at Opc.Ua.ModelCompiler.ModelCompilerValidator.Validate2(IList`1 designFilePaths, String identifierFilePath, Boolean generateIds) in C:\UA-ModelCompiler\ModelCompiler\ModelDesignerValidator.cs:line 1099
   at Opc.Ua.ModelCompiler.ModelGenerator2.ValidateAndUpdateIds(IList`1 designFilePaths, String identifierFilePath, UInt32 startId, String specificationVersion) in C:\UA-ModelCompiler\ModelCompiler\ModelGenerator2.cs:line 95
   at Opc.Ua.ModelCompiler.Program.ProcessCommandLine2(List`1 tokens) in C:\UA-ModelCompiler\ModelCompiler\Program.cs:line 422

Here is the ModelDesign file I am trying to compile.

<?xml version="1.0" encoding="utf-8"?>

<ModelDesign
  xmlns:uax="http://opcfoundation.org/UA/2008/02/Types.xsd"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:ua="http://opcfoundation.org/UA/"
  xmlns:FooZbrFlt="https://new.foo.com/zebra-compression/flattening-and-subspacefolding/UA/"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  TargetNamespace="https://new.foo.com/zebra-compression/flattening-and-subspacefolding/UA/"
  TargetVersion="0.9.0"
  TargetPublicationDate="2020-05-01T00:00:00Z"
  xmlns="http://opcfoundation.org/UA/ModelDesign.xsd">

  <Namespaces>
    <!--No space allowed at the beginning of the namespace URL!
      Prefix sets the filenames of the generated files. -->
    <Namespace Name="FooZbrFlt" Prefix="FooFlt">https://new.foo.com/zebra-compression/flattening-and-subspacefolding/UA/</Namespace>
    <Namespace Name="OpcUa" Version="1.03" PublicationDate="2013-12-02T00:00:00Z">http://opcfoundation.org/UA/</Namespace>
  </Namespaces>
    
  <!-- Instantiate at least one variable (or object, or view, or ...) in namespace.
    Compiling an empty namespace will fail with error message:
	Object reference not set to an instance of an object.
    Uncomment to following view and the ModelDesign will compile successfully. -->
  
  <!-- 
  <View SymbolicName="FooZbrFlt:MyView">
    <Description>Dummy view.</Description>
    <References>
      <Reference IsInverse="true">
        <ReferenceType>ua:Organizes</ReferenceType>
        <TargetId>ua:ObjectsFolder</TargetId>
      </Reference>
    </References>
  </View>
  -->
</ModelDesign>

The model design file will compile successfully, if the view is uncommented and the namespace therefore is not empty.

Is this a bug of UA-ModelCompiler?

@opcfoundation-org
Copy link
Contributor

Not sure it is a priority. An empty file serves no purpose.

@benkinooby
Copy link
Contributor Author

Certainly not a priority but it has a purpose:

It allows you to test your server and toolchain without any knowledge about Nodesets and models. It's an edge case, but a rather helpful one. It helps you to start from scratch with your model/nodeset, which is a reasonable first step when starting with OPC UA modelling and getting to know variables, types, etc.

It has a workaround (adding e.g. a view as shown above) too, lowering the priority even further. But it is a confusing bug that will mainly be hit by newcomers.

@opcfoundation-org
Copy link
Contributor

Fixed in NET 5.0 version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants