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
raminasi
Jan 25, 2005

a last drink with no ice
How do GhostDoc and Sandcastle/SHFB compare?

Adbot
ADBOT LOVES YOU

raminasi
Jan 25, 2005

a last drink with no ice

crashdome posted:

I've never used Git because gently caress command line. Although, I do find TFS a bit confusing at times. I thought Git would be more confusing. Is that not true? Can I seamlessly browse my projects in VS with Git? Can I type a comment in a textbox and push pending changes to Git? I'm a lone developer with a few read-only accounts to my projects.

If so, I'd try setting up a Git repo just to play with. It's just as easy to set up Git in VS online as it is to use their TFS. I just thought I would be forced to use a command line or third party tools to use it?

If you want to anything fancy (e.g. any history rewrites), you'll have to go third-party, but basic commit/push/fetch/branch stuff is done easily within VS.

raminasi
Jan 25, 2005

a last drink with no ice

chmods please posted:

Theyre different things entirely :confused: Sandcastle compiles the inline documentation to a set of web pages or whatever. As far as I can tell, GhostDoc is good for automatically writing a comment stating that GetButts() gets the butts. Did they add compilation or something?

According to the website the Pro version will do it. After reading a little bit more I think I just don't understand what's useful about being able to automatically infer that GetButts() gets butts, but to each their own I guess :shobon:

And while we're on the subject, maybe SHFB should be in the OP?

raminasi
Jan 25, 2005

a last drink with no ice
Does anyone have any idea why VS 2013 might start hanging whenever I try to open or add an F# library project? Right after I do it I get that "Visual Studio is doing something or waiting for user input" pop up whenever I click anywhere, and attempting to end the process gives me the "Visual Studio is waiting for modal input" dialog box, except it doesn't look like it is.

This is kind of a problem...

e: Update 2 fixed it, whatever "it" was.

raminasi fucked around with this message at 20:01 on Jun 29, 2014

raminasi
Jan 25, 2005

a last drink with no ice
Can I thank you for making the great OP and suggest adding Sandcastle/SHFB to it :shobon:

raminasi
Jan 25, 2005

a last drink with no ice

Chill Callahan posted:

Can't you just mouse over 'var' to find out the type in VS? C# is still statically typed so I'm not sure why it's a big deal.

It works less often than it should, and now you need to bring your IDE along when you go codebase history spelunking.

raminasi
Jan 25, 2005

a last drink with no ice
I've got a solution that's started opening with some projects unloaded. I can manually load them fine, but I have to do it every time the solution is opened fresh. I deleted the .suo file for the solution and the problem didn't go away. This is on VS 2013. Anyone have any ideas?

raminasi
Jan 25, 2005

a last drink with no ice

Huragok posted:

I'm not 100% sure but aren't solution project files selected for loading/unloading using the .vsproj? If that is the case and you use source control you should break out the rubber hose (:getin:) because someone must be committing the .vsproj with projects unloaded.

I can't find any diff in either the relevant vsproj files or the sln that would explain this.

raminasi
Jan 25, 2005

a last drink with no ice
If I'm inheriting from an abstract class, is there really no way to make one of the overridden properties more accessible without essentially duplicating it?

raminasi
Jan 25, 2005

a last drink with no ice

Bognar posted:

Use the new keyword and make a call to base.SomeMethod? It's still essentially duplication, but you get to keep the same name.

I wasn't clear. I have:

C# code:
public abstract class AbstractButt
{
    protected int Size { get; }
}
Now when I make:

C# code:
public class ConcreteButt : AbstractButt
{
    protected override int Size { get { return 10; } }
}
I want to make Size available, say, internally, but I can't do that, right?

raminasi
Jan 25, 2005

a last drink with no ice
FileSystemWatcher.OnChanged is fired when a file change begins, not when it ends. Is there a way to get the changed file after it's done being modified other than just repeatedly attempting to open it and catching IOExceptions?

raminasi
Jan 25, 2005

a last drink with no ice
Your question is about configuring your deployment, not your build settings, so unless I'm mistaken somewhere, this:

Mr Shiny Pants posted:

You should create the folders within VS solution and tell it to copy the solution files "always". The copy option is within the file properties of the file you want it to copy.

actually solves a different problem. How are you deploying?

raminasi
Jan 25, 2005

a last drink with no ice

Sedro posted:

You have to use ClassB (with initialization in the ctor) or ClassC.

They do plan to add this to the language [source].

quote:

The initializer directly initializes the underlying field – it doesn’t go through the setter. For that reason, it is now meaningful to allow getter-only auto-properties:

Yessss :getin:

raminasi
Jan 25, 2005

a last drink with no ice

