0

Take the following Original C# code.

  class Pair
        {
#pragma warning disable 649
            public Customer customer;
            public Order order;
#pragma warning restore 649
        }

A well used online converter produced the following VB,

  Class Pair
    #Pragma warning disable 649
    Public customer As Customer
    Public order As Order
    #Pragma warning restore 649
End Class

Now VB doesn't support Pragma Warnings which Instant VB Does pick up and warn you about.

   Private Class Pair
'INSTANT VB TODO TASK: There is no equivalent to #pragma directives in VB:
'#pragma warning disable 649
            Public customer As Customer
            Public order As Order
'INSTANT VB TODO TASK: There is no equivalent to #pragma directives in VB:
'#pragma warning restore 649
        End Class

Now my question is this. Do I just remove the warnings and leave as is Ie;

   Private Class Pair
    Public customer As Customer
    Public order As Order

   End Class

or should I explicitly set values for these; say either an empty string or perhaps Null ie;

 Private Class Pair
    Public customer As Customer = NOTHING
    Public order As Order = NOTHING

   End Class

Thanks for any assistance and insight you can shed on the matter.

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Dom Sinclair
  • 2,458
  • 1
  • 30
  • 47
  • possible duplicate of [Suppressing "is never used" and "is never assigned to" warnings in C#](http://stackoverflow.com/questions/3820985/suppressing-is-never-used-and-is-never-assigned-to-warnings-in-c-sharp) – Bjørn-Roger Kringsjå Jan 04 '15 at 14:56
  • 1
    Why is there a warning at all? Wouldn't it make more sense to remove the problem causing a warning in the first place? – nvoigt Jan 04 '15 at 14:56
  • @Bjørn-RogerKringsjå I don't think it's a duplicate in so far as the other questioner was asking what they as a C# programmer ought to be doing when the get specific warnings, one of the answers being that they could use #prama warnings. Given that these don't exist in vb in the first place my question relates to specifically what I should do with them whem they crop up in converted code. Is it safe to simply delete them or should one try to avert whatever the original programmer was trying to avert with their ~pragma by, for example, explicitly setting the value of the whatever to Null? – Dom Sinclair Jan 04 '15 at 15:04
  • Looks to me you are entirely too focused on the task instead of the code. VB.NET doesn't generate that warning, no point in trying to suppress it. – Hans Passant Jan 04 '15 at 15:22
  • Thanks Hans. Yes I agree I'm probably too focused on the task, conversely one has to reason that the original developer had a reason for doing what they did. You have at least confirmed that all reference to the #Pragma or trying to 'allow' for an issue is unnecessary in this instance. – Dom Sinclair Jan 04 '15 at 15:30

0 Answers0