Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Gul Banana
Nov 28, 2003

Munkeymon posted:

You mean they're dropping support? Link?

t4 still exists and works (except in new xproj projects), but it has not been rewritten to use roslyn. it's based on the old compiler infrastructure, so when you write t4 in vs2015 you get C#5 level features only.

reading the tea-leaves of developer statements, it appears that the team(s) would prefer people migrate to razor. unfortunately, that's just a nice parser library which doesn't provide the same generalised & tool-integrated macro facility as t4.

Adbot
ADBOT LOVES YOU

Sab669
Sep 24, 2009

I have an ASP page with a regular old HTML button on it. This button has its click event set dynamically based on the value of a hidden field. Basically it just calls 1 JavaScript method and passes a different parameter depending on that hidden field.

Is it possible to create a custom control that'd encase most of this logic for me?

I created a control which inherits from System.Web.UI.WebControls.Button, added a String member and a constructor that takes a String, which I assign to the private member.

In the ascx page I put a regular old HTML input button and copied over the logic that sets its click event and display text based on the private string defined in MyCustomButton.ascx.VB

On my actual page, I drop an instance of this button into the page and in the code behind I declare MyCustomButton1 / pass a String with the constructor.

When I run the application however, I just see a blank button with no text on it and it does nothing when clicked.

Not sure if I'm doing something wrong, or if this isn't really do-able.

Wasn't sure if the custom control needed to include the JavaScript files, or if it'd be able to call methods on it since the page in which the control is placed includes it too. But this did not make a difference.

SixPabst
Oct 24, 2006

Tony Montana posted:

What do you think, .NET devs? Am I doing this for the right reasons?

Phone posting so apologies for the brevity.

You're going to find a lot of similar issues on the dev side of things. Programmers can be complete god drat morons too. You may have an idealistic perspective of being left alone to program. Unless you're working on your own this usually isn't the case and a lot of the time you'll be looking at code someone else wrote and asking just what the gently caress they were thinking. You may not have time to comment and refactor that bad code.

On the other hand, I've seen your posts and you don't seem like an idiot, you've got good ambition and seem like you're about a million steps ahead of the next pluralsight graduate so I'd say go for it. Just maybe lose the rose-colored glasses. Development has it's days just like everything else.

epswing
Nov 4, 2003

Soiled Meat

mintskoal posted:

Unless you're working on your own this usually isn't the case and a lot of the time you'll be looking at code someone else wrote and asking just what the gently caress they were thinking.

Or looking at your own code 2 years later and asking what the gently caress you were thinking :v:

Mr Shiny Pants
Nov 12, 2012

epalm posted:

Or looking at your own code 2 years later and asking what the gently caress you were thinking :v:

This happens frequently....

No Safe Word
Feb 26, 2005

epalm posted:

Or looking at your own code 2 years later and asking what the gently caress you were thinking :v:

2 years? More like 2 days or 2 hours :v:

LiterallyAnything
Jul 11, 2008

by vyelkin
Every time I try and format the text content in a frame it reverts back visually but the properties stay the same. Anyone know why?

Edit- Also, after installing a package via NuGet, I can't find it in references. What obvious step am I missing? I've tried it using Package Manage Console as well as "Manage NuGet Packages../".

LiterallyAnything fucked around with this message at 17:14 on Jul 29, 2015

Drastic Actions
Apr 7, 2009

FUCK YOU!
GET PUMPED!
Nap Ghost
Installed the Windows 10 SDK update. Made a new project. Got told I didn't have .NETCore Version 5, and to download an update to get it, which redirected me back to the MS website. I checked the directory and I did have it there :shrug:

I'll try repairing VS and try again. I just want to update my app :(.

EDIT:

Didn't work. I'll just uninstall and reinstall VS :(

Drastic Actions fucked around with this message at 20:15 on Jul 29, 2015

Che Delilas
Nov 23, 2009
FREE TIBET WEED

Mr Shiny Pants posted:

This happens frequently....

And if it doesn't, you aren't learning enough.

aBagorn
Aug 26, 2004

Mr Shiny Pants posted:

This happens frequently....

Yeah this is pretty much every day for me, especially in non C# code (Javascript frameworks and SQL mostly).

Drastic Actions
Apr 7, 2009

FUCK YOU!
GET PUMPED!
Nap Ghost
Reinstalled VS, now I get "Cannot resolve Assembly or Windows Metadata file 'System.Runtime.dll'"

:suicide:

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

aBagorn posted:

Yeah this is pretty much every day for me, especially in non C# code (Javascript frameworks and SQL mostly).

Hell, I've gotten an hour into working on something, referred back to code I wrote near the start, and thought "No, no no, this is no good!"

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.
Any reason to avoid installing VS 2015 right now? It's a fresh install of Windows 10 and I'd just need to support existing apps and not making anything new atm.

Drastic Actions
Apr 7, 2009

FUCK YOU!
GET PUMPED!
Nap Ghost

Uziel posted:

Any reason to avoid installing VS 2015 right now? It's a fresh install of Windows 10 and I'd just need to support existing apps and not making anything new atm.

VS 2015 is great. I don't have any breakages except with this UWP stuff, which I think is because of all of these insider build cruft. But beyond that, it's great. You should be fine.

ljw1004
Jan 18, 2005

rum

Drastic Actions posted:

Reinstalled VS, now I get "Cannot resolve Assembly or Windows Metadata file 'System.Runtime.dll'"

People use the phrase "uninstall VS" as if that's even possible... there are just zillions of components it installs, and I don't know how to nail all of them. There were also some "insider builds" of VS that you probably were using which left cruft. And because they were just insider builds, the VS installer team weren't as thorough about making sure it all worked.

Honestly, I know it's frustrating, but at this stage it will be more time efficient to reimage your machine than to dig into why it's not working.

Oh... Known issue: The .netcore packages haven't yet been indexed on the nuget servers. So, if you open a UWP app without first having done File>New>UWP, then it won't find them. The fix is either to wait until indexing is done, or do file>new>UWP just once.

Drastic Actions
Apr 7, 2009

FUCK YOU!
GET PUMPED!
Nap Ghost

ljw1004 posted:

People use the phrase "uninstall VS" as if that's even possible... there are just zillions of components it installs, and I don't know how to nail all of them. There were also some "insider builds" of VS that you probably were using which left cruft. And because they were just insider builds, the VS installer team weren't as thorough about making sure it all worked.

Honestly, I know it's frustrating, but at this stage it will be more time efficient to reimage your machine than to dig into why it's not working.

Oh... Known issue: The .netcore packages haven't yet been indexed on the nuget servers. So, if you open a UWP app without first having done File>New>UWP, then it won't find them. The fix is either to wait until indexing is done, or do file>new>UWP just once.

I've been reformatting my computers so I can get onto the stable RTM build and off of the insider tracks. Once I got VS set up again (and Resharper :v:) I built the new UWP solution and it worked. So yeah, it was probably cruft and other crap from all of those other builds and VS updates. I should have something running hopefully tonight, and can hopefully submit something to the store tonight or tomorrow.

EDIT:

Good news! I got Awful working as a new UWP!

It has taken about an hour and and a half to get it working. It was not just drag and drop. One of the libraries I used (PCLStorage) did not work under the new project, so I had to fork it and make the library a UWP class library so it would work. I had to recreate three projects in my own solution so they would work too.

But after all that, it runs. Now I have to remake all of my icons because you guys changed the sizes again :argh:

EDIT 2: Now I'm fighting the loving app manifest. The build keeps failing, and it won't tell me why! First loving with icon sizes, now this. poo poo man, come on.

Drastic Actions fucked around with this message at 03:14 on Jul 30, 2015

ljw1004
Jan 18, 2005

rum

Drastic Actions posted:

One of the libraries I used (PCLStorage) did not work under the new project

Could you say more about that please? A couple of weeks ago I looked at SomethingAwful, and went through verifying that the NuGet packages it used would continue to install into a UWP app, and it's possible to reference PCLStorage fine. Is there some runtime behavior of it that's failing? I didn't test that.

(oh, and I saw that you're using PropertyChanged.Fody which doesn't work in UWP apps. I've contacted the author, and some .NET/NuGet devs are meeting on Friday to figure out how PropertyChanged.Fody should best be updated).


PS. If you have specific comments about the manifest designer or "build failing mysteriously", let me know and I'll pass it on to the manifest team. My manager told me that my job for the coming two weeks is to gather feedback about .NET development of UWP apps. So posting here is part of my day job :)

Drastic Actions
Apr 7, 2009

FUCK YOU!
GET PUMPED!
Nap Ghost

ljw1004 posted:

Could you say more about that please? A couple of weeks ago I looked at SomethingAwful, and went through verifying that the NuGet packages it used would continue to install into a UWP app, and it's possible to reference PCLStorage fine. Is there some runtime behavior of it that's failing? I didn't test that.

(oh, and I saw that you're using PropertyChanged.Fody which doesn't work in UWP apps. I've contacted the author, and some .NET/NuGet devs are meeting on Friday to figure out how PropertyChanged.Fody should best be updated).


PS. If you have specific comments about the manifest designer or "build failing mysteriously", let me know and I'll pass it on to the manifest team. My manager told me that my job for the coming two weeks is to gather feedback about .NET development of UWP apps. So posting here is part of my day job :)

When I tried to install PCLStorage from Nuget into the UWP project, it referenced the very bottom baseline PCL, instead of the WinRT one like I was expecting. When I tried to just straight up reference the WinRT DLLs Visual Studio would not let me. It did work in the older UWP app though. So I'm not sure if I screwed something up, or something else is going on :shrug:.

For PropertyChanged.Fody, I was using it for adding those events for updating the UI (Because those models are in the PCL and I'm lazy) but it seemed like it was working right to me. The thread post reply counter gets changed when I set new values to it. So maybe it never worked like how I thought it did and it's not necessary?

For the Manifest, I just want to know who said "Let's change Square70x70 to Square71x71.". Because seriously, why. I'm sure there is a good reason for these changes but it was the last change I was expecting. And it's such a pain in the rear end it make new ones. :argh:. I managed to get the build working again by just making a blank one and changing fields one by one, and then running the build to make sure it still worked. I still don't know what I did to cause it to break. But when it did fail, it just said it failed. Nothing in the console, no error messages. Just "failed".

Also for the icons again, I assumed the sizes were not changing because my old ones worked in my old UWP project by just dumping them in.

EDIT: 10 minutes before midnight on the East Coast. I got the UWP packages ready for Awful :woop:. Tomorrow I'll make the screenshots and submit to the store. There are still bugs I know about, but they are minor and I can release fast updates for them.

Drastic Actions fucked around with this message at 04:52 on Jul 30, 2015

Mr Shiny Pants
Nov 12, 2012

ljw1004 posted:

Could you say more about that please? A couple of weeks ago I looked at SomethingAwful, and went through verifying that the NuGet packages it used would continue to install into a UWP app, and it's possible to reference PCLStorage fine. Is there some runtime behavior of it that's failing? I didn't test that.

(oh, and I saw that you're using PropertyChanged.Fody which doesn't work in UWP apps. I've contacted the author, and some .NET/NuGet devs are meeting on Friday to figure out how PropertyChanged.Fody should best be updated).


PS. If you have specific comments about the manifest designer or "build failing mysteriously", let me know and I'll pass it on to the manifest team. My manager told me that my job for the coming two weeks is to gather feedback about .NET development of UWP apps. So posting here is part of my day job :)

Can you tell if the new Office is built using these templates? Just for my curiosity. :)

ljw1004
Jan 18, 2005

rum

Drastic Actions posted:

When I tried to install PCLStorage from Nuget into the UWP project, it referenced the very bottom baseline PCL, instead of the WinRT one like I was expecting.

I did File>New>VB>UWP and then added a NuGet reference to PCLStorage. It picked up the binary from the "portable-win8+wpa81" directory. The author says this is the correct one, and it does indeed support WinRT.

Is it possible you actually have your own PCL, and you're referencing PCLStorage from this PCL? That could cause it to pick up a different binary. If so, exactly which target does your PCL have?


Mr Shiny Pants posted:

Can you tell if the new Office is built using these templates? Just for my curiosity. :)

No idea! Sorry.

Mr Shiny Pants
Nov 12, 2012
Question:

I am working on an RT app, and one of the things you can do in the app is draw on a picture. This works fine.

Now the problem is the saved changes don't appear in the app. I generate a new thumbnail but it does not get loaded.

Is there a propertychanged for something like picture controls?

SirViver
Oct 22, 2008

Drastic Actions posted:

VS 2015 is great. I don't have any breakages except with this UWP stuff, which I think is because of all of these insider build cruft. But beyond that, it's great. You should be fine.
Personally, I'm pretty disappointed so far. I've been evaluating it while working on our large ASP.NET WebForms app, and overall the experience has been worse than VS 2013.
  • Edit & Continue in vicinity of LINQ/Lambda expressions is great, but the process of doing so is very sluggish. If you pause execution or hit a breakpoint and want to start typing, VS completely hangs for several seconds before your input is processed at all. Also very frequently objects will end up being nulled after editing that would not have been with the old E&C.

  • When writing code, there is a small but noticeable delay in keyword highlighting and similar functions like brace matching. This can make writing nested calls kinda awkward, as you can't rely on the highlighting actually showing you the current level so you know when to stop mashing ')'. I know this is a small & stupid thing, but I notice it and it irks me.

  • Occasional unexplainable sluggishness/hangs/general performance problems after using VS for some time. I've experienced VS hangs when trying to do banal stuff like:
    • Opening the Extensions & Updates dialog and trying to scroll or click on anything. The dialog is completely unresponsive for a while, then completes one action, then becomes unresponsive again, repeat.
    • Opening the New Project dialog and trying to scroll or click on anything. Same as above.
    • Browsing the Tools > Options dialog and clicking on various option groups on the left. VS would hang about ~10 seconds before it would display the corresponding options on the right.

  • Stupid little bugs like Go to Definition (F12) on external assemblies producing a "One or more errors occurred." dialog instead of showing the metadata info. If the SO report is correct, it's caused by the "Keep tabs" C# text editor setting :psyduck:

  • Other "enhancements" that you can't turn off, such as collapsed XML doc comments showing the first line of the <summary> contents. When I collapse things, I want the visual clutter to be reduced - this is the opposite of that. No option to disable as far as I can tell. Worse, there's apparently no option to change the text color of collapsed XML doc regions, so I can't even make it ultra light gray.

  • Code Lens is nice and I want to use it, but it adds too much visual clutter during normal development. There is still no toggle shortcut for it.
There might be other things I've forgotten. Of course it's not all bad, but my overall first impression regarding user experience is it being a step backwards from VS 2013.

ljw1004
Jan 18, 2005

rum

SirViver posted:

Personally, I'm pretty disappointed so far [...]

Oh dear! If you have time,

* EnC sluggishness - we haven't yet heard other reports of sluggishness here. The commonest cause of sluggishness is Resharper being installed, but that seems unlikely in this case. If you have time, I'd love it if you could "send a frown" via the smiley face at the top right. Put "attention: Uhlenhuth" somewhere in the bug description. Then, on the next page of the send-a-frown dialog, click "Something seems too slow" and perform the steps that exhibit the hang of several seconds. That way we'll get a detailed perf-trace of what's happening.

* Occasional unexplainable sluggishness/hangs in opening Extensions&Updates, opening NewProject, ToolsOptions -- for these again, if you have time, it'd be great to "send a frown". We haven't had any other reports of these kinds of hangs yet.

* True, "F12 Go To Definition" issue is indeed caused by tabs :(

* For CodeLens, you say it's too much visual clutter. (I agree, and always turn it off myself, unless I'm particularly keen to see the GitHub commit history for a particular method). You write "There's still no toggle shortcut". Do I understand correct that you just want a keyboard shortcut to quickly turn it off and on again?


If you prefer, you could also email me your comments (lwischik@microsoft.com) and I could loop in the relevant folks directly on the email thread. But if you have time, please at least do so in conjunction with the send-a-frown perf-traces, since we'll have no idea where to look for the hangs otherwise.

Drastic Actions
Apr 7, 2009

FUCK YOU!
GET PUMPED!
Nap Ghost

Mr Shiny Pants posted:

Question:

I am working on an RT app, and one of the things you can do in the app is draw on a picture. This works fine.

Now the problem is the saved changes don't appear in the app. I generate a new thumbnail but it does not get loaded.

Is there a propertychanged for something like picture controls?

I'm not sure if this is the same issue, but I remember having issues when trying to overwrite existing images when if you were binding an image from a file via the files source to an image view. So if I tried to download and overwrite an existing image (one where the image was loaded on the screen) it would not update because the file was not closed. Instead of binding an image source directly to an image in XAML I had to create a blank bitmap in my view model, then load my image directly to that, so that way I could close the file and we could overwrite that bitmap later with a newer one.

This is how I fixed it for VLC. Basically all you need to know is item.ArtistImage is a bitmap. So in your view model, try having a blank image that you map to.

Not sure if that answers your question, nor if my solution is the correct one :shrug:


ljw1004 posted:

I did File>New>VB>UWP and then added a NuGet reference to PCLStorage. It picked up the binary from the "portable-win8+wpa81" directory. The author says this is the correct one, and it does indeed support WinRT.

Is it possible you actually have your own PCL, and you're referencing PCLStorage from this PCL? That could cause it to pick up a different binary. If so, exactly which target does your PCL have?

"portable-win8+wpa81" is correct, but it would not work in my project. Nuget would get "portable-net45+wp8+wpa81+win8+monoandroid+monotouch+Xamarin.iOS+Xamarin.Mac", which is the baseline PCL and won't work. Referencing the DLLs directly would throw an error that they were not compatible. It needs "portable-win8+wpa81" because that actually has the reflections to the correct API calls for files.

This was on a fresh build of Windows 10, with a fresh install of VS 2015 and just the RTM SDK. I was only using Nugets DLLs, not any special brew I made. I know that in the last UWP SDK build and VS 2015 RC it did get "portable-win8+wpa81" and worked right. It was easy enough to just fork the project and make a new class library so I'm not bothered by it.

Drastic Actions fucked around with this message at 14:25 on Jul 30, 2015

Mr Shiny Pants
Nov 12, 2012

Drastic Actions posted:

I'm not sure if this is the same issue, but I remember having issues when trying to overwrite existing images when if you were binding an image from a file via the files source to an image view. So if I tried to download and overwrite an existing image (one where the image was loaded on the screen) it would not update because the file was not closed. Instead of binding an image source directly to an image in XAML I had to create a blank bitmap in my view model, then load my image directly to that, so that way I could close the file and we could overwrite that bitmap later with a newer one.

This is how I fixed it for VLC. Basically all you need to know is item.ArtistImage is a bitmap. So in your view model, try having a blank image that you map to.

Not sure if that answers your question, nor if my solution is the correct one :shrug:

I think this will put me on the right track. Thanks!

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

ljw1004 posted:

* For CodeLens, you say it's too much visual clutter. (I agree, and always turn it off myself, unless I'm particularly keen to see the GitHub commit history for a particular method). You write "There's still no toggle shortcut". Do I understand correct that you just want a keyboard shortcut to quickly turn it off and on again?

I think the information from CodeLens is great, but by no means do I want to see it all the time. If there was a hotkey to make that information appear just above the method your cursor is in, or maybe in a popover window, I would be pretty happy.

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


Coworker and I are having a minor disagreement on where to implement a few windows events on a ListView--specifically, DragOver, Drop, and KeyPressed (delete key, specifically, for removing entries). Right now he has them implemented as markup extension commands, instead of normal code-behind events; this means they (and their business logic) can go straight to the viewmodel. I feel that, because they use things like the DragOverEventArgs as the CommandParameter, which are inherently UI/view related, they have no business going to the VM at all--at least, not before parsing those event args into a list of files that were dropped, in this case--and should have been normal code behind events, despite the usual thing about code-behind being bad or whatever.

What do you think? Either way works, we're both just still learning the 'right' way to do things in this cockamamie MVVM thing.

(Sorry I can't post any code. :()

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Ciaphas posted:

Coworker and I are having a minor disagreement on where to implement a few windows events on a ListView--specifically, DragOver, Drop, and KeyPressed (delete key, specifically, for removing entries). Right now he has them implemented as markup extension commands, instead of normal code-behind events; this means they (and their business logic) can go straight to the viewmodel. I feel that, because they use things like the DragOverEventArgs as the CommandParameter, which are inherently UI/view related, they have no business going to the VM at all--at least, not before parsing those event args into a list of files that were dropped, in this case--and should have been normal code behind events, despite the usual thing about code-behind being bad or whatever.

What do you think? Either way works, we're both just still learning the 'right' way to do things in this cockamamie MVVM thing.

(Sorry I can't post any code. :()

Here's my guideline: Does the behavior you're implementing interact with the underlying data in any way? For example, if the "drop" interaction results in data moving from one observable collection to another, then that's not purely view related. It's the view manipulating the viewmodel via UI interactions, same as typing text into a textbox updates the viewmodel.

The UI behavior itself can be in the view, that's fine. But the interaction with the data shouldn't happen in the view. Of course, it's a lot less important if you know 100% for a fact that you will never, ever hook a different view up to that viewmodel. No need to be dogmatic about things. Patterns and practices are great for giving you a general direction, but there are going to be real world cases where doing things THE RIGHT WAY is not worth the effort.

Like with unit testing: A few years ago, I was 100% "everything should be unit tested all the time no exceptions". Now I've backed off a bit to "everything critical or complex should be unit tested".

New Yorp New Yorp fucked around with this message at 15:12 on Jul 30, 2015

GoodCleanFun
Jan 28, 2004
Loving 2015 thus far. Only issue I've seen is with NuGet versioning as described here: https://stackoverflow.com/questions/31617719/vs-2015-nuget-versioning

A few of my packages I've updated to 1.0.0.1 and those show the correct version. Something about 1.0.0.0 NuGet in 2015 doesn't like and it just displays 1.0.0. Seems like just a display issue, but I can't say for sure.

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


Ithaqua posted:

Here's my guideline: Does the behavior you're implementing interact with the underlying data in any way? For example, if the "drop" interaction results in data moving from one observable collection to another, then that's not purely view related. It's the view manipulating the viewmodel via UI interactions, same as typing text into a textbox updates the viewmodel.

The UI behavior itself can be in the view, that's fine. But the interaction with the data shouldn't happen in the view. Of course, it's a lot less important if you know 100% for a fact that you will never, ever hook a different view up to that viewmodel. No need to be dogmatic about things. Patterns and practices are great for giving you a general direction, but there are going to be real world cases where doing things THE RIGHT WAY is not worth the effort.

Like with unit testing: A few years ago, I was 100% "everything should be unit tested all the time no exceptions". Now I've backed off a bit to "everything critical or complex should be unit tested".

For production, no, the view and viewmodel in question are proverbially joined at the hip. My only thinking was that, if I dig the Windows-y UI poo poo (DragEventArgs in this case) out of the viewmodel and leave it in the view's code-behind, we can attach a different view later--say, a console for headless unit tests. (And this viewmodel in question is one that does very much need to be tested.)

Plus, neither of us really know what we're doing when it comes to MVVM yet; going against dogma when we don't quite know what the dogma is is kinda hard. What's the old saw, the rules are there to make you at least think when you're breaking them? Yeah, I don't know the rules yet, hence these posts :v:

The specific use case here is that drag-dropping a file should attempt to open it, adding it to the VM's ObservableCollection<Request> and thus displaying the dropped file in the ListView it was dropped on via binding. This was already implemented as a command leading to a method in the VM via a plain old button. So my figuring was, I'd move the actual drop event to the code behind, have it extract the file name, then call the VM's Open method directly (via something like (DataContext as MyViewModel).Open(fileName)).

Ciaphas fucked around with this message at 16:18 on Jul 30, 2015

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy
I generally like to do like you're suggesting. I consider drag-and-drop to be view related, so I isolate my ViewModel from DnD logic wherever possible.

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


Thanks to both of you. My coworker and I will discuss what you said when we meet again today. :)

Separate question entirely I just remembered, and one a hell of a lot more general/easier to answer (I hope). Is this sufficient for overriding Equals(), or am I missing a piece? (I may have ballsed up the syntax--again, different machine)

C# code:
class Request : IEquatable<Request>
{
   public string FileName {get; set;} // whatever

   public override bool Equals(object rhs)
   {
      if (base.Equals(rhs)) return true;
      if (rhs.Type() != this.Type()) return false;

      return Equals(rhs as Request);
   }
   public bool Equals(Request rhs) // implements IEquatable
   {
      return FileName == rhs.FileName; // or whatever other value semantics...
   }
}

Ciaphas fucked around with this message at 16:25 on Jul 30, 2015

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Ciaphas posted:

Thanks to both of you. My coworker and I will discuss what you said when we meet again today. :)

Separate question entirely I just remembered, and one a hell of a lot more general/easier to answer (I hope). Is this sufficient for overriding Equals(), or am I missing a piece? (I may have ballsed up the syntax--again, different machine)

C# code:
class Request : IEquatable<Request>
{
   public string FileName {get; set;} // whatever

   public override bool Equals(object rhs)
   {
      if (base.Equals(rhs)) return true;
      if (rhs.Type() != this.Type()) return false;

      return Equals(rhs as Request);
   }
   public bool Equals(Request rhs) // implements IEquatable
   {
      return FileName == rhs.FileName; // or whatever other value semantics...
   }
}

When you override Equals, you should also override GetHashCode -- Stack Overflow explains why this is important:
http://stackoverflow.com/questions/371328/why-is-it-important-to-override-gethashcode-when-equals-method-is-overridden

[edit]
Now that I look more closely, your overridden equals seems weird.

New Yorp New Yorp fucked around with this message at 16:51 on Jul 30, 2015

Sedro
Dec 31, 2008

Ciaphas posted:

Thanks to both of you. My coworker and I will discuss what you said when we meet again today. :)

Separate question entirely I just remembered, and one a hell of a lot more general/easier to answer (I hope). Is this sufficient for overriding Equals(), or am I missing a piece? (I may have ballsed up the syntax--again, different machine)

You need to implement GetHashCode, and yours will throw exceptions when comparing to null.

You shouldn't be writing this boilerplate. Here's what R# generates:
C# code:

class Request : IEquatable<Request>
{
    public string FileName { get; set; } // whatever

    public bool Equals(Request other)
    {
        if (ReferenceEquals(null, other)) return false;
        if (ReferenceEquals(this, other)) return true;
        return string.Equals(FileName, other.FileName);
    }

    public override bool Equals(object obj)
    {
        if (ReferenceEquals(null, obj)) return false;
        if (ReferenceEquals(this, obj)) return true;
        if (obj.GetType() != this.GetType()) return false;
        return Equals((Request) obj);
    }

    public override int GetHashCode()
    {
        return (FileName != null ? FileName.GetHashCode() : 0);
    }
}
You can also use compile-time instrumentation (e.g. Fody) which is a bit more maintainable than code generation

SirViver
Oct 22, 2008

ljw1004 posted:

Oh dear! If you have time,
Thanks for the reply!

I'll try to reproduce these issues and send the reports within the next week or so. Of course, with the whole thing only happening sometimes it might take a while. Especially the hanging dialogs could be tricky, as IIRC I had to force close devenv.exe to get anything done once it occurred. The EnC thing I can reproduce relatively easily though. Let's see.