LOOK I AM A TURTLE posted:

It still doesn't cover all the bases, but for what it's worth they're also adding some new syntax for "primary constructors", so you'll be able to do stuff like this:

C# code:
public struct Point(int x, int y)
{
	public int X { get; } = x;
	public int Y { get; } = y;
}

This is what I should have quoted.

raminasi
Jan 25, 2005

a last drink with no ice
I've developed a custom WPF control that "intelligently" determines the best way to display information that's been bound to it. I want this control to expose a facility to export the data that's currently being displayed in a way that corresponds to the current way that information is being displayed. (i.e. the export format matches the display format). However, the control shouldn't be the component that actually initiates the export - that should happen elsewhere. What's the best way to do this? I was thinking of having the control offer some kind of Action<string> (or more appropriately, a custom delegate) property that a view model could bind to using OneWayToSource binding, but I'm not sure if that's the kind of thing I should be doing, or if it is, if there's a way to enforce the one-way-reverse behavior when setting up the relevant DependencyProperty.

e: It looks like the "right" way to do this, using a ReadOnlyDependencyProperty, isn't going to work.

raminasi fucked around with this message at 18:56 on Aug 11, 2014

raminasi
Jan 25, 2005

a last drink with no ice
I want to start a ridiculous, pie-in-sky side project to compile C# into this tiny other programming language that already exists (but is really, really terrible). Is Roslyn the place to start here?

raminasi
Jan 25, 2005

a last drink with no ice
I basically need a C#-parsing frontend.

raminasi
Jan 25, 2005

a last drink with no ice

Rooster Brooster posted:

Rosyln should be able to parse you out a syntax tree from C# text, and then you could build a translator that would take that tree and spit out the other language's code. Does that sound like what you're looking for?

It's a start. I'm realizing I haven't quite thought all this through enough.

raminasi fucked around with this message at 19:24 on Aug 18, 2014

raminasi
Jan 25, 2005

a last drink with no ice
I'm using the built-in VS2013 profiler thing, and I'm seeing a bunch of time spent on a simple field read. As it turns out, the code to populate this field might be taking some substantial time to execute. I'm profiling a release build. Am I seeing the JIT or whatever defer the computation and assignment until the field is actually accessed?

raminasi fucked around with this message at 20:31 on Aug 19, 2014

raminasi
Jan 25, 2005

a last drink with no ice
C# 6.0 will have a way to more easily match constructor arguments with auto-properties, but there's nothing like what you want yet.

raminasi
Jan 25, 2005

a last drink with no ice

Sedro posted:

So primary constructors will save exactly 1 line of code (excluding braces)? I hope that's not the case.

Edit: I guess it also removes the need for field assignments e.g. this.foo = foo. But still not in the same league as scala's case classes.

There's syntax to automatically plug them into auto properties, which is really nice.

raminasi
Jan 25, 2005

a last drink with no ice
I've seen that problem when the assembly containing the viewmodel gets renamed in a post-build event. Basically, Intellisense knows what the class will look like once compiled, but the compiler can't actually find it once it is.

raminasi
Jan 25, 2005

a last drink with no ice
The whole process is made harder than it needs to be by the fact that WPF doesn't offer a good, concrete ICommand implementation out of the box, for some idiotic reason. Most people either use third-party frameworks or just roll the bits from them they need on their own, like the RelayCommand in this article. (RelayCommand is really tiny so it's not hard.)

The end product looks something like this:
C# code:
public class ViewModel : INotifyPropertyChanged
{
    public ICommand CalculateCommand { get; private set; }

    public ViewModel()
    {
        CalculateCommand = new RelayCommand(Calculate);
    }

    private void Calculate()
    {
        // Perform whatever calculation and property assignment is necessary.
        // Remember that you have access to all the data-bound properties you need to serve as calculation inputs.
    }

    // blah blah blah whatever else
}

raminasi
Jan 25, 2005

a last drink with no ice

A Tartan Tory posted:

