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
Space Whale
Nov 6, 2014
edit is not quote

Adbot
ADBOT LOVES YOU

GoodCleanFun
Jan 28, 2004

Ciaphas posted:

Is there a "right" way to open new views in MVVM? In a possibly ill-advised attempt to avoid controlling views from a viewmodel directly, I cobbled together something like this. Is it kind of the right way to go about it?

See my post here for a very clean approach: http://forums.somethingawful.com/showthread.php?threadid=3644791&pagenumber=61&perpage=40#post442712636

Inverness
Feb 4, 2009

Fully configurable personal assistant.

Ithaqua posted:

That starts to fall apart when the using block doesn't coincide with the end of the method.

...

You actually want the first stream to be disposed in this case, so it can open a new stream to the same file. It seems like it's saving you a few levels of indentation at the cost of explicitness and readability, which I generally don't like.
Well no, it doesn't fall apart because like C++, C# lets you create your own blocks:
C# code:
private void MyMethod()
{
    using new ScopedTimer(_fileTimer);
    _tryCount++;

    {
        using var stream = File.OpenRead(_fileName);
        stream.DoSomething();
        _successCount++;
    }

    {
        using var anotherStream = File.OpenRead(_fileName);
        anotherStream.DoSomething();
        _successCount++;
    }
}
That lets you be quite explicit about when something would go out of scope and be disposed.

ljw1004 posted:

I think the difference is that in C++ doesn't have GC, so every single blasted resource has to be disposed of, which is why they made the idiom so easy to use -- at the cost of it being implicit+invisible.

C# does have GC, so you only use the "using" pattern for heavyweight resources where you want to manually be fully aware and in control of disposing of those resources. So an implicit+invisible way to call Dispose would defeat the point.
That makes more sense. I find though that the using statement makes it desirable to take advantage of the functionality for other things like the aforementioned timing/logging. I don't have many examples on that front though.

Inverness fucked around with this message at 23:08 on May 7, 2015

crashdome
Jun 28, 2011

Ciaphas posted:

Is there a "right" way to open new views in MVVM? In a possibly ill-advised attempt to avoid controlling views from a viewmodel directly, I cobbled together something like this. Is it kind of the right way to go about it?

XML code:
<!-- main window, datacontext is viewmodel -->
<Button Content="Open Sub-window" Command="{Binding OpenSubWindowCommand}"/>
C# code:
interface IWindowService // everything's an object because maybe a test harness view wouldn't use System.Windows.Window???
{
  object OpenWindow(object window);
  bool FocusWindow(object window);
  bool CloseWindow(object window);
}

class WindowService : IWindowService
{
  object OpenWindow(object window)
  {
    // type checks here
    if (window as string == "SubWindow")
    {
      System.Windows.Window w = new Window();
      w.Show();
      return w;
    }
  }
  bool FocusWindow(object window) { return (window as Window).Focus(); }
  bool CloseWindow(object window) { (window as Window).Close(); return true; }
}

class MainWindowViewModel : IDisposable
{
  private IWindowService _MyWindowService; // set in ctor
  public RelayCommand OpenSubWindowCommand = new RelayCommand(x=>OpenSubWindow());

  private object _SubWindow;
  private void OpenSubWindow()
  {
    _SubWindow = _MyWindowService.OpenWindow("SubWindow");
  } 
  
  private void FocusSubWindow() // pretend I had the command etc for this too
  {
    if (_SubWindow != null) _MyWindowService.FocusWindow(_SubWindow);
  }

  public void Dispose()
  {
    if (_SubWindow != null) MyWindowService.CloseWindow(_SubWindow);
  }
}

I do something similar. I call mine WpfWindowManager and forego the interface as its explicitly for use only with Wpf views. Although you could try and make an interface to encapsulate different platforms if you want.

Also make it static. I maintain a list of valid views in a servicelocator so the vm calling OpenLogin or whatever in the svclocator. The servicelocator then calls wpfwindowmanager which constructs the appropriate window based on the view registered.

Edit: Oops skipped past Good Cleans post... That is a great example.

crashdome fucked around with this message at 00:31 on May 8, 2015

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:




crashdome posted:

I do something similar. I call mine WpfWindowManager and forego the interface as its explicitly for use only with Wpf views. Although you could try and make an interface to encapsulate different platforms if you want.

Also make it static. I maintain a list of valid views in a servicelocator so the vm calling OpenLogin or whatever in the svclocator. The servicelocator then calls wpfwindowmanager which constructs the appropriate window based on the view registered.

Edit: Oops skipped past Good Cleans post... That is a great example.

Thank you both, I'll give GoodCleanFun's code a lookover and work it out from there. :)

Gul Banana
Nov 28, 2003

man, i want higher-kinded delegates

how cool would it be to be able to implement this interface:
code:
interface IFoo {
    Foo<T>();
}
with this closure-accepting impl:
code:
class DelegateFoo: IFoo {
  private Action<<T>> f;
  public DelegateFoo(Action<<T>> f) {
    this.f = f;
  }

  public Foo<T>() {
    f();
  }
}
where <<T>> is hypothetical syntax for a parameterised type constructor.

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy
Your code is confusing to me, but I think I get what you're saying. Somewhat related to that, I've always wished for static interface methods (which could also include constructor signatures). That would let you do things like:

C# code:
public interface IParseable<T>
{
    static T Parse(string s);
    static bool TryParse(string s, out T result);
}

...
// maybe in a parser somewhere

public T MyParse<T>(string s) where T : IParseable<T>
{
    T val;
    if (T.TryParse(s, out val))
        return val;

    _errors.Add("Could not parse " + s + "into type " typeof(T));
    // additional error logic
    return default(T);
}

public void MyMethod()
{
    var num = MyParse<int>("123");
    var date = MyParse<DateTime>("1-1-2015");
    var fail = MyParse<double>("hello");
}
Obviously the BCL would have to change to support something like that with TryParse, but it gets the idea across.

More abstractly, you could also do this:

C# code:
public interface IMonad<T>
{
    static IMonad<T> Return<T>(T val);
    IMonad<R> Bind<T, R>(Func<T, IMonad<R>> func);
}

Inverness
Feb 4, 2009

Fully configurable personal assistant.
So it seems most of the features in Productivity Power Tools 2013 still work in 2015. :dance:

You have to extract and edit the extension.vsixmanifest file to make it support Visual Studio 14.0 instead of 12.0. And also remove/comment-out content references for: Fix Mixed Tabs, Column Guides, Go to Definition Click, and Solution Error Filter. You'll also need to delete the files for those components from the extension. Once that is done you can zip the file back up as a vsix and then install it.

Also the page for turning various parts on and off crashes when you try to press OK so you'll also need to disable whatever parts you don't want by commenting out their lines in the vsixmanifest. You don't need to delete their files in this case though, and you can do this at any time by editing the manifest after its been installed in %LOCALAPPDATA%\Microsoft\VisualStudio\14.0\Extensions\.

Inverness fucked around with this message at 22:54 on May 8, 2015

EssOEss
Oct 23, 2006
128-bit approved
There was a lot of buzz about TFS Build vNext supporting Linux but I can't find any build agent binaries to actually install anywhere. Am I missing something?

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

EssOEss posted:

There was a lot of buzz about TFS Build vNext supporting Linux but I can't find any build agent binaries to actually install anywhere. Am I missing something?

It's a Node program, grab it from npm.

https://github.com/Microsoft/vso-agent

You also have to set up basic Auth on the TFS server so the agent can authenticate. Not sure if they will make it easier at RTM.

New Yorp New Yorp fucked around with this message at 18:14 on May 8, 2015

RICHUNCLEPENNYBAGS
Dec 21, 2010

Gul Banana posted:

man, i want higher-kinded delegates

