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

The suppressINotifyPattern flag in pac modulebuilder build crashes unless passed true/false parameter #361

Closed
filcole opened this issue Nov 20, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@filcole
Copy link

filcole commented Nov 20, 2022

The supressINotifyPattern is a flag parameter, however pac modulebuilder build crashes unless it is passed a true or false parameter, e.g.

Without a boolean parameter it crashes, as below:

❯ pac modelbuilder build --writesettingsTemplateFile --namespace ACME.Entities --serviceContextName ServiceContext --emitfieldsclasses --entitynamesfilter "account;contact" --suppressGeneratedCodeAttribute --outdirectory EntityModel2 --suppressINotifyPattern
Microsoft PowerPlatform CLI
Version: 1.20.3+ga66a744

Error: Model generation failed.
System.InvalidCastException: Null object cannot be converted to a value type.
   at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
   at Microsoft.PowerPlatform.Dataverse.ModelBuilderLib.CommandLineArgument.SetValue(Object argTarget, String argValue)
   at Microsoft.PowerPlatform.Dataverse.ModelBuilderLib.CommandLineParser.ParseArguments(String[] args)
   at Microsoft.PowerPlatform.Dataverse.ModelBuilderLib.ModelBuilderInvokeParameters.LoadArguments(String[] args)
   at bolt.module.modelbuilder.verbs.ModelBuilderVerb.Execute(IContext context, Command command)

Usage: pac modelbuilder build [--suppressGeneratedCodeAttribute] [--language] [--namespace] [--serviceContextName] [--generateActions] [--emitfieldsclasses] [--entitynamesfilter] [--messagenamesfilter] [--outdirectory] [--entitytypesfolder] [--messagestypesfolder] [--optionsetstypesfolder] [--generateGlobalOptionSets] [--writesettingsTemplateFile] [--settingsTemplateFile] [--suppressINotifyPattern]

  --suppressGeneratedCodeAttributeWhen set, this suppress all generated objects being tagged with the code generation engine and version (alias: -sgca)
  --language                  The language to use for the generated proxy code.  This can be either 'CS' or 'VB'.  The default language is 'CS'. (alias: -l)
  --namespace                 The namespace for the generated code.  The default namespace is the global namespace. (alias: -n)
  --serviceContextName        The name for the generated service context. If a value is passed in, it will be used for the Service Context.  If not, no Service Context will be generated. (alias: -sctx)
  --generateActions           When set, Emits message classes as part of code generation. (alias: -a)
  --emitfieldsclasses         Generate a constants structure that contains all of the field names by entity at the time of code generation. (alias: -efc)
  --entitynamesfilter         Filters the list of entities are retrieved when reading data from Dataverse. Passed in as a semicolon separated list.  Using the form <entitylogicalname>;<entitylogicalname> (alias: -enf)
  --messagenamesfilter        Filters the list of messages that are retrieved when reading data from Dataverse. Passed in as a semicolon separated list, required messages ( Create, Update, Delete, Retrieve, RetrieveMultiple, Associate and DisAssociate) are always included. An * can be used to proceed or trail an message allowing for all messages starting with or ending with a string.  Using the form <messagename>;<messagename> (alias: -mnf)
  --outdirectory              Write Directory for entity, message and optionset files (alias: -o)
  --entitytypesfolder         Folder name that will contain entities. default is Entities (alias: -etf)
  --messagestypesfolder       Folder name that will contain messages.  default is Messages (alias: -mtf)
  --optionsetstypesfolder     Folder name that will contain messages.  default is OptionSets (alias: -otf)
  --generateGlobalOptionSets  Emit all Global OptionSets, note: if an entity contains a reference to a global optionset, it will be emitted even if this switch is not present. (alias: -go)
  --writesettingsTemplateFile When Set, writes a settings file out to the output directory with the current passed settings or default settings (alias: -wstf)
  --settingsTemplateFile      Contains Settings to be used for this run of the Dataverse Model Builder, overrides any duplicate parameters on command line.  Cannot be set when --writesettingstemplate is used. (alias: -stf)
  --suppressINotifyPattern    When enabled, does not write the INotify wrappers for properties and classes.

With a parameter it does not crash if false or true are passed. Note: It seems anything other than false or true will trigger a crash.

❯ pac modelbuilder build --writesettingsTemplateFile --namespace ACME.Entities --serviceContextName ServiceContext --emitfieldsclasses --entitynamesfilter "account;contact" --suppressGeneratedCodeAttribute --outdirectory EntityModel2 --suppressINotifyPattern true
Connected to...Phil Cole's Environment
Begin Reading Metadata from MetadataProviderService
        Begin Reading Metadata from Server
        Read 2 Entities
        Read 0 Global OptionSets
        Read 0 SDK Messages
        Completed Reading Metadata from Server - 00:00:00.9790903
Completed Reading Metadata from MetadataProviderService - 00:00:00.9816697
Begin Writing Code File
        Processing 2 Entities
        Wrote 2 Entities - 00:00:00.0853007
        Processing 0 Messages
        Wrote 0 Messages - 00:00:00.0000112
        Processing 0 Global OptionSets
        Wrote 0 Global OptionSets - 00:00:00.0000138
        Code written to C:\Dev\ModuleBuilderTest\EntityModel2\Entities\account.cs.
        Code written to C:\Dev\ModuleBuilderTest\EntityModel2\Entities\contact.cs.
        Code written to C:\Dev\ModuleBuilderTest\EntityModel2\ServiceContext.cs.
        Code written to C:\Dev\ModuleBuilderTest\EntityModel2\EntityOptionSetEnum.cs.
Completed Writing Code File - 00:00:00.1118845

The other flags, e.g. --emitfieldsclasses and --suppressGeneratedCodeAttribute do not require parameters.

@MattB-msft MattB-msft added the bug Something isn't working label Nov 22, 2022
@MattB-msft
Copy link
Member

This has been identified and fixed in the next release.

@MattB-msft
Copy link
Member

This has been fixed in PAC CLI 1.21.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants