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
Inverness
Feb 4, 2009

Fully configurable personal assistant.
I'm looking into MEF and getting pretty confused with the versioning.

I'm seeing things that say MEF came with .NET 4 and MEF 2 comes with .NET 4.5, but I also see the MEF 2 NuGet package which contains a portable implementation.

Is this a case of having the "full" MEF 2 with .NET 4.5 and a lightweight MEF 2 subset on NuGet?

Adbot
ADBOT LOVES YOU

RICHUNCLEPENNYBAGS
Dec 21, 2010

22 Eargesplitten posted:

I read the OP, I see Skeet and Richter recommended for books. I'm used to Java and C++, with somewhere between an undergrad sophomore and junior level of understanding. So I don't need to have the difference between a parent class and an interface explained to me. But I still need something aimed at a relatively low level. Which of the two would you recommend (or others)?

Skeet's book might be better? It's targeted at people who already know the basics.

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

epalm posted:

Mind if I steal this from you? Or, if I do it myself by setting SuspendExecutionStrategy to true/false in the constructor/dispose, is that all or is there more to it that you've stumbled across?

All yours. I'd have to go find the Azure project that we have have that Transaction wrapper in, but I don't remember there being too much happening in the constructor. I think we also had some code that changed some per-request settings in the data layer, but that was project specific.


C# in Depth is a top-notch book for anyone with a beginner or above grasp of C#. Highly recommended.

Bognar fucked around with this message at 15:00 on Mar 24, 2015

epswing
Nov 4, 2003

Soiled Meat

Bognar posted:

All yours.

Brilliant, sent you a PM. :allears:

When you find it, that's the email address to use.

Thanks!

Gul Banana
Nov 28, 2003

Inverness posted:

I'm looking into MEF and getting pretty confused with the versioning.

I'm seeing things that say MEF came with .NET 4 and MEF 2 comes with .NET 4.5, but I also see the MEF 2 NuGet package which contains a portable implementation.

Is this a case of having the "full" MEF 2 with .NET 4.5 and a lightweight MEF 2 subset on NuGet?

not quite; .NET 4 and 4.5 both have "MEF 1", although the 4.5 version has more features and bug fixes. "MEF 2", aka Microsoft.Composition, is the standalone package, which can also run on .net 4 and 4.5, as well as on system.runtime/PCL platforms.

MEF 2 isn't a subset so much as a rethink. it adds as well as removes features.

Drastic Actions
Apr 7, 2009

FUCK YOU!
GET PUMPED!
Nap Ghost
I downloaded the Windows 10 SDK and started screwing around with it.





And that's basically all I have. It does work on phones... kinda, but I'm having issues with my PCL storage library so I can't log in at the moment with the emulators. But it should have nearly the same interface across the two devices. They are getting rid of the split projects and instead are pushing more adaptable ux controls.

Inverness
Feb 4, 2009

Fully configurable personal assistant.
It's pretty funny to see updates on various MSDN blogs and have one of the first comments be a link pointing out the XNA 5 voting page with over 20k votes.

I guess Microsoft is just going to keep pretending it doesn't exist.

The least they could do is open source XNA 4 so that the MonoGame people could benefit.

TheEffect
Aug 12, 2013
Newbie question here, but how come this won't work for me?

code:
If (((pushFileSelectCheckBox1.Enabled = True) & (pushFileSelectCheckBox2.Enabled = True) & 
(pushFileSelectCheckBox3.Enabled = True) & (pushFileSelectCheckBox4.Enabled = True)) = True) Then
I get a runtime error saying that "True,False,False,False" can't be converted to type Boolean, but I thought what I was doing there is seeing if they are all true, and if so, the whole if statement would be true?

I've been reading up on the solution/ links posted here but can't seem to get it to work no matter what I do.

tunah posted:

Remember to call Dispose on the icon when your application is exiting.

Actually, I'm already calling it before the exit button is clicked. Should it be elsewhere?

code:
    Private Sub exitBTN_Click(sender As Object, e As EventArgs) Handles exitBTN.Click
        LogOutput(DateStamp() + " " + TimeStamp() + ": - Terminating Application.")
        trayIcon.Dispose()
        Me.Close()
    End Sub
Edit- Broke tables.


VVV That looks amazing! VVV

TheEffect fucked around with this message at 16:38 on Mar 25, 2015

Drastic Actions
Apr 7, 2009

FUCK YOU!
GET PUMPED!
Nap Ghost
More Windows 10 SDK stuff:









raminasi
Jan 25, 2005

a last drink with no ice

TheEffect posted:

Newbie question here, but how come this won't work for me?

code:
If (((pushFileSelectCheckBox1.Enabled = True) & (pushFileSelectCheckBox2.Enabled = True) & 
(pushFileSelectCheckBox3.Enabled = True) & (pushFileSelectCheckBox4.Enabled = True)) = True) Then
I get a runtime error saying that "True,False,False,False" can't be converted to type Boolean, but I thought what I was doing there is seeing if they are all true, and if so, moving on with the code.

I've been reading up on the solution/ links posted here but can't seem to get it to work no matter what I do.


Thanks for the tip!

Edit- Broke tables.


VVV That looks amazing! VVV

& is a string concatenation operator in VB.NET. Did you mean to use AndAlso?

Inverness
Feb 4, 2009

Fully configurable personal assistant.
That looks great.

Except for the lack of padding around text which makes me :emo:

TheEffect
Aug 12, 2013

GrumpyDoctor posted:

& is a string concatenation operator in VB.NET. Did you mean to use AndAlso?

I have no formal VB.Net training, only C++ and very little at that. That was exactly what was needed. Thank you!!!

Inverness
Feb 4, 2009

Fully configurable personal assistant.

TheEffect posted:

I have no formal VB.Net training, only C++ and very little at that. That was exactly what was needed. Thank you!!!
It's kind of important that you actually learn the basics of the language before trying to write it. Formal training isn't required. Go Google for a tutorial.

TheEffect
Aug 12, 2013
I'm kind of a "try it and break it until you figure it out" kind of guy. So far I'm almost nearly done with writing a fairly impressive, in my opinion, file push / file remove program that let's user's choose a file or a directory to push/remove and let's them specify where it should go, without any training in vb.net at all. I guess that's elementary for most of you guys but I'm kind of proud of myself. Although to be fair I should've Google'd around a bit more on that last question since the answer was so very simple, and an intro tutorial probably WOULD'VE covered something like that.

Edit- So on that note, for a slightly more advanced question, how come "My.Computer.FileSystem.CopyDirectory" doesn't copy the directory that's selected like MSDN implies, but rather the CONTENTS of said directory? How can I get around this?

TheEffect fucked around with this message at 00:49 on Mar 26, 2015

putin is a cunt
Apr 5, 2007

BOY DO I SURE ENJOY TRASH. THERE'S NOTHING MORE I LOVE THAN TO SIT DOWN IN FRONT OF THE BIG SCREEN AND EAT A BIIIIG STEAMY BOWL OF SHIT. WARNER BROS CAN COME OVER TO MY HOUSE AND ASSFUCK MY MOM WHILE I WATCH AND I WOULD CERTIFY IT FRESH, NO QUESTION
I've got a really, really basic question that is a bit about personal style perhaps, or best practice. If I have a method that's going to be used to say, update a person's details, what is the best approach: 1) include the details in the signature of the method as parameters OR 2) use some kind of an purpose-made object to hold all of the possible update fields?

1.
code:
public static void UpdatePerson(string given, string surname, string mobileNumber, DateTime birthDate)
{
    [...]
}
2.
code:
public static void UpdatePerson(int personId, UpdatePerson values)
{
    [...]
}
Obviously either way will work, but I assume there's a best practice around this? Maybe an approach I haven't considered?

Try not to get too hung up on my specific example's details, but more the general idea of whether there's a number of parameters that is just "too many" and you should refactor out the details you need into a class that can be populated and then sent as a parameter.

brap
Aug 23, 2004

Grimey Drawer

GrumpyDoctor posted:

& is a string concatenation operator in VB.NET. Did you mean to use AndAlso?

Hahahahaha how do people use this loving language

Essential
Aug 14, 2003

fleshweasel posted:

Hahahahaha how do people use this loving language

A lot of people (myself included) use vb.net. We're not weirdo's/idiots.

EssOEss
Oct 23, 2006
128-bit approved

The Wizard of Poz posted:

I've got a really, really basic question that is a bit about personal style perhaps, or best practice. If I have a method that's going to be used to say, update a person's details, what is the best approach: 1) include the details in the signature of the method as parameters OR 2) use some kind of an purpose-made object to hold all of the possible update fields?

1.
code:
public static void UpdatePerson(string given, string surname, string mobileNumber, DateTime birthDate)
{
    [...]
}
2.
code:
public static void UpdatePerson(int personId, UpdatePerson values)
{
    [...]
}
Obviously either way will work, but I assume there's a best practice around this? Maybe an approach I haven't considered?

Yes, the second approach is something most developers tend to naturally discover at some point in their programming life. It makes many scenarios easier and all calls do not necessarily need to be changed just if the fields on the object change, which is nice. It also enables polymorphic behavior - maybe at some point you will want to provide a UpdateLegalPerson structure that subclasses the basic UpdatePerson structure. There are some downsides, though - if you add properties to this object but forget to update the call sites or the method contents, you could have asymmetry in data production and consumption. But the tradeoff is generally worth it for anything nontrivial.

At the end of the day, such design decisions need to be handled on a case-by-case basis, taking into considerating not only the code but also the purpose of the code and its foreseeable future evolution and maintenance. Both approaches are valid, certainly.

Funking Giblet
Jun 28, 2004

Jiglightful!

The Wizard of Poz posted:

I've got a really, really basic question that is a bit about personal style perhaps, or best practice. If I have a method that's going to be used to say, update a person's details, what is the best approach: 1) include the details in the signature of the method as parameters OR 2) use some kind of an purpose-made object to hold all of the possible update fields?

1.
code:
public static void UpdatePerson(string given, string surname, string mobileNumber, DateTime birthDate)
{
    [...]
}
2.
code:
public static void UpdatePerson(int personId, UpdatePerson values)
{
    [...]
}
Obviously either way will work, but I assume there's a best practice around this? Maybe an approach I haven't considered?

Try not to get too hung up on my specific example's details, but more the general idea of whether there's a number of parameters that is just "too many" and you should refactor out the details you need into a class that can be populated and then sent as a parameter.

Second one, just make sure you are using a dedicated viewmodel for updates, and not a model that might expose some fields you don't want updated as it may be possible is certain circumstances to update them (bad automapper usage etc).

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

The Wizard of Poz posted:

I've got a really, really basic question that is a bit about personal style perhaps, or best practice. If I have a method that's going to be used to say, update a person's details, what is the best approach: 1) include the details in the signature of the method as parameters OR 2) use some kind of an purpose-made object to hold all of the possible update fields?

I used to use #2 a lot, but I mostly just stick to long method signatures now. The main reason is to reduce errors when coming back and updating the method.

If you need to add a parameter to a method but you're using a parameter object, you have to find all of the places you're the parameter object to update it to add the new parameter. This is error-prone since there's no guarantee you'll actually change all of the usages. However, if all of your parameters are explicit in the method, the compiler won't let you build until you fix every single one.

The usual counter-argument to this that I hear is that you can make the parameters required in the constructor of the parameter object. To me it seems like you've just moved the problem from the method call to the parameter object constructor at that point, but this approach can be useful if you're passing a lot of the same information down to other methods.

