# Visual Basic parser suppress warning

**URL:** <https://forum.alternetsoft.com/t/visual-basic-parser-suppress-warning/502>\
**Category:** AlterNET Studio Support\
**Tags:** windows-forms\
**Created:** [July 23, 2025, 4:04pm UTC](https://forum.alternetsoft.com/t/visual-basic-parser-suppress-warning/502 "2025-07-23T16:04:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rob.panosh](https://forum.alternetsoft.com/letter_avatar_proxy/v4/letter/r/606060/32.png) [@rob.panosh](https://forum.alternetsoft.com/u/rob.panosh)\
**Post date:** [July 23, 2025, 4:04pm UTC](https://forum.alternetsoft.com/t/visual-basic-parser-suppress-warning/502/1 "2025-07-23T16:04:25Z")

</div>

When creating VB Roslyn compiler warning can be suppress using options:

options = options.WithSpecificDiagnosticOptions(  
New Dictionary(Of String, ReportDiagnostic) From {  
{“BC40000”, ReportDiagnostic.Suppress}, ’ Suppress BC40000 warning  
{“BC42105”, ReportDiagnostic.Suppress}, ’ Suppress BC42105 warning  
{“BC42005”, ReportDiagnostic.Suppress} ’ Suppress BC42005 warning  
})

How can warning be suppress in the VBParser?

Thanks,  
Rob

---

<div class="post-metadata">

**Author:** ![dmitry.medvedev](https://forum.alternetsoft.com/user_avatar/forum.alternetsoft.com/dmitry.medvedev/32/27_2.png) [@dmitry.medvedev](https://forum.alternetsoft.com/u/dmitry.medvedev)\
**Post date:** [July 24, 2025, 7:34am UTC](https://forum.alternetsoft.com/t/visual-basic-parser-suppress-warning/502/2 "2025-07-24T07:34:25Z")

</div>

Hi Rob,

Here’s a code snippet that does the same job for the parser:

```auto
  var vbParser = new VbParser(new MyVbSolution());

 public class MyVbSolution : VbSolution
 {
     private IDictionary<string, ReportDiagnostic> diags;

     public MyVbSolution()
     {
         diags = new Dictionary<string, ReportDiagnostic>
         {
             { "BC40000", ReportDiagnostic.Suppress },
         };
     }

     public override bool RegisterNamespaces(string[] nameSpaces, ProjectId projectId = null, string rootNamespace = null)
     {
         Project project = GetProjectOrDefault(projectId);
         if (project == null)
             return false;

         ApplySolutionChanges(s => s.WithProjectCompilationOptions(
             project.Id,
             new VisualBasicCompilationOptions(
                 OutputKind.DynamicallyLinkedLibrary,
                 globalImports: GetGlobalImports(nameSpaces),
                 rootNamespace: rootNamespace,
                 parseOptions: GetParserOptions(projectId) as VisualBasicParseOptions).WithSpecificDiagnosticOptions(diags)));
         Update();
         return true;
     }

     protected override CompilationOptions GetCompilationOptions(ProjectId projectId)
     {
         return base.GetCompilationOptions(projectId).WithSpecificDiagnosticOptions(diags);
     }

     private IList<GlobalImport> GetGlobalImports(string[] namespaces)
     {
         if (namespaces == null || namespaces.Length == 0)
             return null;
         IList<GlobalImport> result = new List<GlobalImport>();
         foreach (var import in namespaces)
         {
             result.Add(GlobalImport.Parse(import));
         }

         return result;
     }
 }

```

Overriding RegisterNamespaces should not be required, we will try to fix it in the next minor update.

Kind regards,  
Dmitry

---

<div class="post-metadata">

**Author:** ![rob.panosh](https://forum.alternetsoft.com/letter_avatar_proxy/v4/letter/r/606060/32.png) [@rob.panosh](https://forum.alternetsoft.com/u/rob.panosh)\
**Post date:** [July 24, 2025, 1:00pm UTC](https://forum.alternetsoft.com/t/visual-basic-parser-suppress-warning/502/3 "2025-07-24T13:00:49Z")

</div>

Hi Dmitry,

I converted your code to [VB.Net](http://VB.Net) and I am getting the following error messages:

 ![image](https://forum.alternetsoft.com/uploads/default/original/1X/418f7c0122c985893b37d5a8f0ca8fb8838afc70.png)

Here are the methods:

 ![image](https://forum.alternetsoft.com/uploads/default/original/1X/2b016cbde14e9805c224488713938387e851e059.png)

![image](https://forum.alternetsoft.com/uploads/default/optimized/1X/7148c27bfecfa740f94a779c201c7551ef9df2be_2_690x62.png)

I have feeling it is because I am on version 9.5.15.

Rob

---

<div class="post-metadata">

**Author:** ![rob.panosh](https://forum.alternetsoft.com/letter_avatar_proxy/v4/letter/r/606060/32.png) [@rob.panosh](https://forum.alternetsoft.com/u/rob.panosh)\
**Post date:** [July 24, 2025, 2:47pm UTC](https://forum.alternetsoft.com/t/visual-basic-parser-suppress-warning/502/4 "2025-07-24T14:47:02Z")

</div>

Fixed first error:  
 ![image](https://forum.alternetsoft.com/uploads/default/original/1X/b4b7b71081ec3c0972253e5891b202b621304b52.png)

Fixed second error:  
 ![image](https://forum.alternetsoft.com/uploads/default/original/1X/955c5c85ea23417d6db816f3e563eee21b875abd.png)

I’m assuming the newer version has overridden function passing “ProjectId”.

Rob

---

<div class="post-metadata">

**Author:** ![dmitry.medvedev](https://forum.alternetsoft.com/user_avatar/forum.alternetsoft.com/dmitry.medvedev/32/27_2.png) [@dmitry.medvedev](https://forum.alternetsoft.com/u/dmitry.medvedev)\
**Post date:** [July 25, 2025, 2:26am UTC](https://forum.alternetsoft.com/t/visual-basic-parser-suppress-warning/502/5 "2025-07-25T02:26:19Z")

</div>

Hi Rob,

The code above would work for the latest version (10.0).

I’ve uploaded a VB project compatible with 9.5.15 here:

> **[VBSample.zip](https://drive.google.com/file/d/1NsyszdK0b9stnZnIPteqYTtZTVgilo54/view?usp=sharing)**
>
> Google Drive file.

Please let me know if it works for you.

Kind regards,  
Dmitry
