Hi Folks,
In this post, we will discuss how to suppression the best practice warnings while development. It's always recommended to remove/fix all best practice warnings before check-in your code to VSTS. To see all the BP warnings on your project; right click on the project and select
Run Best practice Fixer on <Project name>
This step will show all the BP warnings for the selected project. Let's see what all the ways we have to fix these.
1. In code itself:
Add suppression line before your method, with warning type and justification, the syntax is below
[SuppressBPWarning(‘<BPWarningType>’, <Description/Justification>.)] for example [SuppressBPWarning(‘BPParameterNotUsed’, Parameter required by the event interface.)].
This is an example for the same.
2. Edit Best Practice Suppression file (AxIgnoreDiagnosticList)
Every model should have a BP suppression file named
AxIgnoreDiagnosticList, for system models, you can find related BP suppression file at
K:\AosService\PackagesLocalDirectory\<ModelName>\<ModelName>\AxIgnoreDiagnosticList
Right-click on your project and select
‘Edit Best practice Suppression’. For all system models, this action will open the related BP suppression file.
For a new model:
In case you created a new model for your development (of course you would
) you have to create this file manually the first time, and on a later stage, you can amend for all BP fixes.
Create a new XML file under below path, I recommend to use a separate Visual studio instance for Create OR Edit this file.
K:\AosService\PackagesLocalDirectory\<yourModel>\<YourModel>\AxIgnoreDiagnosticList
Copy paste below
<?xml version="1.0" encoding="utf-8"?>
<IgnoreDiagnostics>
<Name>myModel_BPSuppressions</Name>
<Items>
<Diagnostic>
<DiagnosticType>BestPractices</DiagnosticType>
<Severity>Warning</Severity>
<Path>dynamics://<warning path></Path> //You can get this path from warning message
<Moniker>BPParameterNotUsed</Moniker> //You can get this from error message
<Justification>FormDataSourceEventArgs e is mandatory parameter for events and not used in the current context.</Justification>
</Diagnostic>
</Items>
</IgnoreDiagnostics>
Keep adding below tag for every warning
<Diagnostic>
<DiagnosticType>BestPractices</DiagnosticType>
<Severity>Warning</Severity>
<Path>dynamics://<warning path></Path> //You can get this path from warning message
<Moniker>BPParameterNotUsed</Moniker> //You can get this from error message
<Justification>FormDataSourceEventArgs e is mandatory parameter for events and not used in the current context.</Justification>
</Diagnostic>
</Items>
</IgnoreDiagnostics>
Some recommendations:
1. Best would be to create a new file using VS and place in the respective folder. Also, while adding new records best would be to edit this file from separate VS instance rather than same solution explorer.
2. You will find the BPWarningType in the warning message. If you not sure about the justification OR if you want to make consistency with system existing BP suppression, see the standard code.
3. I recommend using a separate Visual studio instance for Create OR Edit this file.
Cheers
Harry…