how cool would it be to be able to implement this interface:
code:
interface IFoo {
    Foo<T>();
}
with this closure-accepting impl:
code:
class DelegateFoo: IFoo {
  private Action<<T>> f;
  public DelegateFoo(Action<<T>> f) {
    this.f = f;
  }

  public Foo<T>() {
    f();
  }
}
where <<T>> is hypothetical syntax for a parameterised type constructor.

Call me stupid but what are you getting here that you don't get with abstract classes and protected members?

Captain Capacitor
Jan 21, 2008

The code you say?

EssOEss posted:

Azure is a cloud platform that can be used for hosting web applications (and other types of server-side applications) and which provides various pre-existing services. It does not change the way you develop software unless you wish to integrate those pre-existing services it offers. If you need to make a REST web service then make a REST web service. Yes, you can easily host it in Azure. And you can easily host it elsewhere.

It may be possible to share further advice if you provide more details about what you need to accomplish.

Unless you're using something like Mobile services, which lets you define resources for a REST endpoint and some simple code to handle the actions.

Gul Banana
Nov 28, 2003

RICHUNCLEPENNYBAGS posted:

Call me stupid but what are you getting here that you don't get with abstract classes and protected members?

abstract classes don't let you write an inline closure either. here's the general use case for Delegate____ impls:

C# code:
    class FormulaTester
    {
        public void Test(IFormula f)
        {
            for (int i = 0; i < 10; i++)
            {
                Console.WriteLine("{0}({1}): {2}", f.Name, i, f.Calculate(i));
            }
        }
    }

    interface IFormula
    {
        string Name { get; }
        int Calculate(int i);
    }

    class DelegateFormula : IFormula
    {
        private string n;
        private Func<int, int> f;

        public DelegateFormula(string n, Func<int,int> f)
        {
            this.n = n;
            this.f = f;
        }

        public string Name
        {
            get { return n; }
        }

        public int Calculate(int i)
        {
            return f(i);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            var tester = new FormulaTester();

            var changeAmount = 1;
            tester.Test(new DelegateFormula("inc", x => x + changeAmount));
            tester.Test(new DelegateFormula("dec", x => x - changeAmount));
            tester.Test(new DelegateFormula("const", x => changeAmount));

            Console.ReadKey();
        }
    }
they let you write multiple concise implementations with access to local data via closures.