Ok so, this is the viewmodel, it initiates itself whenever the button is pressed (how do I represent that in the XAML in view?) and all the inputted data is bound to the name I use in the xaml in view for that textbox it just needs to be assigned to a new variable within this method (how do I access it from the binding to do that then, it can't be within the model as given in the example?).

It doesn't need to be assigned anywhere new; presumably you've got some of these guys elsewhere in your viewmodel:
C# code:

    private IEnumerable<CalculatedResult> results;
    private int months;
    private int years;

    public IEnumerable<CalculatedResult> Results
    {
        get { return results; }
        set
        {
            results = value;
            // Most people do a null check here but I'm eliding that for simplicity
            // (And because there's a better way to do it)
            PropertyChanged(this, new PropertyChangedEventArgs("Results"));
        }
    }

    public int Months
    {
        get { return months; }
        set
        {
            months = value;
            PropertyChanged(this, new PropertyChangedEventArgs("Months"));
        }
    }

    public int Years
    {
        get { return years; }
        set
        {
            years = value;
            PropertyChanged(this, new PropertyChangedEventArgs("Years"));
        }
    }

that you've databound to. The body of Calculate will then have access to this.Months and this.Years as calculation arguments, and this.Results to stuff the results in.

raminasi
Jan 25, 2005

a last drink with no ice

A Tartan Tory posted:

Oh, oh! I get it now! So whenever the view is updated by the user, the command updates the variables that are assigned in public in the ViewModel, so it can be used by the programming logic later on and then displayed as results when finished?

If I was to stuff multiple arrays into this.results though, would it still work if it was shown in view in the correct way?

Not quite. The command doesn't do the updating; the data binding engine itself does that. It would still work even if there were no command anywhere.

If you perform multiple assignments to Results, only the last one will "stick," the same as any other variable assignment.

raminasi
Jan 25, 2005

a last drink with no ice
I only use the fluent notation because I don't use LINQ for database operations so I figured that if I'm writing C# it might as well actually look like C#.

raminasi
Jan 25, 2005

a last drink with no ice

Ciaphas posted:

Assuming the resulting IEnumerable or whatever is the same, the order of your fluent-syntax calls doesn't have an effect on performance, does it? Like doing the .OrderBy() before or after the .Select() or whatever?

That's a very strong assumption. Can you give an example of when it holds that you're talking about?

raminasi
Jan 25, 2005

a last drink with no ice

mortarr posted:

Does anyone have any ideas on how to take a querystring like so:

code:
take=20
&skip=20
&page=2
&pageSize=20
&sort[0][field]=JobBagNumber&sort[0][dir]=asc
&filter[logic]=or&filter[filters][0][value]=what&filter[filters][0][operator]=eq&filter[filters][0][field]=JobBagNumber
&filter[filters][1][value]=what&filter[filters][1][operator]=contains&filter[filters][1][field]=State
&filter[filters][2][value]=what&filter[filters][2][operator]=contains&filter[filters][2][field]=Title
and parse it into a dynamic / expando object based on json like so:

code:
{
  take: "20",
  ...
  sort: [ { field: "JobBagNumber" }, { dir: "asc" } ],
  filter: { 
    logic: "or", 
    filters: [ { value: "what", operator: "eq", field: "JobBagNumber" }, ... ]
  },
  ...
}
I've been bashing my head against a brick wall all day on this goddamn thing.

What have you tried, and what's not working?

raminasi
Jan 25, 2005

a last drink with no ice
If I've got a spun-off async operation blocking on a call to TcpListener.AcceptTcpClient(), and something else calls TcpListener.Stop(), a SocketException is thrown with the message "A blocking operation was interrupted by a call to WSACancelBlockingCall". That seeems like it's exactly what I want. Can I just swallow this exception? It feels like there should be a better way to do this.

edit: There had better be a better way to do this, as I am apparently unable to actually catch this exception. No matter where I put try/catch blocks, the exception slips through and brings my app down.

raminasi fucked around with this message at 19:16 on Sep 6, 2014

raminasi
Jan 25, 2005

a last drink with no ice

Bognar posted:

Can you post some code?

Are you explicitly catching SocketException, or catching any Exception? If you're just catching a SocketException and the TcpListener is on an async call, it's possible that an AggregateException is being thrown instead.

EDIT: On second thought, this is probably unlikely. Back to line 1 - got any code?

I will disclose that this is my first attempt at writing my own async code (rather than just blindly copying from someone else), so I might be thinking about this completely wrong. Here is the original, non-working code, with the relevant bits noted with comments:
code:
member public this.Start () =
    if semaphore.WaitOne(0) then
        let res = RhinoGet.GetInteger("Port", true, &port)
        if res <> Result.Success then
            semaphore.Release() |> ignore
            res
        else
            socket <- TcpListener(IPAddress.Loopback, port)
            // Important stuff starts here
            let server = async {
                let onCancel () =
                    socket.Stop()
                    socket <- Unchecked.defaultof<TcpListener>
                    semaphore.Release() |> ignore
                use! canceller = Async.OnCancel(onCancel)
                socket.Start()
                RhinoApp.WriteLine("umi CityScope: Server started on port {0}.", port)
                let client = socket.AcceptTcpClient() // This line doesn't work
                RhinoApp.WriteLine("umi CityScope: Client connected.")
                listen client // This function returns when the client closes the connection
                client.Close() }
            if cts <> Unchecked.defaultof<CancellationTokenSource> then cts.Dispose()
            cts <- new CancellationTokenSource()
            Async.Start(server, cts.Token)
            Result.Success
    else
        RhinoApp.WriteLine("umi CityScope: Server already running.")
        Result.Nothing
I was able to fix it by changing the offending line to
code:
let! client = socket.AcceptTcpClientAsync() |> Async.AwaitTask
so that no exception is thrown when the task is cancelled, but I still don't understand why I wasn't able to catch the original exception. (As an Exception, not any subtype.)

raminasi
Jan 25, 2005

a last drink with no ice

Bognar posted:

I'm very inexperienced with F#, but my read of that code is that you are calling Async.Start which is starting the server method on the threadpool. If you're not handling exceptions within that method, the exception can not be caught because it's running on a different thread as the first method in its call stack (and therefore not wrapped in a try/catch at any level).

The problem is that
code:
try
    let client = socket.AcceptTcpClient()
    RhinoApp.WriteLine("umi CityScope: Client connected.")
    listen client
    client.Close()
with
    | ex -> RhinoApp.WriteLine(ex.Message)
doesn't catch it either.

raminasi
Jan 25, 2005

a last drink with no ice

darthbob88 posted:

That might do it, but I don't understand async that well. I don't suppose I can get a demonstration, just a toy program?

ETA: I think I might get it. You're suggesting three StreamWriters to write to three files, with asyncs and awaits to keep them vaguely in sync. That'd work, but what I really wanted was something that'd let me do
code:
using (var comicsLog = File.CreateText(file1, file2, file3)) {comicsLog.Write(things)}

What specific problem do you think that will solve that three separate async writes won't?

raminasi
Jan 25, 2005

a last drink with no ice

darthbob88 posted:

It'd save creating and disposing of two StreamWriters per media collection, and it'd be marginally easier to have the StreamWriter write to another folder than to create and dispose of another StreamWriter, but that only matters to my crippling Asperger's. The async is probably unnecessary; at the moment the catalogs total only about 400K, with the largest being 180K, so I can just do it with three regular writes.

Computers exist to do boring, repetitive work. Wait for the profiler to start whining before you worry about this kind of optimization.

raminasi
Jan 25, 2005

a last drink with no ice
Why can't you just have the projects that need NuGet packages directly reference them?

raminasi
Jan 25, 2005

a last drink with no ice
Is there a way to get more detailed information about what's causing a TypeLoadException? I know the type it can't find, but I haven't the faintest idea why it can't find the type, and I'm pulling my hair out trying to figure out what's going on.

raminasi
Jan 25, 2005

a last drink with no ice

No Safe Word posted:

It's always a binding redirect :v:

No seriously, whenever it hasn't been some NuGet package (or rogue developer) doing something stupid with binding redirects, I've been able to fairly easily step through the normal places .NET looks for poo poo and figure it out manually, but we also don't do much mucking about with assembly loading.

Oh, it's found the assembly. It loads all the other types in it fine. I just can't add any more, apparently.

raminasi
Jan 25, 2005

a last drink with no ice

Sedro posted:

Does the type have a .cctor or any static fields?

Yep, static class with .cctor.

raminasi
Jan 25, 2005

a last drink with no ice

Sedro posted:

Obvious question, does it throw an exception?

I forgot that I'd disabled the .cctor to try to solve this problem. The class at this point has a single method which is a no-op.

edit: Problem solved, the wrong .dll was getting loaded. (It was an old version in a different location.) ProcMon, you've saved my bacon yet again!

raminasi fucked around with this message at 06:25 on Sep 12, 2014

raminasi
Jan 25, 2005

a last drink with no ice

mortarr posted:

If you're after optional conditions in the where clause, there's always predicate builder.

I don't have any need for this right now, but I have a question about their example code:
C# code:
IQueryable<Product> SearchProducts (params string[] keywords)
{
  IQueryable<Product> query = dataContext.Products;

  foreach (string keyword in keywords)
  {
    string temp = keyword;
    query = query.Where (p => p.Description.Contains (temp));
  }
  return query;
}

quote:

The temporary variable in the loop is required to avoid the outer variable trap, where the same variable is captured for each iteration of the foreach loop.

Why would the same variable be captured on each iteration?

Adbot
ADBOT LOVES YOU

raminasi
Jan 25, 2005

a last drink with no ice

ljw1004 posted:

It's not captured on each iteration any longer. We made this change is VS2012. The temporary is no longer needed.

Was the old behavior originally intended, or was it a bug? That behavior seems incredibly counterintuitive to me, especially because, if I understand right, there's no way to explicitly request it anywhere in the language.

(Also, how did I not know that?)

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