EssOEss posted:

At the end of the day, such design decisions need to be handled on a case-by-case basis, taking into considerating not only the code but also the purpose of the code and its foreseeable future evolution and maintenance. Both approaches are valid, certainly.

Also this.

LiterallyAnything
Jul 11, 2008

by vyelkin
Say I wanted to get a string of all characters at the end of a path starting with "\" and going until the end. I'm looking at the string functions and can't find any easy way of doing this. Could anyone offer a hint?

Edit- I guess I would use Split() and return the last element of the array?

Nope- "One dimensional array of 'String' cannot be converted to 'String'.

LiterallyAnything fucked around with this message at 16:54 on Mar 26, 2015

zokie
Feb 13, 2006

Out of many, Sweden

Brady posted:

Say I wanted to get a string of all characters at the end of a path starting with "\" and going until the end. I'm looking at the string functions and can't find any easy way of doing this. Could anyone offer a hint?

Edit- I guess I would use Split() and return the last element of the array?

Something like this?

code:
var s = "farts/butts/foos";
var c = '/';
var afterC = s.Substring(s.IndexOf(c));

LiterallyAnything
Jul 11, 2008

by vyelkin

zokie posted:

Something like this?

code:
var s = "farts/butts/foos";
var c = '/';
var afterC = s.Substring(s.IndexOf(c));

That's returning everything after the first "\". :(

zokie
Feb 13, 2006

Out of many, Sweden
I thought that was what you wanted...

GI_Clutch
Aug 22, 2000

by Fluffdaddy
Dinosaur Gum

Brady posted:

Say I wanted to get a string of all characters at the end of a path starting with "\" and going until the end. I'm looking at the string functions and can't find any easy way of doing this. Could anyone offer a hint?

Edit- I guess I would use Split() and return the last element of the array?

Nope- "One dimensional array of 'String' cannot be converted to 'String'.

This works for me and returns "\file.txt"

code:
string path = @"C:\path\to\my\file.txt";
string[] stuff = path.Split('\\');
string fileName = "\\" + stuff[stuff.Length-1];
Do that instead. I always forget there are dozens of methods like that built in.
VVVVVVVVV

GI_Clutch fucked around with this message at 17:20 on Mar 26, 2015

Scuzzywuffit
Feb 5, 2012

Can you use Path.GetFileName?

LiterallyAnything
Jul 11, 2008

by vyelkin

Will this work if it's not a file, but a directory instead? Unable to test right this moment but I'm gonna try this and GI_Clutch's solution when I can. Thanks guys.

No Safe Word
Feb 26, 2005

Brady posted:

Will this work if it's not a file, but a directory instead? Unable to test right this moment but I'm gonna try this and GI_Clutch's solution when I can. Thanks guys.

The docs explicitly state that you get an empty string if it's a directory.

GI_Clutch
Aug 22, 2000

by Fluffdaddy
Dinosaur Gum
Yes. It appears to just grab everything after the final slash. It doesn't even need to be a valid path or anything. You can throw anything you want at it and it just grabs the last thing.
code:
string butt = @"butts\farts\)#( *$&#& ^#& ^@ &^#^&# ^&\foldername";
Console.WriteLine(Path.GetFileName(butt));
Will return "foldername" even though that path is invalid as all get out. There's also Path.GetDirectoryName which will return everything before the final slash in case you ever need that.

Scuzzywuffit
Feb 5, 2012

No Safe Word posted:

The docs explicitly state that you get an empty string if it's a directory.

I think that's talking about the "directory or volume separator character", which I'm assuming means '\' or ':'. It should work even without a file extension, since I think it's technically legal to have a file without an extension.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

TheEffect posted:

I have no formal VB.Net training, only C++ and very little at that. That was exactly what was needed. Thank you!!!

Off the top of my head the &/&&/AndAlso and |/||/OrElse are probably the two biggest 'gotchas' about VB.net as compared to how other languages work. Actually bitwise operators too have a few quirks, maybe brain up on them:
https://msdn.microsoft.com/en-us/library/wz3k228a.aspx

The other big change is how variable declaration is done, but that's mostly syntactical and you probably won't even run into it unless you're doing a bunch of List (of or LINQ style one line statements.

Dr. Poz
Sep 8, 2003

Dr. Poz just diagnosed you with a serious case of being a pussy. Now get back out there and hit them till you can't remember your kid's name.

Pillbug

Brady posted:

Say I wanted to get a string of all characters at the end of a path starting with "\" and going until the end. I'm looking at the string functions and can't find any easy way of doing this. Could anyone offer a hint?

Edit- I guess I would use Split() and return the last element of the array?

Nope- "One dimensional array of 'String' cannot be converted to 'String'.

You don't really say what this is for, but since other's were going with directory/file examples, maybe this is what you're looking for?

code:
Directory.GetFiles(@"c:\test\").Select(Path.GetFileName)
If that's not right, can you give us some example input data and your expected result?

Mongolian Queef
May 6, 2004

I'm looking for some help regarding shared projects.
Here's how our Subversion repository is laid out:

/tags
/branches
/trunk
Shared1
Shared2
Shared3
Product1
Product2
Product3
Product4
...
Product9

The Solution file for each product has project references to the shared libraries (..\..\Shared1\Shared1.csproj and similar).
Right now, if we build Project9, it will always reference the very latest of all shared libraries.
We sometimes create a tag for the entire trunk when releasing a version, but usually the product executable is given a version string containing the revision of trunk it was built from.
We don't fix old versions. If there is a bug to be fixed, it will be fixed in the next build and the customer will upgrade to the latest version. This has been working just fine, but we need to make changes due to ISO certification.
So here's where I would like to hear any opinions. A solution containing all projects needed to build is great, in my opinion. But let's say we now need to run much more QA before releasing a new build.
Product1 will want to reference a shared library at a specific revision, not the very latest.
Maybe we should build nuget packages of all the shared libraries?
What happens if we want to step into code which is in one of the shared libraries, can the source code be included in the nuget package?
Won't it be really tiresome to fix a bug in a shared lib if we no longer use project references?

And if we want to keep using project references, maybe we should choose another layout for the repository.
Where each project/library has tags, branches and trunk.
Like this:
Product1.sln
..\..\Shared1\tag\1.0\Shared1.csproj (or similar)
..\..\Shared2\tag\1.3\Shared2.csproj (or similar)
But then, building Product1 for the first time will require going into each shared project and making sure we get the tag that the solution references.

Sorry for this wall of text. We are trying to come up with how we want things to work in the future but none of us have experience with this.

ljw1004
Jan 18, 2005

rum

tunah posted:

What happens if we want to step into code which is in one of the shared libraries, can the source code be included in the nuget package?

The way we have it set up within the VB/C# team at Microsoft is that, for each binary DLL, we upload its symbols to our company's internal symbol server. Also the symbols contain a TFS command to fetch the source. That way VS can automatically pull up the correct symbols, and can automatically pull up the correct source code. (I have no idea how this magic is accomplished...)

By the way, I've not seen it done with NuGet, but my first thought reading your post was "Use NuGet!". It seems like the best way to represent a dependency on a specific version of a DLL.

...

The way we do it is that each "independently maintained release" has its own branch in source control. Thus, Visual Studio 2013 RTM / Update1 / Update2 / Update3 go in branch called "D12Rel", and Visual Studio 2015 RTM will eventually go in a branch "D14Rel", and VS2015 CTP1 through CTP6 were all versions along the way in a single branch called "DP14". (If there's a bug in VS2013 then we can tell customers to upgrade to the latest VS2013 update, which is why VS2013 and all its updates go in just one branch: Update1 doesn't need its own branch, for instance. But we can't tell them all to upgrade to VS2015 which is why VS2013 has to be kept in its own branch).

We actually have large enough teams that each shared library (or set of libraries) has its own similar branch structure. Thus, the Roslyn team (VB/C# compilers) have one branch for the version of Roslyn that will go into VS2015RTM, and another branch for the latest ongoing development. That way, the main product branch DP14 / D12Rel / D14Rel doesn't need its own copies of the Roslyn source code. It merely gets "FCIBs", "Foreign Checked In Binaries", where we copy the output DLLs from the Roslyn branch into a folder called "ExternalAPIs" in the main product.


quote:

Won't it be really tiresome to fix a bug in a shared lib if we no longer use project references?

Yeah, I guess. But it's a fact of life. If you need to independently service old versions of your product (rather than just telling customers to buy the newest version), then you have to make it harder on yourself. So: if we really needed to fix a bug in an old release of our product, we'd sync up to the latest version in the branch for that release. And if it was a bug in the VB/C# compilers, then we'd also need to sync up to the appropriate version of the Roslyn source code.

We don't have one "canonical" .sln file. A developer working on one bug might have a SLN which includes a hodge-podge of related projects.

Destroyenator
Dec 27, 2004

Don't ask me lady, I live in beer
What is your ideal/required process for versioning and QA?

Adhemar
Jan 21, 2004

Kellner, da ist ein scheussliches Biest in meiner Suppe.
NuGet is one of those typical Microsoft "I will do magical poo poo behind the scenes for you but not tell you what I did so if you have even one person in your team who is not anal retentive OCD*, you will be in a world of poo poo in no time." technologies. Works great 99% of the time but that 1% of the time you're spending a day forced to figure out what it did which defeats the purpose of using it. It's probably nice for pulling in 3rd party libs but I wouldn't recommend it for your own stuff (we tried). Also if you can show me how to set up this symbol server magic quickly I'll blow you. I've never gotten that to work rebliably in a reasonable amount of time spent.

Keep it simple, use externals if you're on svn or otherwise its equivalent (I hear git sucks for this, sorry!). Only release from tags and with all externals pointing to tags. Use commit hooks to enforce this if possible.

*I'm bitter because I'm the OCD guy who gets to clean up the mess.

RICHUNCLEPENNYBAGS
Dec 21, 2010
I'm using nuget for internal package management and I like it. There's some cloud service that offers the servers for you; I forget what it's called. Just write a script to make a package, IMO.

Gul Banana
Nov 28, 2003

nuget is not magic and you will waste more and more time if you refuse to use it, since everything's coming to rely on it

maintaining build scripts and nuspec files requires at most a small chunk of one engineers time. setting up a symbol server took us about a day and it works consistently

crashdome
Jun 28, 2011

Adhemar posted:

NuGet is one of those typical Microsoft "I will do magical poo poo behind the scenes for you but not tell you what I did so if you have even one person in your team who is not anal retentive OCD*, you will be in a world of poo poo in no time." technologies. Works great 99% of the time but that 1% of the time you're spending a day forced to figure out what it did which defeats the purpose of using it. It's probably nice for pulling in 3rd party libs but I wouldn't recommend it for your own stuff (we tried). Also if you can show me how to set up this symbol server magic quickly I'll blow you. I've never gotten that to work rebliably in a reasonable amount of time spent.

Keep it simple, use externals if you're on svn or otherwise its equivalent (I hear git sucks for this, sorry!). Only release from tags and with all externals pointing to tags. Use commit hooks to enforce this if possible.

*I'm bitter because I'm the OCD guy who gets to clean up the mess.

Ha! 1% only? Only a day to fix a mess? Sounds much better than all the years I've spent not using it to me.

Adbot
ADBOT LOVES YOU

Boz0r
Sep 7, 2006
The Rocketship in action.
Is there somewhere I can find a tutorial for making a generic shop website in C# .NET MVC with a database?

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