now, what happens if i want to add a type parameter? let's say that IFormulas can operate on a T instead of an int? still works:
C# code:
    class FormulaTester
    {
        public void Test<T>(IFormula<T> f, T[] testdata)
        {
            foreach (var datum in testdata)
            {
                Console.WriteLine("{0}({1}): {2}", f.Name, datum, f.Calculate(datum));
            }
        }
    }

    interface IFormula<T>
    {
        string Name { get; }
        T Calculate(T i);
    }

    class DelegateFormula<T> : IFormula<T>
    {
        private string n;
        private Func<T, T> f;

        public DelegateFormula(string n, Func<T,T> f)
        {
            this.n = n;
            this.f = f;
        }

        public string Name
        {
            get { return n; }
        }

        public T Calculate(T x)
        {
            return f(x);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            var tester = new FormulaTester();
            var data = new[]{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

            var changeAmount = 1;
            tester.Test(new DelegateFormula<int>("inc", x => x + changeAmount), data);
            tester.Test(new DelegateFormula<int>("dec", x => x - changeAmount), data);
            tester.Test(new DelegateFormula<int>("const", x => changeAmount), data);

            Console.ReadKey();
        }
    }

Gul Banana fucked around with this message at 09:12 on May 11, 2015

Gul Banana
Nov 28, 2003

so those are the basics. now we want something fancy. i want programmable swapping/locking strategies, using generics; i'm going to have the tester supply inputs and print whichever one comes back. i can do that for concrete implementations:
C# code:
    class Box<T>
    {
        public T x {get; set;}

        public override string ToString()
        {
            return x.ToString();
        }
    }

    class FormulaTester
    {
        public void Test(IConcurrentFormula f)
        {
            var i0 = new Box<int> { x = 0 }; var i1 = new Box<int> { x = 1 };
            Console.WriteLine("{0}(0, 1): {1}", f.Name, f.Calculate(i0, i1));
            Console.WriteLine("{0}(1, 1): {1}", f.Name, f.Calculate(i1, i1));

            var d0 = new Box<double> { x = 0 }; var d1 = new Box<double> { x = 0 };
            Console.WriteLine("{0}(0.0, 1.0): {1}", f.Name, f.Calculate(d0, d1));
            Console.WriteLine("{0}(1.0, 1.0): {1}", f.Name, f.Calculate(d1, d1));

            var c0 = new Box<char> { x = '0' }; var c1 = new Box<char> { x = '1' };
            Console.WriteLine("{0}('0', '1'): {1}", f.Name, f.Calculate(i0, i1));
            Console.WriteLine("{0}('1', '1'): {1}", f.Name, f.Calculate(i1, i1));
        }
    }

    interface IConcurrentFormula
    {
        string Name { get; }
        T Calculate<T>(T left, T right) where T:class;
    }

    class SwapFormula : IConcurrentFormula
    {
        public string Name
        {
            get { return "swap"; }
        }

        public T Calculate<T>(T left, T right) where T : class
        {
            return Interlocked.Exchange(ref left, right);
        }
    }

    class CompareAndSwapFormula : IConcurrentFormula
    {
        public string Name
        {
            get { return "cas"; }
        }

        public T Calculate<T>(T left, T right) where T : class
        {
            Interlocked.CompareExchange<T>(ref left, default(T), right);
            return left;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            var tester = new FormulaTester();
            
            tester.Test(new SwapFormula());
            tester.Test(new CompareAndSwapFormula());

            Console.ReadKey();
        }
    }
but... how do we write DelegateConcurrentFormula? it looks something like this:
C# code:
    class DelegateConcurrentFormula : IConcurrentFormula
    {
        private string n;
        private ??? f;

        public DelegateFormula(string n, ??? f)
        {
            this.n = n;
            this.f = f;
        }

        public string Name
        {
            get { return n; }
        }

        public T Calculate<T>(T left, T right) where T : class
        {
 	        return f<T>(left, right);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            var tester = new FormulaTester();
            
            tester.Test(new DelegateConcurrentFormula("swap", (left, right) => Interlocked.Exchange(ref left, right)));
            tester.Test(new DelegateConcurrentFormula("cas", (left, right) => Interlocked.CompareExchange(ref left, right, right)));

            Console.ReadKey();
        }
    }
there's no actual type you can write for f. hypothetically it would be something like Func<T><T>, that is, the type of a function which has a type parameter T and which returns a value of that type T. this is a "rank 2" or "higher-kinded" type, and it doesn't exist on the CLR.

Gul Banana fucked around with this message at 09:12 on May 11, 2015

ljw1004
Jan 18, 2005

rum

Gul Banana posted:

so those are the basics. now we want something fancy. i want programmable swapping/locking strategies, using generics; i'm going to have the tester supply inputs and print whichever one comes back.

I like the way you wrote that out and built up reasonable cases. My thoughts:

A instance of a delegate is basically an instance of a class with a method on it -- and that's how it's implemented under the hood -- but with the limitation you describe about generics.

Option 1 is to introduce higher-order types to the language and to the CLR, so that field "f" would be a higher order delegate type.

Option 2 is just to ask coders to write it out longhand, as you have done, and field "f" can be of type IConcurrentFormula.

All round, Option2 seems the nicer choice! More in keeping with object oriented design! and a much simpler language!



My other thought is that the job of the type-system is to help catch errors at compile-time rather than at runtime. For instance, the current effort by the VB/C# language design team to bring in "nullable types" and "non-nullable types" into the type system is a way to reduce the number of times that folks get NullReferenceExceptions and ArgumentNullExceptions at runtime. But it's always a tradeoff, and you can live in a more type-heavy world or a less type-heavy world.

In that light, question what a higher-order delegate actually means. A instance of a higher-order delegate Func<<T>><T,T> would be an instance that, for any type "T", it can take in an object of type "T" and will return one of type "T". There already exists this concept in object-oriented languages: Func<object,object>. This will work for any type "T", and will take in an object of that type, and can return one. You don't get the compile-time enforcement that an InvalidCastException won't occur at runtime, but in most cases you'd detect and eliminate such errors very early in your unit tests.



Incidentally, why define your own "Box" type rather than using the "StrongBox" type in .NET ?

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.
I'm about to start a pretty ambitious project and try to deliver something in a small turn around time. I wanted to possibly use the 2015 RC. Anyone have any thoughts or opinions (based on previous RC -> RTM versions) how things would go? Anything that I need to know installing the RC side by side with 2013?

ljw1004
Jan 18, 2005

rum

Uziel posted:

I'm about to start a pretty ambitious project and try to deliver something in a small turn around time. I wanted to possibly use the 2015 RC. Anyone have any thoughts or opinions (based on previous RC -> RTM versions) how things would go? Anything that I need to know installing the RC side by side with 2013?

You can use RC side-by-side with VS2013 perfectly fine.

I haven't had success uninstalling VS2015 RC. And I've had failures upgrading from previous CTPs to RC. So that makes me unconfident about upgrading from RC to RTM.

What I plan to do is wipe my machine entirely when VS2015 RTM comes out, and install whatever is the latest version of Windows 10 Insider at that point, and VS2015. [I should add the caveat that I'm in the VB/C# team at Microsoft, doing work on Win10 app development at the moment, so folks like me are used to paving and reinstalling our machines frequently...]

ljw1004 fucked around with this message at 00:56 on May 12, 2015

EssOEss
Oct 23, 2006
128-bit approved

Ithaqua posted:

It's a Node program, grab it from npm.

https://github.com/Microsoft/vso-agent

You also have to set up basic Auth on the TFS server so the agent can authenticate. Not sure if they will make it easier at RTM.

Thanks for the hint! Looks like it works pretty well once the initial setup is done. We have a few multiplatform projects cooking and this will definitely make our lives much easier.

The Windows build process is a tiny bit broken, though. I notice PowerShell is involved - always a sign of trouble!

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

EssOEss posted:

I notice PowerShell is involved - always a sign of trouble!

Not really... PowerShell is a pretty major part of the new build. At RTM (I believe, although don't quote me on that) you'll be able to upload custom tasks to the new build system, which are just JSON files describing the parameters, and scripts (PS1, batch file, bash, whatever).

The new release management system coming in Update 1 will be the same way. In fact, it will use the same task system.

Gul Banana
Nov 28, 2003

ljw1004 posted:

I like the way you wrote that out and built up reasonable cases. My thoughts:

A instance of a delegate is basically an instance of a class with a method on it -- and that's how it's implemented under the hood -- but with the limitation you describe about generics.

Option 1 is to introduce higher-order types to the language and to the CLR, so that field "f" would be a higher order delegate type.

Option 2 is just to ask coders to write it out longhand, as you have done, and field "f" can be of type IConcurrentFormula.

All round, Option2 seems the nicer choice! More in keeping with object oriented design! and a much simpler language!

Yeah, I don't realistically expect this feature to be added - at minimum there are other things that would benefit more people as well as being simpler. I just wanted to explain the concept, at least, without having to refer to Haskell type constructors :)

quote:

My other thought is that the job of the type-system is to help catch errors at compile-time rather than at runtime. For instance, the current effort by the VB/C# language design team to bring in "nullable types" and "non-nullable types" into the type system is a way to reduce the number of times that folks get NullReferenceExceptions and ArgumentNullExceptions at runtime. But it's always a tradeoff, and you can live in a more type-heavy world or a less type-heavy world.

In that light, question what a higher-order delegate actually means. A instance of a higher-order delegate Func<<T>><T,T> would be an instance that, for any type "T", it can take in an object of type "T" and will return one of type "T". There already exists this concept in object-oriented languages: Func<object,object>. This will work for any type "T", and will take in an object of that type, and can return one. You don't get the compile-time enforcement that an InvalidCastException won't occur at runtime, but in most cases you'd detect and eliminate such errors very early in your unit tests.

Actually, this doesn't cover my use case. See, the thing i was really trying to achieve is a 'generic visitor'. I have a set of types that all implement IThing (not actual name), and then an IThingInfo for each type- this is all backed by generated code. At runtime, we want to get the static type of a dynamically selected IThing impl, using its info. The mechanism I have for this is an interface IThingInfo.Visitor, similar to the usual visitor pattern but with a single Accept method which just calls Sub Visit(Of T As IThing)(). This means that we can then define a bunch of visitor implementations which, when visited, *receive the type parameter T* and go on to do more work with it.

The entire point is to recover type safety, and to gain access to apis like CreateThingListController(Of T As IThing)- so object or dynamic wouldn't help. However, this is all so esoteric that I didn't want to use it as the real example (although it is a real use case in heavily used code). What we do is write a bunch of SpecificActionTakingThingVisitor classes and wish occasionally that they could be inline.

quote:

Incidentally, why define your own "Box" type rather than using the "StrongBox" type in .NET ?
I didn't know about it :D
Looks like I should go poke around System.Runtime.CompilerServices someday!

Space Whale
Nov 6, 2014
So I'm trying to use a little boolean logic in newtonsoft's ShouldSerializePROPERTY methods to programmatically serialize a property in a class, or not.

code:
    public bool ShouldSerializeSystem()
        {
            return !isUpdate;
        }
However, both in terms of looking at the json firing away and stepping through this method, it doesn't return NOT isUpdate, it just returns what isUpdate is!

isUpdate is a property in the same class as System, and the ShouldSerializeSystem() method. I've tried researching this and even had some senior devs look this over, who now think I'm loving with them.

WTF is going on? :smith:

Note that the following works fine:
code:
            if (isUpdate)
                return false;
           return true;
            

raminasi
Jan 25, 2005

a last drink with no ice
Your computer has a gremlin, go work on something else for a day so it gets bored and leaves. (Seriously. Problems that bizarre, in my experience, are only ever solved by putting them down and only coming back once your brain has untied whatever knots it's put itself in.)

Newf
Feb 14, 2006
I appreciate hacky sack on a much deeper level than you.

Uziel posted:

I'm about to start a pretty ambitious project and try to deliver something in a small turn around time. I wanted to possibly use the 2015 RC. Anyone have any thoughts or opinions (based on previous RC -> RTM versions) how things would go? Anything that I need to know installing the RC side by side with 2013?

Unless there is some specific feature available in 2015 that will substantially reduce your workload, I think you should consider sticking with the familiar. The little gotchyas that are inevitable when moving to a new piece of software can add up quickly, and your own description of the protect suggests that you won't have a lot of wiggle room.

How will you be feeling when you've lost a second or third day's worth of work to some sort of build/deployment issues which (at least in your head) wouldn't have happened had you been working in 2013?

Space Whale
Nov 6, 2014

GrumpyDoctor posted:

Your computer has a gremlin, go work on something else for a day so it gets bored and leaves. (Seriously. Problems that bizarre, in my experience, are only ever solved by putting them down and only coming back once your brain has untied whatever knots it's put itself in.)

:downs: The API I was sending JSON to is just gone anyway!

Other divisions like to do one thing with servers and we do another, and nobody communicates, sooo suddenly one endpoint is gone and another is now pointing to production. :downsrim:

CapnAndy
Feb 27, 2004

Some teeth long for ripping, gleaming wet from black dog gums. So you keep your eyes closed at the end. You don't want to see such a mouth up close. before the bite, before its oblivion in the goring of your soft parts, the speckled lips will curl back in a whinny of excitement. You just know it.
I've discovered some code left by my predecessor that's just baffling to me; can anyone shed some light? Basically, I've got a program that, when it sees it's time for an update, closes itself and calls SelfUpdate.exe, which is in the same folder. SelfUpdate.exe goes and fetches the new files and extracts them. All that makes sense. And then I hit this:
code:
string[] args = Environment.GetCommandLineArgs();
get_file("Main file", args[1]);
Application.DoEvents();

System.Diagnostics.Process.Start(args[1]);
So he's obviously using the second command line argument to get the path of the original file. What I don't get is why. First off, why is he so sure that the second command line argument is always going to be the path of the file that called SelfUpdate? It clearly is -- this process works -- but this seems like a hell of a thing to grab blindly like that. Secondly, why's he doing this at all? SelfUpdate knows goddamn well where the original file is because they're in the same folder as each other, it is not hard to locate. My reaction is "this is bad code, rewrite it", but it's so outside anything I've seen before that I want to double-check that he's not actually being brilliant.

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy
How is SelfUpdate.exe being called in the original application? I assume it's passing in the executable path as the first argument.

In any case, it does seem a bit odd, since now it essentially means you can't change the name of your executable in an update. I would just change it to call the path it knows it downloaded to, like you said.

Bognar fucked around with this message at 18:28 on May 12, 2015

ljw1004
Jan 18, 2005

rum

CapnAndy posted:

First off, why is he so sure that the second command line argument is always going to be the path of the file that called SelfUpdate? It clearly is -- this process works -- but this seems like a hell of a thing to grab blindly like that. Secondly, why's he doing this at all? SelfUpdate knows goddamn well where the original file is because they're in the same folder as each other, it is not hard to locate.

I assume that he wrote a general-purpose "SelfUpdate.exe" program which can be used to update any executable. As long as it's passed the URL to download from, and the name of the EXE, then it should be agnostic (i.e. loosely coupled) to the calling program.

Inverness
Feb 4, 2009

Fully configurable personal assistant.

Space Whale posted:

So I'm trying to use a little boolean logic in newtonsoft's ShouldSerializePROPERTY methods to programmatically serialize a property in a class, or not.

code:
    public bool ShouldSerializeSystem()
        {
            return !isUpdate;
        }
However, both in terms of looking at the json firing away and stepping through this method, it doesn't return NOT isUpdate, it just returns what isUpdate is!

isUpdate is a property in the same class as System, and the ShouldSerializeSystem() method. I've tried researching this and even had some senior devs look this over, who now think I'm loving with them.

WTF is going on? :smith:

Note that the following works fine:
code:
            if (isUpdate)
                return false;
           return true;
            
Are you using the 2015 RC? This is strange enough that you could have some sort of compiler bug.

CapnAndy
Feb 27, 2004

Some teeth long for ripping, gleaming wet from black dog gums. So you keep your eyes closed at the end. You don't want to see such a mouth up close. before the bite, before its oblivion in the goring of your soft parts, the speckled lips will curl back in a whinny of excitement. You just know it.
He does pass the program the path, but the URL it downloads from is hardcoded.

ljw1004 posted:

I assume that he wrote a general-purpose "SelfUpdate.exe" program which can be used to update any executable. As long as it's passed the URL to download from, and the name of the EXE, then it should be agnostic (i.e. loosely coupled) to the calling program.
This is probably the truth anyway, I've uncovered the ruins of a couple other things that were clearly meant to be big deals but never got implemented and just stuck around as confusing code snippets prone to breaking stuff. Thanks.

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.

ljw1004 posted:

You can use RC side-by-side with VS2013 perfectly fine.

I haven't had success uninstalling VS2015 RC. And I've had failures upgrading from previous CTPs to RC. So that makes me unconfident about upgrading from RC to RTM.

What I plan to do is wipe my machine entirely when VS2015 RTM comes out, and install whatever is the latest version of Windows 10 Insider at that point, and VS2015. [I should add the caveat that I'm in the VB/C# team at Microsoft, doing work on Win10 app development at the moment, so folks like me are used to paving and reinstalling our machines frequently...]
Thanks, good to know! Lack of confidence upgrading plus the fact that it's likely that I'd be able to easily wipe my machine when the RTM is out means I'll probably wait for now.

Newf posted:

Unless there is some specific feature available in 2015 that will substantially reduce your workload, I think you should consider sticking with the familiar. The little gotchyas that are inevitable when moving to a new piece of software can add up quickly, and your own description of the protect suggests that you won't have a lot of wiggle room.

How will you be feeling when you've lost a second or third day's worth of work to some sort of build/deployment issues which (at least in your head) wouldn't have happened had you been working in 2013?
Good point, and I would likely blame those issues on the RC.

My main concern was that I normally never work with user accounts and for this particular project, I'm going to be going off this to tutorial: http://www.asp.net/mvc/overview/security/create-an-aspnet-mvc-5-app-with-facebook-and-google-oauth2-and-openid-sign-on to use the ASP.NET Identity stuff. Only going to be using Facebook and Google logins though, so I wasn't sure if this was improved in the next version of ASP.NET. I swear I read that it was, but I can't for the life of me find it.

Dietrich
Sep 11, 2001

ungh web development in vs 2015 is like learning a whole new tool set with Gulp and Bower.

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

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.)

Blasphemeral
Jul 26, 2012

Three mongrel men in exchange for a party member? I found that one in the Faustian Bargain Bin.

NihilCredo posted:

"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?"

"That's what I'm saying, Nihil; I asked him the same thing. It's like he doesn't know anything about negative flux tachyon streams! What did he do all those years at the academy?"

bobua
Mar 23, 2003
I'd trade it all for just a little more.

NihilCredo posted:


"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?"


I love this sentence.

Kekekela
Oct 28, 2004
code:
.TrimEnd('_');
Kind of freaked myself out when I looked up and realized I'd coded some kind of weird anime face this morning.

Space Whale
Nov 6, 2014

Kekekela posted:

code:
.TrimEnd('_');
Kind of freaked myself out when I looked up and realized I'd coded some kind of weird anime face this morning.

How are those wax tadpoles?

Calidus
Oct 31, 2011

Stand back I'm going to try science!
Could I split out my entity frame work edmx model and various classes into its own project and use that project in multiple solutions? How would that work with config files? I would like to be able to refuse my entity model from my MVC site on a couple of desktop solutions.

Faldoncow
Jun 29, 2007
Munchin' on some steak

Calidus posted:

Could I split out my entity frame work edmx model and various classes into its own project and use that project in multiple solutions? How would that work with config files? I would like to be able to refuse my entity model from my MVC site on a couple of desktop solutions.

I'm doing this right now, where I have my database-first EF model in a class library and am using it as a reference in a couple of other projects. There may be a better way, but so far all I've had to do is copy the connection string to the app/web.config of my other projects. I haven't run into any major problems so far.

crashdome
Jun 28, 2011
I'm just posting to confirm I also do the above. Only copy the connection string and add the reference.

Adbot
ADBOT LOVES YOU

Milotic
Mar 4, 2009

9CL apologist
Slippery Tilde
Is the only easy-ish solution for a machine global 'mutex' which protects access to async code by using database transactions for acquiring exclusivity? Since async code isn't guaranteed to be re-entrant on the same thread, you'll blow up when you release the Mutex after the async code. The only alternative that springs to mind is a class which pins a mutex to a thread, and uses message passing to marshal calls to acquire/release the mutex onto that thread. That just seems like :effort:.

Use case is extracting a zip of binaries to a local directory (a bit like NuGet), and multiple builds for a given user. I can probably live without it for now. And if needs be use a database to register locks, and handle unexpected termination of the process.

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