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
mystes
May 31, 2006

Mr Shiny Pants posted:

It is complaining about the output of the function? Use ignore on both cases?
I'm not invoking the functions. Console.In.ReadLine and StreamReader should both be unit -> string and I am selectively setting my readline function to one of them.

However it turns out I misunderstood the problem. I don't know if it's a problem in this version of the fsharp compiler or dotnet core itself, but the actual problem is that it doesn't like StreamReader(string) for some reason, and it's determined to call StreamReader(stream) (one of the other constructors).

Looking at the .net standard reference at https://docs.microsoft.com/en-us/dotnet/api/system.io.streamreader?view=netstandard-1.6 the table of constructors at the bottom doesn't even have StreamReader(string) which makes me wonder if .net core therefore doesn't? And yet the example on that very page actually gives an example of using StreamReader(string)!
code:
...
String filename = "TestFile1.txt";
Char[] buffer;
        
using (var sr = new StreamReader(filename)) {
...
so if that's correct the example is just wrong? I'm pretty confused now.

Edit: Oh god it appears to be true: http://stackoverflow.com/questions/37785384/new-streamreader-class-doesnt-accept-filename

Why, Microsoft, why?

Edit 2: OK, I changed it to System.IO.File.OpenText and it builds with dotnet core 1.0, and I can debug it in VSCode. However, since the auto-completion and error highlighting are I think still based on mono this is probably going to lead to its own headaches if it doesn't match the actual compiler.

Drastic Actions posted:

What do you mean? That .NET Core is going to get more focus than Mono? I can tell you that's not that case.

Which version of mono are you running? We released 5.0 a few days ago to stable. I'm not sure if that impacts VS Code or not, but it might be worth checking the versions to see if 5.0+ fixes your breakpoint issues.You can also try using MonoDevelop and see if that integration works better. And try using the flatpak we release, as that's more up to date than what's probably in the distro's repo.

If you're still having issues, you can file a bug and I can poke people to see if they have any ideas, or if it's a VS Code/Ionide issue.
I didn't mean in terms of .net core and mono in general, but in terms of the infrastructure around fsharp on linux. It would be nice if I'm wrong, though. It just seems like fsharp isn't popular enough as it is, and with more configuration options the tooling is just going to get increasing fragmented, though.

I'm sure it's an issue with ionide rather than mono, but I might try seeing if upgrading mono helps.

mystes fucked around with this message at 16:37 on May 18, 2017

Adbot
ADBOT LOVES YOU

NihilCredo
Jun 6, 2011

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

AFAIK you have two possible debuggers on VSCode: OmniSharp (uses .NET Core) and MonoDebug (uses Mono). They're separate extensions from Ionide, and you can install either, both or neither. If you install both, you'll get a dropdown menu asking which debugger you want to use.

I wouldn't recommend going with .NET Core unless you're using some tools which require it, like Fable.

mystes
May 31, 2006

Oh never mind, I'm dumb. The breakpoint wasn't working because it was just using a version of the file I had compiled manually without debug information, so I'm back to mono and it's working fine now. I still apparently don't understand how to configure builds in VSCode at all, though.

Luckily that means I can postpone learning anything about .net core.

Mr Shiny Pants
Nov 12, 2012
So I just lost two hours to PgAdmin not showing a record if point[] seems to be defined in the DB........ And you prepend to the array.

Here's to thinking you are doing it wrong, instead of it being a bug.

God......

Mr Shiny Pants
Nov 12, 2012
Well poo poo, since the last time I looked ASP.net hasn't become any easier to understand.

Trying to figure out how it all hangs together is quite a thing.

NihilCredo
Jun 6, 2011

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

Mr Shiny Pants posted:

Well poo poo, since the last time I looked ASP.net hasn't become any easier to understand.

Trying to figure out how it all hangs together is quite a thing.

Since you're already using F#, take a look at Suave, or its ASP.NET Core port Giraffe. (Freya has its fans too, but I dislike Xyncro's projects.)

Being completely new to web programming, I found ASP.NET MVC to be extremely opaque and full of magic poo poo. By contrast, I was amazed at how I could immediately understand Suave's workings.

This book is quite good, and I think it says a lot that its first chapter makes you write a simplified version of Suave from scratch. It's that straightforward.