I do have some extensions installed, of which the most performance hungry is probably the Productivity Power Tools 2015 one, though running in Safe Mode (all 3rd party Extensions disabled) didn't show any immediate performance improvement either. Resharper I only have on VS 2013 and perma-suspended except for when I really need specific functionality of it, as the performance impact of it is quite frankly ridiculous.

quote:

* For CodeLens, you say it's too much visual clutter. (I agree, and always turn it off myself, unless I'm particularly keen to see the GitHub commit history for a particular method). You write "There's still no toggle shortcut". Do I understand correct that you just want a keyboard shortcut to quickly turn it off and on again?
Yes, exactly. Just some way to enable/disable Code Lens via a command instead of having to go to Options and switching it from there. Whether it's done via a toolbar button or keyboard shortcut doesn't really matter to me, though I think the latter would be the generally preferred option. Implementing one probably comes with the other anyway, though. The reason I wrote "still" is actually because I found a VS 2013 Uservoice entry wishing for it when I did a Google search for the non-existing shortcut - I admittedly didn't even know Code Lens existed since VS 2013 already :shobon:

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


Sedro posted:

You need to implement GetHashCode, and yours will throw exceptions when comparing to null.

You shouldn't be writing this boilerplate. Here's what R# generates:
[code elided]
You can also use compile-time instrumentation (e.g. Fody) which is a bit more maintainable than code generation

Sorry, what's R#? Google's coming up with some statistical programming language, which given context I don't think is right :v:

gariig
Dec 31, 2004
Beaten into submission by my fiance
Pillbug

Ciaphas posted:

Sorry, what's R#? Google's coming up with some statistical programming language, which given context I don't think is right :v:

Resharper. Code Rush might have the same problem

Sedro
Dec 31, 2008
Yeah, ReSharper, sorry. Google has never been good with symbols

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


ReSharper, I vaguely remember the dev team I'm helping was working on getting that, I think. I'll have to look at what it is, I've never heard of it, but if it helps me deal with bullshit boilerplate like that Equals stuff (thanks for that by the way) I'm all for it :v:

Adbot
ADBOT LOVES YOU

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


ok i looked up resharper and why the hell doesn't our team have resharper :mad:

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply