C# Enum generation - underlying int values do not match the original enum
I created an enum on my server with integer values set manually rather than the default increment up from 0 public enum UserType { Anonymous = 0, Customer = 10, Technician = 21, Manager = 25, Primary = 30 } I am using AspNetCore.App 2.2.0 and swashbuckle aspnetcore 4.0.1 to generate my CSharp API client The generated enum in the c sharp api client (using NSwag Studio for windows v 13.2.3.0) looks like this - the underlying integer values do not match the original enum. [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.5.0 (Newtonsoft.Json v11.0.0.0)")] public enum UserType { [System.Runtime.Serialization.EnumMember(Value = @"Anonymous")] Anonymous = 0, [System.Runtime.Serialization.EnumMember(Value = @"Customer")] Customer = 1, [System.Runtime.Serialization.EnumMember(Value = @"Technician")] Technician = 2, [System.Runtime.Serialization.EnumMember(Value = @"Manager")] Manager = 3, [System.Runtime.Serialization.EnumMember(Value = @"Primary")] Primary = 4, } This creates a problem for me client side as there are situations where I need to know the integer value. I am looking for a solution where I can avoid writing converters every time I want to know the integer value on the client side. Option 1: Is there an option I am missing in either NSwag Studio or in .net configuration (my Startup.Cs config is below for reference) where I can force the generated enums to get the same integer values as the original enum? Option 2: Alternatively if not, both my client and my server have access to the same original enum via a shared class library. Is there a way to get the generated api client to use the actual original enums in the apiclient.cs rather than generate its own? Reference: The enums part of my swagger generation code in Startup.Cs looks like this services.AddJsonOptions(options => { options. SerializerSettings.Converters.Add(new StringEnumConverter()); ....services.AddSwaggerGen(setup => { setup.SwaggerDoc("v1", new Info { Title = AppConst.SwaggerTitle, Version = "v1" }); setup.UseReferencedDefinitionsForEnums(); ... other stuff... } Matching SO question if you want some rephttps://stackoverflow.com/questions/60222469/swagger-c-sharp-enum-generation-underlying-int-values-do-not-match-the-originaRegistry key is not getting added for auto Login using C# script.
Hi, I am trying to write registry key for auto login using C# script. The script is getting executed, but the registry is not getting added. My code is shown as below: Initially I was getting an error stated as "Registry root is invalid",but running Test Complete as Administrator, the problem got solved. Now, that thescript is getting executed registry is not getting updated.Please help. function Test_FWC_UTL_Registry_Write_Registry_Key_Value() { var strKey strKey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon" FWC_UTL_Registry_Write_Registry_Key_Value (strKey, "DefaultUsername", "REG_SZ", "XXXXXXXX") } function FWC_UTL_Registry_Write_Registry_Key_Value(strRegistryKey, strRegName, strRegType, strRegKeyValue) { var WshShellObj,OutputVal WshShellObj = Sys["OleObject"]("Wscript.Shell") OutputVal = 0 if (WshShellObj == null) { GL_ErrMessage = "Couldn't able to create Shell object" } else { WshShellObj.RegWrite(strRegistryKey + "\\" + strRegName , strRegKeyValue, aqString["ToUpper"](strRegType)) WshShellObj = null OutputVal = 1 return OutputVal; } }Solved4.2KViews0likes9CommentsCannot create Test Complete Object
I am new to Visual Studio / Test Complete / C#. I have written a Test Complete test in C#, but when I try to run it it says "Cannot Create Test Complete Object". The only question so far that I have found does not apply to me. Even if it did, I did, as it suggested, run the program as admin but the same problem. This is nowhere near enough information for you to go on, so let me continue. My Test Complete test extends a class "AbstractTestCase" that we got from our team. This is the base class that has been used for years, so I am sure it is OK. I made a simple test, just to try to click an object. I have no idea whether the values are correct, but for now it does not matter, as my test is throwing an exception in the "Before()" method, so it has not gotten there yet. The exception is being thrown at this method, which I believe is Smart Bear method, so I cannot debug into it, and it shows no line number: Connect.RunTest(GetTestName(), "Generic", Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\Automation\TcFramwork\TcFramwork.pjs"); The values are as follows: GetTestName() ="RepriceTest" Path.GetDirectoryName... ="C:\\VS_Projects\\ErepricerSolution\\ErepriceClassLibrary\\bin\\Debug\\Automation\\TcFramwork\\TcFramwork.pjs" I do have a fileC:\\VS_Projects\\ErepricerSolution\\ErepriceClassLibrary\\bin\\Debug\\Automation\\TcFramwork\\TcFramwork.pjs which looks like this (along with a "Generic" subdirectory). Please see attached file. To attach it I had to convert it to an XML file. The only difference is this. Because my Desktop started crashing, I was one of the first (and only so far) people to get a laptop. Others will be getting themn as time goes on. The laptop has Windows 10, while everyone else has Windows 7. The Laptop has Test Complete 12. The laptop had Visual Studio 2015, but due to compiler incompatibilities with Smart Bear Connetc, I had to have Visual Studio 12 installed, which I am using. So others are using Windows 7, Visual Studio 12 and Test complete 12, while I am using Windows 10, Visual Studio 12 and Test Complete 12. I do see somewhet of a backtrace from this Connect.RunTest(), so maybe someone can figure out what's going on. Please see attached file trace.png. I am also attaching a copy of my test class. (And again I have no idea whether the Connect statement is right, but it never gets that far)2.7KViews0likes3CommentsC# Script implementation of VB script.
Hi, I am trying to write registry. I have a .vbs file which write the server registry for auto login as administratorafter a reboot. I am trying to integrate it as a C# script but getting run time error from the If statement as shown below. The code inside the .vbs files is as shown below. Please help. If WScript.Arguments.Named.Exists("elevated") = False Then CreateObject("Shell.Application").ShellExecute "wscript.exe", """" & WScript.ScriptFullName & """ /elevated", "", "runas", 1 WScript.Quit End If Set objShell = WScript.CreateObject("WScript.Shell") objShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\AutoAdminLogon", "1", "REG_SZ" Set objShell = Nothing1.9KViews0likes3Commentstimeout while waiting for a window (such as explorer, etc).
I have a main method in C# using Visual Studio. The important part is public void reprice() { ... try { test1(); } catch(Exception ex) { System.Diagnostics.Debug.WriteLine("place a break point here"); } ... } with the expectation that anything in test1() causing an exception I can catch. test1() has my Test Complete (12) code in it. The entire test worked fine. A teeny subset: pubclic void test1() { ... Connect.NameMapping["Sys"]["Keys"]("[Hold][Win]e[Release]"); wndCabinetWClass = explorer["wndCabinetWClass"]; } the second line beginning with wnd depends on the [Win]e above it top open a windows explorer window. To simulate an error, I commented out the Connect line. When I run it, I get the message "waiting for the wndCabinetWClass...", which is exactly what I would expect. The problem is, it does not seem to time out. It gives the message, and when the dots get to the end, it starts over again, and never seems to timeout. As you can see from the attached picture, my auto wait timeout is 10000 ms (10 sec), but this thing is still waiting after minutes. It takes a while for some windows to come up, but I would think 60 seconds is good enough. I found a suggestion to do "Options.Run.Timeout = 30000;", however my code cannot find Options. So I am not sure what to do. I guess it will eventually time out when the test has reached its maximum time, but that could be 30 minutes.1.6KViews0likes1Comment