Mr Shiny Pants
Nov 12, 2012

NihilCredo posted:

Since you're already using F#, take a look at Suave, or its ASP.NET Core port Giraffe. (Freya has its fans too, but I dislike Xyncro's projects.)

Being completely new to web programming, I found ASP.NET MVC to be extremely opaque and full of magic poo poo. By contrast, I was amazed at how I could immediately understand Suave's workings.

This book is quite good, and I think it says a lot that its first chapter makes you write a simplified version of Suave from scratch. It's that straightforward.

Well I would love to but I don't want to reinvent the wheel, MVC comes with Razor and all types of niceties to render pages. I've looked at Suave as a webserver and it sure does look nice, but no view engine and Razor makes it easy to have something presentable in not a lot of time.

Maybe starting with MVC (Again) and trying to build my own identity store is not the smartest thing in the world.

Now to learn Suave and Fable for serving pages is a bit much, maybe a bit later.

I had my mind set on Elm as my page renderer, but that is a bridge too far at this moment.
I tried making the Identity store in F# but implementing interfaces and having it hook up to ASP.net is a bit above my skill level at the moment. :(

BTW I am having a bit of conundrum with the following: I have a server that users can register themselves ( that's why I need the custom Identity store, the server will authenticate users and be the store for the user and not the ASP.net application, or something else ) with and they will use a signup page to register themselves.

Now my signup page only requires a username and 2 passwords, my server has a recordtype of user that gets stored in the DB along with their salted passwords. The problem is that the JSON coming in differs from the recordtype in that it is not complete or might not be complete.

How would you handle that? Create another recordtype with only the properties needed for the signup eg: Identity or something? Or have my signup page require all fields.
Or do I go hog wild, make everything in the user record be an option except for the Id, username and passwords, iterate over the JSON and do a Array.choose over the incoming JSON to get the filled in properties, create the record type and in my db layer do the same, adding parameters only if they are Some x and not None.

I am thinking seriously about the latter, just to see if I can, but it is just for this scenario.

Mr Shiny Pants fucked around with this message at 20:07 on May 20, 2017

nolen
Apr 4, 2004

butts.
I've got a C# question about lambdas, scope, and possible memory leaks.

code:
public void GetAsset<T>(string url, Action<bool, T, string> onComplete) where T : UnityEngine.Object
{
     // make an HTTP request
     HTTPRequest wwwReq = new HTTPRequest(new System.Uri(url));

     // triggers the callback that was passed in, along with other required information
     wwwReq.Callback = (HTTPRequest req, HTTPResponse resp) => { onComplete(resp.IsSuccess, this.GetAssetData<T>(resp.Data), req.Uri.AbsolutePath); };

     // send the request
     wwwReq.Send();
 }
I'm writing a web services wrapper with a public method that will kick off an HTTP request and then, when the request is complete, invoke an onComplete function that was passed into said method. The signature of the onComplete callback(Action<bool, T, string>) is pretty much set in stone according to the framework, so the current workaround I've implemented involves setting the HTTP request Callback property to a lambda/anonymous function and letting that invoke the onComplete function via scope magic.

My question is this: will this clean itself up automatically in terms of garbage collection? I've read a bunch of articles regarding lambda expressions that have scared me into thinking this code will produce a bunch of leaks since I'm using a lambda for a callback and thus extending the scope of the variables passed into it.

If the object that owns onComplete goes out of scope before the lambda invokes it, will this cause problems that wouldn't be resolved by a simple null check?

ljw1004
Jan 18, 2005

rum

nolen posted:

I've got a C# question about lambdas, scope, and possible memory leaks.

I know you were asking about memory leaks with lambdas, but (1) you should be using async-await rather than lambda callbacks, (2) you should be cancelling the web request if its result is no longer needed, (3) what is this HTTPRequest/HTTPResponse class anyway? It looks like it's not System.Web.HttpRequest (which has different capitalization and lacks a Callback property) and I can't find it on Google, so I don't know how to write the code I think you should be writing instead. Why aren't you using "HttpClient' ?

ljw1004 fucked around with this message at 21:05 on May 20, 2017

mystes
May 31, 2006

ljw1004 posted:

I know you were asking about memory leaks with lambdas, but (1) you should be using async-await rather than lambda callbacks, (2) you should be cancelling the web request if its result is no longer needed, (3) what is this HTTPRequest/HTTPResponse class anyway? It looks like it's not System.Web.HttpRequest (which has different capitalization and lacks a Callback property) and I can't find it on Google, so I don't know how to write the code I think you should be writing instead. Why aren't you using "HttpClient' ?
Considering the type parameter constraint it's probably part of Unity, so that may impose some limitations.

jony neuemonic
Nov 13, 2009

NihilCredo posted:

Being completely new to web programming, I found ASP.NET MVC to be extremely opaque and full of magic poo poo.

Microsoft could do a better job explaining MVC and Web API to new users. I found both really difficult to learn using the docs, but straightforward when I grabbed a good book instead. Hopefully Core's docs pick up a good onramp.

StoicFnord
Jul 27, 2012

"If you want to make enemies....try to change something."


College Slice
Does anyone know of an easy way of nailing down event handle leaks, but without having live access to the server process?

I'm loving trapped in handle.exe he'll right now.

raminasi
Jan 25, 2005

a last drink with no ice

nolen posted:

I've got a C# question about lambdas, scope, and possible memory leaks.

code:
public void GetAsset<T>(string url, Action<bool, T, string> onComplete) where T : UnityEngine.Object
{
     // make an HTTP request
     HTTPRequest wwwReq = new HTTPRequest(new System.Uri(url));

     // triggers the callback that was passed in, along with other required information
     wwwReq.Callback = (HTTPRequest req, HTTPResponse resp) => { onComplete(resp.IsSuccess, this.GetAssetData<T>(resp.Data), req.Uri.AbsolutePath); };

     // send the request
     wwwReq.Send();
 }
I'm writing a web services wrapper with a public method that will kick off an HTTP request and then, when the request is complete, invoke an onComplete function that was passed into said method. The signature of the onComplete callback(Action<bool, T, string>) is pretty much set in stone according to the framework, so the current workaround I've implemented involves setting the HTTP request Callback property to a lambda/anonymous function and letting that invoke the onComplete function via scope magic.

My question is this: will this clean itself up automatically in terms of garbage collection? I've read a bunch of articles regarding lambda expressions that have scared me into thinking this code will produce a bunch of leaks since I'm using a lambda for a callback and thus extending the scope of the variables passed into it.

If the object that owns onComplete goes out of scope before the lambda invokes it, will this cause problems that wouldn't be resolved by a simple null check?

wwwReq goes out of scope at the end of that method, so I'm not sure what handler reference could be even hanging around. Honestly I feel like all the "your event handlers are leaking memory!!!" articles crossed a threshold into outright fearmongering. Event subscription isn't a black hole from which your resources will never escape, it's just another way to make object dependencies.

nolen
Apr 4, 2004

butts.

mystes posted:

Considering the type parameter constraint it's probably part of Unity, so that may impose some limitations.

Oops, yeah. I should have mentioned this is a Unity project, so no async/await for me :(.

We are using BestHTTP for requests and unfortunately I'm not able to switch us out for anything else at this point and time: https://docs.google.com/document/d/181l8SggPrVF1qRoPMEwobN_1Fn7NXOu-VtfjE6wvokg

raminasi posted:

wwwReq goes out of scope at the end of that method, so I'm not sure what handler reference could be even hanging around. Honestly I feel like all the "your event handlers are leaking memory!!!" articles crossed a threshold into outright fearmongering. Event subscription isn't a black hole from which your resources will never escape, it's just another way to make object dependencies.

So you're saying I should be good with the above snippet? Your thoughts definitely align with my initial thoughts on the matter.

Oh and ljw1004, requests that are no longer needed are absolutely cancelled from a different method.

NihilCredo
Jun 6, 2011

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

Mr Shiny Pants posted:

Well I would love to but I don't want to reinvent the wheel, MVC comes with Razor and all types of niceties to render pages. I've looked at Suave as a webserver and it sure does look nice, but no view engine and Razor makes it easy to have something presentable in not a lot oftime.

Maybe starting with MVC (Again) and trying to build my own identity store is not the smartest thing in the world.

Now to learn Suave and Fable for serving pages is a bit much, maybe a bit later.

I had my mind set on Elm as my page renderer, but that is a bridge too far at this moment.

FWIW Giraffe supports Razor; Suave has a pure F# view engine of its own, but it's still called 'experimental' so I wouldn't recommend that yet.

They also both support dotLiquid templating, which is less powerful than Razor (it's meant to be used safely by client-side users), but is stable and may be enough for what you need. YMMV.

quote:

BTW I am having a bit of conundrum with the following: I have a server that users can register themselves ( that's why I need the custom Identity store, the server will authenticate users and be the store for the user and not the ASP.net application, or something else ) with and they will use a signup page to register themselves.

Now my signup page only requires a username and 2 passwords, my server has a recordtype of user that gets stored in the DB along with their salted passwords. The problem is tthat the JSON coming in differs from the recordtype in that it is not complete or might not be complete.

How would you handle that? Create another recordtype with only the properties needed for the signup eg: Identity or something? Or have my signup page require all fields.
Or do I go hog wild, make everything in the user record be an option except for the Id, username and passwords, iterate over the JSON and do a Array.choose over the incoming JSON to get the filled in properties, create the record type and in my db layer do the same, adding parameters only if they are Some x and not None.

I am thinking seriously about the latter, just to see if I can, but it is just for this scenario.

If the properties are actually missing, I'd definitely make them all into Option fields. The cleanest approach would be to immediately convert JSON null/undefined values into Nones during deserialization, by changing some JsonSerializerSettings and/or using one of the many custom JSON.Net serializers around. Should that prove tricky, a simple workaround is to save a JSON serialization of the full record type with all the option fields set to None, and use JObject.Merge on it with the incoming possibly-incomplete JSON, so it will fill out all missing fields.

Then you keep the record with its Option types all the way to the database layer, where you can handle the Nones depending on however you've set up your database schema (skip them, turn them to NULL, replace them with default values, etc.).

If the properties are just empty text boxes that the user didn't fill, I wouldn't bother with Option types and I'd just make them empty strings for ease of use.

Mr Shiny Pants
Nov 12, 2012

NihilCredo posted:

FWIW Giraffe supports Razor; Suave has a pure F# view engine of its own, but it's still called 'experimental' so I wouldn't recommend that yet.

They also both support dotLiquid templating, which is less powerful than Razor (it's meant to be used safely by client-side users), but is stable and may be enough for what you need. YMMV.


If the properties are actually missing, I'd definitely make them all into Option fields. The cleanest approach would be to immediately convert JSON null/undefined values into Nones during deserialization, by changing some JsonSerializerSettings and/or using one of the many custom JSON.Net serializers around. Should that prove tricky, a simple workaround is to save a JSON serialization of the full record type with all the option fields set to None, and use JObject.Merge on it with the incoming possibly-incomplete JSON, so it will fill out all missing fields.

Then you keep the record with its Option types all the way to the database layer, where you can handle the Nones depending on however you've set up your database schema (skip them, turn them to NULL, replace them with default values, etc.).

If the properties are just empty text boxes that the user didn't fill, I wouldn't bother with Option types and I'd just make them empty strings for ease of use.

I have never heard of these ( Giraffe and the like ) I will take a look to see if they might be enough. I will, at the moment, go ahead with ASP.net and see where that gets me. Thanks for the tips.

I went ahead and added option values to my user record, they need to be stored in a collection of users anyway so it had to be a record of that type otherwise I had to do some funky stuff with interfaces and casting them to the proper type later on. Right now I am using Fsharp.Data.Json and the extensions to unwrap the json values, validate them per value ( not null, is a Guid etc. etc. ) and build the record that gets stored. By using a different URL on which they come into the system I can differentiatie between the incoming json and decide which validation record to run and what kind of DB storage I need ( full user or only registration ). It is quite a lot of work, but the validation needs to happen anyway so that is ok. You just have to write them once.

Now my whole validation pipeline works on the Json.Parse object in a Failure / Result DU and if the incoming DU is of the type Failure then the next validation function just passes on the error and does nothing. The problem is that I should have made it so that it passes on a user record through these validators so I don't have to built the object on the end and doing some logic again. Oh well, insight eh?

Mr Shiny Pants fucked around with this message at 09:41 on May 21, 2017

ModeSix
Mar 14, 2009

Mr Shiny Pants posted:

BTW I am having a bit of conundrum with the following: I have a server that users can register themselves ( that's why I need the custom Identity store, the server will authenticate users and be the store for the user and not the ASP.net application, or something else ) with and they will use a signup page to register themselves.

Now my signup page only requires a username and 2 passwords, my server has a recordtype of user that gets stored in the DB along with their salted passwords. The problem is that the JSON coming in differs from the recordtype in that it is not complete or might not be complete.

How would you handle that? Create another recordtype with only the properties needed for the signup eg: Identity or something? Or have my signup page require all fields.
Or do I go hog wild, make everything in the user record be an option except for the Id, username and passwords, iterate over the JSON and do a Array.choose over the incoming JSON to get the filled in properties, create the record type and in my db layer do the same, adding parameters only if they are Some x and not None.

I am thinking seriously about the latter, just to see if I can, but it is just for this scenario.

If you're using ASP.net for this, you can handle it through your ViewModel. Your ViewModel is just a representation of what data you expect to encounter, it doesn't even necessarily have to match the db fields, and you can mark the required options as [Required].

Represent the actual database set in the Model then handle the interaction of it using a ViewModel, as such:

This is my model for users, which actually represents the database schema:
code:
public class ApplicationUser 
    {
        public DateTime DateRegistered { get; set; } = DateTime.UtcNow;

        public string FirstName { get; set; }
        public string LastName { get; set; }

        public int IsActive { get; set; } 

    }
Now here is my ViewModel for actually working with the data:
code:
 public class UserViewModel
    {
        public string Id { get; set; }
       
	[Required]
        public string UserName { get; set; }
        
	[Required]
        [DataType(DataType.Password)]
        public string Password { get; set; }
        
	[Required]
        [Display(Name ="Confirm Password")]
        [DataType(DataType.Password)]
        public string ConfirmPassword { get; set; }

        [Required]
        public string FirstName { get; set; }
        
	[Required]
        public string LastName { get; set; }
        
	public string Email { get; set; }
        
        public string RoleName { get; set; }

        public int IsActive { get; set; } = 1;
       

        public List<SelectListItem> ApplicationRoles { get; set; }
        [Display(Name = "Role")]
        public string ApplicationRoleId { get; set; }

    }
In this case the ViewModel is responsible for figuring out what is required, and what other information may come along with any submitted information.

I hope this is actually what you were asking. :v:

If you're not using ASP.net MVC for this well, I hope you find your solution. But it's even possible to pass this off through the server to your authentication server, though that's a bit more work.

It's possible I've totally misunderstood your question and/or I sound like a dick for telling you something you already know, but your post had a lot of words.

ModeSix fucked around with this message at 15:43 on May 21, 2017

Mr Shiny Pants
Nov 12, 2012

"A lot of words" I like that :)

Thanks for taking the time to answer my question. It was more concerned with the backend server of the application and how to register users. Users are represented in the backend by F# records and they have a certain amount of properties that are required ( Surname etc. ) but these are not filled-in during the initial registration but they are stored in the same collection. So my question was how I would go about making this happen in F# with incomplete JSON coming in.

In the end I got it working though. I had to write my own UserManager and implement IUserStore, IUser and I had to implement FindUserById and the other methods to get it working but I can register users through my ASP.Net front-end on my backend and have them authenticate successfully. Yay!

Now I just need ASP to not hash the passwords, the server is responsible for that, and it all should work.

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
Depending on what you need to do with the users, implementing your own user store for authentication is usually overkill. You can just override the AuthorizeAttribute with your own AuthorizeCore implementation. If you're happy to trust the application cookie and don't need to check in on each request, it's even easier since the built-in Identity stuff will handle cookie management for you. Just implement your own logic in the Login action method on the AccountController (via a business logic class or something if you want). Then for registration, just handle that however you like in the Register action method on the AccountController.

The great part about the Identity stuff in ASP.NET is you can kind of use as much or as little of it as you like.

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)
I use something like this for small projects because I am also asp adverse:
php:
<?
public class HttpServer : IDisposable
{
    readonly HttpListener http;
    readonly Semaphore govern =
        new Semaphore(8, 8);
    public bool IsListening 
        => http.IsListening;

    public HttpServer(
        string prefix,
        Action<
            HttpListenerRequest, 
            HttpListenerResponse> handler)
    {
        http = new HttpListener();
        http.Prefixes.Add(prefix);

        void Accept(IAsyncResult ar)
        {
            var c = http.EndGetContext(ar);
            Task.Factory.StartNew(() =>
            {
                using (var resp = c.Response)
                    handler(c.Request, c.Response);
            });
            govern.Release();
        }

        http.Start();

        new Thread(() =>
        {
            while (http.IsListening)
            {
                govern.WaitOne();
                http.BeginGetContext(Accept, null);
            }
        }).Start();
    }

    public void Dispose()
    {
        ((IDisposable)http).Dispose();
        govern.Dispose();
    }
}?>
It goes pretty good for ye olde website, if you're willing to brave it a little. I use C# for most tasks, but if I ever need a "good-enough" website I'm split between this or this with Flask as the front-end/controller. I'm sure asp is really good, but I just wont take the time to figure out how it works unless I'm gonna be an asp programmer for a living which seems terrible (sorry).

Also this may reveal the fact that I still have no idea how the async syntax works (it's just a big fork/join???), but I think Task.Factory.StartNew() is just an alias for ThreadPool.QueueWorkItem anyways ...

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

dougdrums posted:

I use something like this for small projects because I am also asp adverse:
php:
<?
public class HttpServer : IDisposable
{
    readonly HttpListener http;
    readonly Semaphore govern =
        new Semaphore(8, 8);
    public bool IsListening 
        => http.IsListening;

    public HttpServer(
        string prefix,
        Action<
            HttpListenerRequest, 
            HttpListenerResponse> handler)
    {
        http = new HttpListener();
        http.Prefixes.Add(prefix);

        void Accept(IAsyncResult ar)
        {
            var c = http.EndGetContext(ar);
            Task.Factory.StartNew(() =>
            {
                using (var resp = c.Response)
                    handler(c.Request, c.Response);
            });
            govern.Release();
        }

        http.Start();

        new Thread(() =>
        {
            while (http.IsListening)
            {
                govern.WaitOne();
                http.BeginGetContext(Accept, null);
            }
        }).Start();
    }

    public void Dispose()
    {
        ((IDisposable)http).Dispose();
        govern.Dispose();
    }
}?>
It goes pretty good for ye olde website, if you're willing to brave it a little. I use C# for most tasks, but if I ever need a "good-enough" website I'm split between this or this with Flask as the front-end/controller. I'm sure asp is really good, but I just wont take the time to figure out how it works unless I'm gonna be an asp programmer for a living which seems terrible (sorry).

Also this may reveal the fact that I still have no idea how the async syntax works (it's just a big fork/join???), but I think Task.Factory.StartNew() is just an alias for ThreadPool.QueueWorkItem anyways ...

There's a lot to learn about in the ASP.NET MVC world but that's because it does A LOT of stuff out of the box which is a huge time saver when you're working on any kind of large project. There's nothing wrong with not wanting to learn it unless you're going to work with it regularly, but I wouldn't be so quick to call programming in ASP for a living "terrible", since by your own admission you don't really know much at all about ASP.

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)
Well, it's more so that where I'm at, the prospect of making a living as a .Net developer of any sort is waning, to put it lightly. It's nothing personal, just that I don't really see it being valuable to me anytime soon. Someone I know at the local Initech has just spent months converting all of their ASP to Java; and there are certainly more attractive things to chase after right now...

Also I cannot stand video tutorials and I'm just generally dense.

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

dougdrums posted:

Well, it's more so that where I'm at, the prospect of making a living as a .Net developer of any sort is waning, to put it lightly. It's nothing personal, just that I don't really see it being valuable to me anytime soon. Someone I know at the local Initech has just spent months converting all of their ASP to Java; and there are certainly more attractive things to chase after right now...

Also I cannot stand video tutorials and I'm just generally dense.

That's fine and I understand, luckily there are a lot of languages and ecosystems to specialise in when it comes to web development.

What are you planning on pursuing out of curiosity?

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)
Ah, well, what I do now ... which is maybe (already) identifiable and I don't really want it to be ... but it's not making large-scale web applications -- just small apps mostly for the sake of convenience in the course of other computery work, or when I need something that's really public and portable. I do them with Flask or a more reliable version of what I posted usually, depending on if I need other people to help support/maintain it. I've been doing auth with certs.

I just spent like the last month learning CSS3 and HTML5, which have seemed to settled into adulthood nicely. I ended up writing a decent-sized public service website to test my knowledge, which was like 3/4th's just query expressions. Now I just have to figure out how I'm gonna deploy the thing, which I think is definitely a point for ASP over other frameworks.

Mr Shiny Pants
Nov 12, 2012

a hot gujju bhabhi posted:

Depending on what you need to do with the users, implementing your own user store for authentication is usually overkill. You can just override the AuthorizeAttribute with your own AuthorizeCore implementation. If you're happy to trust the application cookie and don't need to check in on each request, it's even easier since the built-in Identity stuff will handle cookie management for you. Just implement your own logic in the Login action method on the AccountController (via a business logic class or something if you want). Then for registration, just handle that however you like in the Register action method on the AccountController.

The great part about the Identity stuff in ASP.NET is you can kind of use as much or as little of it as you like.

I didn't want to have two user stores because I would administrating them at both systems, and the frontend is useless if the backend is down so thought it made sense to have the userstore just pass along the authenticating of users to the other system, acting like a bridge between the two.

It works in the end, I'll be using the hashing libraries from ASP in the backend though.

Mr Shiny Pants
Nov 12, 2012

This is nice, I also just use HTTP listener on the backend with a custom DLL that handles mutlipart form data. It's a fork from Mono's that handles regular SSL Certs instead of bastardized version that the one MS needs. Another pre is not needing administrator access to listen on port 80.

When a request comes in, I wrap the whole HTTPContext inside a F# record and that works through the whole application.

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

Mr Shiny Pants posted:

I didn't want to have two user stores because I would administrating them at both systems, and the frontend is useless if the backend is down so thought it made sense to have the userstore just pass along the authenticating of users to the other system, acting like a bridge between the two.

It works in the end, I'll be using the hashing libraries from ASP in the backend though.

I'm a bit confused I think. You said you have a "server" where users can register themselves. What do you mean by this? Do you mean you have some kind of a web service that has a user registration endpoint? Or is it a website that users access through a browser to register at? Either way I assume it ends up connecting to a database of some description that contains your user accounts. Does this database also contain your other application data that you need?

I'm confident I can help you, I just don't understand the problem very well at this stage.

Mr Shiny Pants
Nov 12, 2012
The "server" is just a backend that exposes an API to the ASP.net application. Users interact with ASP.net as a front-end and the back-end is responsible for authentication and data.

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

Mr Shiny Pants posted:

The "server" is just a backend that exposes an API to the ASP.net application. Users interact with ASP.net as a front-end and the back-end is responsible for authentication and data.

Right, but what is the "backend" exactly? Is it a RESTful API of some description?

Mr Shiny Pants
Nov 12, 2012

a hot gujju bhabhi posted:

Right, but what is the "backend" exactly? Is it a RESTful API of some description?

Yep, maybe SignalR also, I haven't decided yet.

tays revenge
Aug 29, 2009

So, been using EF for a good while, used correctly, seems reasonable enough even for large complicated queries.

B-Nasty
May 25, 2005

tays revenge posted:

So, been using EF for a good while, used correctly, seems reasonable enough even for large complicated queries.

Don't worry, you'll acquire some scars on your forehead from banging it on the desk soon enough.

Unfortunately, most of the pain of EF don't really start until after your application has become large and complex -- when it is harder to swap out.

tays revenge
Aug 29, 2009

B-Nasty posted:

Don't worry, you'll acquire some scars on your forehead from banging it on the desk soon enough.

Unfortunately, most of the pain of EF don't really start until after your application has become large and complex -- when it is harder to swap out.

I mostly just use manual string queries for those situations although I really hate doing that. The trick is using the model that matches the results exactly it seems when converting to maintain decent performance. That being said, I'm slowly starting to back away from frameworks when possible.

B-Nasty
May 25, 2005

I just find the mental energy I'm spending to wrangle EF and make sure I'm not doing something stupid to be not worth it. I'm good at SQL; I like SQL; it's older than I am and still used for a reason. I just want my ORM to handle the boilerplate nonsense of wiring up datareaders and parameters.

In addition to Dapper, I like the Dapper.Contrib library which adds some real simple Insert/Update support. If you're using traditional, basic entities, it can save some time. I like that it isn't performing magic; it just writes an insert/update by dumping all your object's properties.

Mr Shiny Pants
Nov 12, 2012
I am not good at SQL, I make do, but I think I can agree.

I saw a talk once from a guy made a good point that for all the energy spent by software to abstract SQL away, SQL is still around while most of the other tech is not anymore.
Meaning that if you would have just learned SQL from the get go, instead of trying to work around it, you'd still have relevant skills.

That said: I do like something like Dapper or PetaPoco. You just type the SQL you want and out pops the object.

In my current project I do use Npgsql directly for PostgreSQL, and it is pretty nice to work with. Even though you hand build all you result-sets back into objects yourself.

Shame I can't seem to find the talk, it was pretty good.

Mr Shiny Pants fucked around with this message at 07:42 on May 26, 2017

NihilCredo
Jun 6, 2011

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

B-Nasty posted:

I just find the mental energy I'm spending to wrangle EF and make sure I'm not doing something stupid to be not worth it. I'm good at SQL; I like SQL; it's older than I am and still used for a reason. I just want my ORM to handle the boilerplate nonsense of wiring up datareaders and parameters.

If you're running MSSQL, you're gonna love FSharp.Data.SqlClient.

Mr Shiny Pants
Nov 12, 2012

NihilCredo posted:

If you're running MSSQL, you're gonna love FSharp.Data.SqlClient.

This one is also good: https://github.com/fsprojects/SQLProvider

And works with pretty much all the databases you could wish for.

The problem with these is that I had some problems with the drivers not being found. Otherwise it works pretty well.

NihilCredo
Jun 6, 2011

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

Mr Shiny Pants posted:

This one is also good: https://github.com/fsprojects/SQLProvider

And works with pretty much all the databases you could wish for.

The problem with these is that I had some problems with the drivers not being found. Otherwise it works pretty well.

Yeah but Sqlprovider uses LINQ2SQL underneath, you can't write SQL yourself.

It's still a great option if you can't use MSSQL (I'm using it right now because Postgres), but I'd much rather have SqlClient.

I've wanted to port it to non-MS databases for a while, in theory it could work in a super-hacky way by just wrapping every query in "DECLARE params; SELECT * FROM (query) WHERE 0=1" to get the columns.

Mr Shiny Pants
Nov 12, 2012

NihilCredo posted:

Yeah but Sqlprovider uses LINQ2SQL underneath, you can't write SQL yourself.

It's still a great option if you can't use MSSQL (I'm using it right now because Postgres), but I'd much rather have SqlClient.

I've wanted to port it to non-MS databases for a while, in theory it could work in a super-hacky way by just wrapping every query in "DECLARE params; SELECT * FROM (query) WHERE 0=1" to get the columns.

It does? I did not know that.

How are you liking Postgres? It seems to be the only reasonable mature DB if you don't want to sell your soul to MS, Oracle or IBM.

Adbot
ADBOT LOVES YOU

Sab669
Sep 24, 2009

Dumb Question: What exactly does Microsoft's Reference Source site show me?

I wanted to do some research for a question on stack overflow pertaining to an issue with the ZipArchive object, which exists in System.IO.Compression as stated here: https://msdn.microsoft.com/en-us/library/system.io.compression.ziparchive(v=vs.110).aspx


If I pull up the online source reference: https://referencesource.microsoft.com/#q=ZipArchive

And search for "ZipArchive" I get one Class result with a different namespace and different members. Like MSDN lists a constructor which takes a Stream object but the Source site does not define any constructors, for example.

Clearly I must be misunderstanding something, but I don't know what. I very rarely use the online source reference so I'm not very familiar with it.

Where (if at all) can I find the source code for the object as defined on MSDN?

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