Announcement

Collapse
No announcement yet.

The type or namespace name 'HMACSHA1' could not be found

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    The type or namespace name 'HMACSHA1' could not be found

    I'm trying to convert a C# project to JavaScript, as I'm not experienced in C#, and would prefer JavaScript.
    For this I'm testing bridge for the convertion, and then later I can optimize the output/compiled-JavaScript.

    When running
    bridge build
    I'm getting the following error:

    Building demo1               Bridge.NET Compiler error: exception level: 0 - C# Compilation Failed
    
        (183,13): CS0246: The type or namespace name 'HMACSHA1' could not be found (are you missing a using directive or an assembly reference?)
    
        (183,33): CS0246: The type or namespace name 'HMACSHA1' could not be found (are you missing a using directive or an assembly reference?)
    
        (213,42): CS0234: The type or namespace name 'NumberStyles' does not exist in the namespace 'System.Globalization' (are you missing an assembly reference?)
    I've tried running
    bridge add package xyz
    but without any luck.

    What to do?

    #2
    Hi. Welcome to Bridge!

    Are you using Windows or Mac?

    Can you post the .cs sample you are trying to compile?

    Comment


      #3
      Hello, thanks :)

      I'm using Mac OS X.
      I'm trying to convert this project https://github.com/PavelBansky/SharpSMS.

      Comment


        #4
        I guess the both types HMACSHA1 and NumberStyles are not currently supported by Bridge.

        So while they're not supported, the only way is to find alternatives in JavaScript world:
        • If you want to convert C# -> JavaScript just once, you can remove those lines (or replace them with some dummy code), add a TODO comment to find those locations in the generated JavaScript file, and after build is succeed provide the correct implementation in JavaScript.
        • If you want Bridge to generate the correct JavaScript code, that doesn't require additional changes, you can add proper JS code in [Template] attribute like this (but make sure the arguments fit the external function signature):
          	[Template("<self>SomeExternalLib.hmacsha1({0}, {1})")]
          	private extern byte[] ComputeMac(byte[] key, byte[] message);
        • Another option - to take a look at one of Retyped libraries, and replace HMACSHA1 with the corresponding library API call.

        The items for the described issues were already logged, you can track them by the links below

        Comment


          #5
          The NumberStyles class should be easy for us to add to the next Bridge release (16.8.0). I will investigate supporting int.Parse(). I believe the issue there will be properly supporting the NumberFormatInfo class and CultureInfo.

          The crypto classes are going to take some work. There's a lot in there.

          Comment

          Working...
          X