Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 VA 2385: pragma warning breaks class parsing?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Uniwares
Tomato Guru

Portugal
1986 Posts

Posted - Sep 07 2020 :  05:51:53 AM  Show Profile  Reply with Quote
I have a few C# classes here with the following:
namespace Q7.Production
{
#pragma warning disable CA1001 // Types that own disposable fields should be disposable
    public sealed class ProductionHandler
#pragma warning restore CA1001 // This class is never disposed
    {
    }


As a result, all classes with this pragma are not being parsed by VA, Alt+M is empty, VA Outline shows:



As compared to CodeMaids view of the same class:




PS: I wont even talk about the coloring of the #pragma in the VA Outline window...

Edited by - Uniwares on Sep 07 2020 05:58:19 AM

feline
Whole Tomato Software

United Kingdom
16945 Posts

Posted - Sep 07 2020 :  08:57:33 AM  Show Profile  Reply with Quote
Can you please try updating to VA 2389, which is now available here:

https://support.wholetomato.com/default.asp?W404#2389

simply adding this example to the top of one of my C# code files does not show the problem at all. The problem makes some sense, since VA is probably not expecting a # line between the class name and the opening { bracket, but even then, I would not expect this to stop the entire file from being shown. But so far no problem in either VA Outline or the Alt-M list for me.

zen is the art of being at one with the two'ness
Go to Top of Page

Uniwares
Tomato Guru

Portugal
1986 Posts

Posted - Sep 07 2020 :  09:21:23 AM  Show Profile  Reply with Quote
Updated to 2389m continues with the same behaviour. Only change is in coloring of the pragma in the VA outline view.

This method of using the pragma comes from the Code Analyzer directly, so VA should support it (besides it being legal C# syntax)
Go to Top of Page

Uniwares
Tomato Guru

Portugal
1986 Posts

Posted - Sep 07 2020 :  09:26:19 AM  Show Profile  Reply with Quote
Following a stripped down class that shows this error on my IDE. Alt+M should show the ctor and the Instance property. When I enable "Show Regions" in the Alt+M, they dont show up.


using System;
using System.Diagnostics;

namespace Q7.Samples
{
	/// <summary>
	///	This class manages users and access<br/>
	/// </summary>
#pragma warning disable CA1001 // Types that own disposable fields should be disposable

	public sealed class StrippedDownSample
#pragma warning restore CA1001 // This class is never disposed
	{
		#region Private Fields

		private static readonly Lazy<StrippedDownSample> lazy = new Lazy<StrippedDownSample>(() => new StrippedDownSample());

		#endregion Private Fields

		#region Private Constructors

		/// <summary>
		/// Private Constructor => use SecurityHandler.Instance to access
		/// </summary>
		private StrippedDownSample()
		{
		}

		#endregion Private Constructors

		#region Public Properties

		/// <summary>
		/// Returns the one and only instance of this object (singleton)
		/// </summary>
		public static StrippedDownSample Instance
		{
			[DebuggerStepThrough]
			get
			{
				return lazy.Value;
			}
		}

		#endregion Public Properties
	}
}








Go to Top of Page

feline
Whole Tomato Software

United Kingdom
16945 Posts

Posted - Sep 07 2020 :  2:02:23 PM  Show Profile  Reply with Quote
I have the same problem here now, apologies for the delay. I figured out what I was doing wrong, I was testing this with an existing namespace already in the file, so instead of getting a basically empty list, I got a fairly full list, due to the other namespace, but basically nothing from the sample code you provided. It "only" takes out the class, not any following class or namespace, but when you only have one class in the file, it takes out the entire file:

case=142844

zen is the art of being at one with the two'ness
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2019 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000