|
At some point in the next few months, we might have to convert a large solution from VB.Net to C#. Is there a general consensus on what is the most reliable translation tool available on the market?
|
# ¿ Aug 9, 2014 12:03 |
|
|
# ¿ May 21, 2024 05:26 |
|
chippy posted:Can I use a List of Strings as a the key for a dictionary? From the way you describe the problem, it sounds like you want to start with the Foos as the keys, and the lists of strings as the values, and then turn that "inside-out" into the dictionary you actually want. GroupBy would fit exactly what you want to do, but as Sedro says it would also require you to define an EqualityComparer (using SequenceEqual). If you would have no further use for the comparer I'd just go with the lo-tech approach of a For Each loop: https://dotnetfiddle.net/fBRDaW
|
# ¿ Dec 22, 2014 22:14 |
|
Speaking of using{}, if a using (foo) {} block lasts until the end of the method, is it in any way different from just declaring foo as a local variable?
|
# ¿ Jan 16, 2015 20:24 |
|
Gul Banana posted:oh poo poo, just heard the news that asp.net 5 (vNext) will not support vb.net Do you have any source that it will not support vb.net, as opposed to just not supporting it now while it's still in beta? Our company's projects are all in VB.Net, and we're just about to start bringing some of those from the desktop to the web, so it was quite a bummer when I grabbed the MVC 6 starter project, converted to VB everything I could find in the project folder, and it still doggedly showed a reference to MS.Csharp.dll and refused to compile. It would suck pretty hard to have to choose between learning an already-obsolete framework, and the drudgery of converting some really fat DLLs after persuading the older programmers to switch syntax. (Plus, I like VB.Net better than C# myself.)
|
# ¿ Feb 3, 2015 18:57 |
|
Gul Banana posted:Yeah, I had a conversation with David Fowler. He stated pretty clearly that they're not going to support languages other than C# in KRuntime projects (actual asp.net sites and new-style class libraries). The fact that the guy who answered is the Principal Program Manager Lead on the ASP.NET team and has the handle "coolcsh" is pretty telling of his personal bias In any case, we're looking at those sexy, sexy DevExpress controls and those may tie us to MVC 5 for at least the short-medium term anyway, since they haven't said a word about vNext support.
|
# ¿ Feb 4, 2015 22:02 |
|
I'm trialing CodeRush and it's insanely faster than ReSharper, which slowed VS2013 down to a crawl. CodeRush has almost no performance impact, is less intrusive (coloured sidebar lines instead of squiggles EVERYWHERE), while also having pretty much all of the features I wanted from RS. Does that match anybody else's experience? When I was googling them almost everybody seemed to favour ReSharper.
|
# ¿ Feb 11, 2015 09:23 |
|
Ochowie posted:Also, some of the loop to linq conversion suggestions don't make a whole lot of sense and often produce code that is less clear (again in my opinion). I agree here. Lots of for-each loops can be turned into linq queries, but IMO it's the simpler ones that really benefit from it - those that do the exact same thing as one or two LINQ keywords. More complex enumerations are often easier to grok in loop form, and in particular some of the conversions that ReSharper suggested were eye-gougingly ugly. Also, the process of debugging a misbehaving loop is obvious, that of debugging a linq query not as much. NihilCredo fucked around with this message at 21:12 on Feb 11, 2015 |
# ¿ Feb 11, 2015 21:09 |
|
fleshweasel posted:I've got some legacy code with a whole lot of this Yes, the find / replace tool. This is a great place to use a regular expression.
|
# ¿ Feb 26, 2015 23:57 |
|
fleshweasel posted:Maybe if each property directly followed the backing field. But I actually have a region of fields and a region of properties. It's not good. ...but that makes things even easier? Delete the fields, then replace the {get {return (.+?) } set {\1 = value} } pattern* with {get; set;}. Done. I mean, if you already have ReSharper / CodeRush then yeah, let them do it for you, but if you don't this isn't a huge problem or anything. * For readability I didn't insert the newlines or escaped the curly braces, that's all you need though. NihilCredo fucked around with this message at 07:41 on Feb 27, 2015 |
# ¿ Feb 27, 2015 07:39 |
|
EssOEss posted:What are the negative things you have heard about ReSharper? For me, it simply slowed down VS2013 far beyond what I was willing to tolerate. I was considering keeping it just for the occasional refactoring while turning off Code Analysis, but then I tried CodeRush and it provided almost the same functionality at a fraction of the speed penalty.
|
# ¿ Feb 27, 2015 13:42 |
|
If you must maintain XP compatibility and must therefore target .NET 4.0, is it a total no-brainer to grab the BCL Portability Pack to get access to async/await or are there any drawbacks to consider?
|
# ¿ Mar 10, 2015 22:56 |
|
Ithaqua posted:This is basic access modifiers. Nitpick: Internal in VB.Net is called Friend edmund745 posted:I have tried looking for this answer online and can't find anything useful, since I suppose the question contains too many keywords. What, exactly, are the "list methods" you want to access from outside the object? Reading you literally, if you want to access, say, myObject.myList.Add(item) or myObject.myList.Clear(), then yeah, making the list public is what you want to do. (crashdome is correct that you can use a readonly property to let people use the List methods, without being able to outright replace the List with a new one. But in the particular case of a List, this wouldn't do much since people could just call .Clear() to empty the list and .AddRange() to replace it with anything they want. All a "readonly" modifier really does in this case is prevent people from setting the list to Nothing and causing trouble.) If you want to let people use only some methods of the list - a common case would be the ability to add stuff but not remove it - then you set up a few public methods or properties that expose only the stuff you want from the private list. If you want to access the individual objects inside the list, but not the list itself, same thing - add properties that fetch the items, without revealing anything about the list (or even that there is a list). Example: code:
|
# ¿ Apr 1, 2015 20:38 |
|
Rooster Brooster posted:Having never used that class before, do you need to call Close()? https://msdn.microsoft.com/en-us/library/microsoft.visualbasic.fileio.textfieldparser.close%28v=vs.110%29.aspx Either that or use a Using afile As New FileIO.TextFieldParser(filename) block. Setting objects to Nothing is not actually disposing of them. You're not demolishing your car, you're just throwing away your car keys and hope somebody notices the abandoned car and gets around to demolishing it. In this particular case, you're throwing away the keys of a running car. NihilCredo fucked around with this message at 22:17 on Apr 1, 2015 |
# ¿ Apr 1, 2015 22:14 |
|
You can also combine multiple Using variables in a single block, and terminate your loop by checking for .EndOfStream instead of waiting for a null Also, I wouldn't bother checking for file existence. You want to handle I/O exceptions anyway, because file permissions / drive access / network access could drop at any time during the operation, so might as well write the code only once. Visual Basic .NET code:
I'm trying to learn the ropes of F#, and I don't quite get why I must always put an identifier in discriminated unions. Basically, it seems to me that this ought to be legal code: code:
Can anybody help me understand if there's a reason the above code is not allowed? NihilCredo fucked around with this message at 00:47 on Apr 11, 2015 |
# ¿ Apr 10, 2015 23:29 |
|
Yesterday I was trying to speed up a fairly intensive procedure when I noticed that, no matter how much I cut down on the work it had to do, it wouldn't go under 5-6 seconds execution time. Then I realised that most of that time was actually being spent on the initial setup: looping through the DataTable containing the query results and setting up the business logic objects based on its contents. But this DataTable was barely a thousand rows, and the "building" wasn't doing any real work either ("if [Type] = "A" then add ([Name], [Quantity]) to SomeList else add to SomeOtherList", stuff like that) - I couldn't fathom why it would be so slow. Almost on a whim, I tried changing the For Each loop to a For loop. I fully expected nothing to happen... instead lo and behold, the loop became almost instant (Still noticeable, but well under a second.) Does that sort of behaviour ring a bell to anyone? Everything I can google says that the difference in iteration speed should have been insignificant. Casting to IEnumerable couldn't possibly have triggered some schema validation or anything of the sort, I hope?
|
# ¿ Apr 16, 2015 23:00 |
|
Ithaqua posted:This is all from memory: That makes a worrying amount of sense. I'll try that tomorrow, thanks! It seems odd to me that casting would be that expensive, especially when I'm checking for the "original" type. You'd think that looking at the type token and seeing that yep, it matches, would be pretty fast; if nothing else, the fastest of all possible casts. If that's indeed the guilty party, then at least I can keep using the prettier For Each as long as I drop the As DataRow part - and since accessing cells by column name is already horribly unsafe anyway that's quite fine. But, I'll also have to quit using LINQ on any DataTable of non-negligible size .
|
# ¿ Apr 17, 2015 00:20 |
|
Onion Knight posted:Is the Windows 10 registry different than previous versions of windows? This ought to do the trick: code:
EDIT: Although I'm not sure why you're getting that exception in the first place, since Convert.ToBoolean should accept boolean inputs quite fine. This works in dotnetfiddle, for example: code:
NihilCredo fucked around with this message at 11:01 on May 3, 2015 |
# ¿ May 3, 2015 10:39 |
|
Onion Knight posted:Once I get Windows 10 on my laptop I'll test it again with NihilCredo's solution, just in case. Cryolite posted:How safe is it to install VS2015 RC alongside VS2013? I vaguely remember reading something that said you should only install VS2015 in a VM or something that can be reformatted. Was this only for the CTPs or something like that? When it's actually released, will I be able to completely uninstall the RC and install the actual release, without messing up my system? Have been running the CTP alongside VS13 for a few months now (for messing around with F#4 and with vNext, while I did production work on VS13), never had any problems. If all my plugins work fine I'll probably switch over to VS15RC for production work too; side-by-side installations are a little expensive on a SSD.
|
# ¿ May 3, 2015 19:25 |
|
Dietrich posted:ungh web development in vs 2015 is like learning a whole new tool set with Gulp and Bower. Lots of development in 2015 seems to be about constantly learning new, totally essential open-source plugins and packages that you're supposed to discover through sheer memetic osmosis more than by any structured process. "What, you don't even Squazzle your assemblies or check them in Hoobilai before you Dripr them to a Kanoozer stack? You just compile and run? Jesus do you write COBOL programs for AS/400 or something?" (Say what you will about boring-rear end '90s enterprise software, but if somebody says that they're having good/bad results with MegaCorp Distributed Database Mapping Manager 5.0, I don't have to hit up Google to figure out if it's a tool that I care about.)
|
# ¿ May 13, 2015 21:30 |
|
chippy posted:Ahhh, thanks, I'll give this a go. I actually already tried pretty much exactly this, but I was using KeyDown, so taht explains why that wasn't working. For another option, I wouldn't bother dealing with input at all, instead I would handle the TextChanged event directly and get rid of any carriage returns.
|
# ¿ May 21, 2015 12:19 |
|
So if you want to create a WebSharper website, what are your options for good-looking UI controls beside KendoUI?
|
# ¿ Jun 4, 2015 19:55 |
|
AuxPriest posted:There's http://www.syncfusion.com but they have a similar price tag as Kendo Ui. Thanks, but what makes you say that SyncFusion works with WebSharper? I can't find any mention of either on the other's page The price tag for the UI library I don't mind - my boss has already committed to buying something nice in that area. But a WebSharper wrapper (premium extension) that costs as much as a DevCraft license would be a much harder sell, when there is no such additional cost for MVC; I could probably make the case for purchasing a WebSharper commercial license instead of a UI library, but not on top of one.
|
# ¿ Jun 8, 2015 22:54 |
|
Bognar posted:However, it looks like you could just use List.exists or List.forall with a mapping function instead of piping to Seq.exists. The LINQ corollaries are .Any() and .All(), respectively. Any(), All(), or exists() are the correct functions to use here as they will short-circuit as soon as they find a (non-)matching element.
|
# ¿ Jul 9, 2015 22:27 |
|
Mr Shiny Pants posted:I am writing a F# program and need a timer. What is a good timer for F#? Have you read this implementation with Timer and (F#) Observable? It doesn't look particularly ugly to me.
|
# ¿ Jul 19, 2015 11:40 |
|
LeftistMuslimObama posted:The whole concept of having multiple parts of each type is what makes it dumb. I get having a separate style part and worksheet part. Cool, separation of purposes. Having multiple worksheet parts that contain your document's worksheets is dumb. Just give a "get worksheets" method that returns a collection of all the worksheets, and require devs add new worksheets via that collection. Don't arbitrarily add parts whenever you want to add sheets. I should just be able to do something like A while ago I had to manipulate some data in an Excel file so I just used Microsoft.Interop.Excel.dll and I remember it being very straightforward; you do need to have Excel installed though.
|
# ¿ Jul 24, 2015 21:37 |
|
GrumpyDoctor posted:I accidentally just wrote an event handler for A that caused event B to fire, which in turn had a handler that caused A to fire, but the resulting infinite loop didn't blow my stack. Is that as impressive of a runtime achievement is it seems? Not really, I think. Events are async, so each handler will happily terminate and GTFO of the stack after firing off the event that continues the loop - kinda like TCO, in a way. In a normal infinite loop you blow the stack because there's an endless chain of calling functions that never got to terminate, but that doesn't happen here.
|
# ¿ Jul 25, 2015 23:32 |
|
GrumpyDoctor posted:I had never heard this before. Do you know somewhere I can read about it? Ok, sorry there, midnight brain fart, forget what I said. I'm so used to putting events, particularly UI events, on async execution (event handlers just wrap a threadpool call) that I forgot it's not the default behaviour. Event handler methods, by themselves, are blocking and synchronous. There still could be several reasons why your loop didn't explode. Maybe one of the events only actually fires after the method is exited, maybe you're using WaitHandles in a way that prevents the problem... I'd like to see the code, to be honest.
|
# ¿ Jul 26, 2015 11:23 |
|
The King of Swag posted:Maybe I'm just not understanding exactly at what level of the compilation process the safe navigation operator (?.) is working at, but despite developing using the .NET 4.0 runtime, VS2015 is recommending I use it, and sure enough, it actually works. So what's going on here? Is the compiler just compiling it in a way that it still functions with the older runtimes? Language version and .NET Framework versions are two different things, yes. The framework mostly just changes the libraries you work with.
|
# ¿ Aug 2, 2015 23:03 |
|
chippy posted:WinForms: I just want a property of the form (very simple dialogue for entering a single number) to always reflect the value of a NumericUpDown in the form. Based on those specs, is there any reason you can't just write code:
(If you do need to use databinding, VB14's NameOf function should at least help with type-safety.) NihilCredo fucked around with this message at 19:41 on Aug 6, 2015 |
# ¿ Aug 6, 2015 19:39 |
|
Does anyone know if the ASP.NET MVC Boilerplate template that's on Visual Studio Gallery is any good? Are there any recommended alternatives?
|
# ¿ Aug 30, 2015 20:51 |
|
quote:Add a notion of safe nullable reference types T? to the language, in addition to the current ones T which are from now on non-nullable. quote:From a semantic viewpoint, T and T? are mostly equivalent: they are the same type in that they have the same domain of values. Specifically, because the system is far from watertight, non-nullable reference types can contain null. The only way in which they differ is in the warnings caused by their use. I don't quite get how that would different from the existing Nullable<T> a.k.a. T? structure, which can already be used to wrap any reference type (even though that's not its intended purpose). The only new thing in the proposal seems to be the compiler warnings for lack of null-checks / null-propagation.
|
# ¿ Sep 5, 2015 13:47 |
|
LOOK I AM A TURTLE posted:Not sure what you mean by saying that T? can wrap any reference type. T? today is always translated to Nullable<T>, which can't be used on reference types because it has a where T : struct constraint: http://referencesource.microsoft.com/#mscorlib/system/nullable.cs,27. You're right. I was confused by a recent discussion in another thread. quote:Personally I like the proposal. It's a good compromise that allows backwards compatibility but should give much better practical safeguards against boneheaded NullReferenceExceptions. Of course we'd all rather have truly non-nullable reference types in C# if we could, but I don't think there's any realistic way to retrofit that at this point. Compiler option maybe? I mean, if VB.Net can have Option Strict which basically switches it from a strongly-typed to a weakly-typed language, I don't see why you can't introduce some sort of Option Nullable.
|
# ¿ Sep 5, 2015 15:35 |
|
Gul Banana posted:maybe if an *entire* language was async, coroutine based or green-threaded, you could avoid the infecting type..? Erlang?
|
# ¿ Sep 5, 2015 19:19 |
|
So, let's say I have a SQL table of a few thousand rows that I want to store in memory, as it will be frequently and randomly accessed. The table has only 6-7 relevant columns, all short strings or numbers. In the business logic, each row translates to an instance of a class which isn't quite a POCO, since it features a Parent property that returns (lazily) the instance identified by the ParentID column, plus a few static methods to find common ancestors and the like. (The fact that the class is self-referential is important, since otherwise I could have made it a struct.) Am I more likely to be better off : A) loading the table into memory as a DataTable and, when necessary, grabbing the row by the provided Id and instantiating the class from the row (and then throwing it away) or B) immediately loading the table into memory as a big Dictionary of string -> class ?
|
# ¿ Sep 14, 2015 12:35 |
|
Pause for a second. I thought DST always took effect at 2 AM <-> 3 AM?
|
# ¿ Sep 18, 2015 01:22 |
|
fleshweasel posted:These kinds of things are pretty much inevitable if you want c# code to basically compile into SQL at runtime and execute in your database. It's amazing they've made it as close as it is to the "real thing." That's why I love FSharp.Data.SqlClient so much. Give me the type safety and otherwise just let me write straight SQL: it's easier (and far, far more useful) to learn to write good SQL than to learn the quirks of an ORM's DSL.
|
# ¿ Sep 22, 2015 08:08 |
|
Manslaughter posted:Is there a way in visual studio to check a project for all uses of any enums? I'm having serialization problems with them, but its not just one specific enum, and I have a few hundred of them to sort out (tool generated). Do a find/replace over the declaration page for "public enum " -> "public enum BUTTS_", then go through the error list? (Also known as the "wow girl these hammer-shaped glasses are really makin' you look thin and sharp" method.)
|
# ¿ Sep 23, 2015 20:53 |
|
GrumpyDoctor posted:Holy god I just learned about "Paste Special->Paste XML As Classes" this is amazing It's cool as poo poo, but be sure to FULLY review the output or you may have some nasty surprises down the line. NihilCredo posted:Random cool thing about XML: Visual Studio has a feature called "Paste XML as classes" which does exactly what it says on the label and it looks loving magical.
|
# ¿ Oct 1, 2015 00:06 |
|
Your problem is that GetByManufacturer returns a collection of Automobiles. It makes no promises about those being Cars or Trucks - for all you know the implementation might completely ignore the input and just output a fixed mix of both - so they cannot be implicitly converted as such. To fix that, make GetByManufacturer into a generic function: code:
|
# ¿ Oct 6, 2015 22:48 |
|
|
# ¿ May 21, 2024 05:26 |
|
GrumpyDoctor posted:Also, is that generic method syntax right? I thought it should be
|
# ¿ Oct 7, 2015 01:22 |