« first day (2293 days earlier)      last day (2661 days later) » 

6:00 PM
in theory, it should be with self contained .NET Core
I would love to be wrong though
 
IIRC .net core fires up kestrel as a tiny self-host, it doesn't compile it to an exe in its own right...does it?
 
I was under the impression that the exe could run and start its own instance of Kestrel
 
Oh cool, well if you say so
 
as it is right now, you do dotnet run projectName.dll
 
Pretty much, your site can run as its own process.
Thankfully that's becoming common with docker and all, being at the mercy of IIS really annoys me
 
6:02 PM
I think for the most part its recommended to use IIS but not required?
might miss out on some features though
 
Not really, core runs on Linux, so no IIS there.
Kestrel should be production-grade webserver capable
My english faild on me
 
can TempData be passed from one controller to another?
without the use of a query string
 
Generaeted the EXE with the old(er) LTS version of .NET Core, then used dotnet migrate on the new version, ran build and no dice. what a mess!
 
@Skullomania Sure. TempData is just a bag of data for this and the next request.
(Backed by session state)
 
6:28 PM
Isn't kestrel just the front? Don't you have to have some other webserver behind it on linux?
reverse proxy thingy
 
C4u
Hi everyone :)
 
(or other way around)
 
C4u
Any regex-pro's in here? I need to grab the 2nd id from the input-elements. Chellange is, sometimes there is only 1 input-element.
<div id="505">
<input someText id="10"> some trash in here
<input someText id="15">
</div>
All I know is the id of the div-box.
Its unique.
Already tried it like id="505".*?(<input.*?id="(.*?)".*?>.*?)+".
Going crazy with this.
 
!!tell c4u zalgo don't parse html with regex
 
@mikeTheLiar That didn't make much sense. Use the !!/help command to learn more.
@c4u ḑ̷͓̤͖ͮ͗̿ͭ̂̒o̸͖͇͖̦̲̣ͫͪ͝n̨͎̣̟̈́͂ͭ͛͊́̚̚͢'̥̲͕̝̩͓̙̬ͦͯt̶͆̀ͬ͊͗ͯ̿ͮ͜҉͓̫̣ͅ ̧̣̻̤̌ͯ̀̽̌ͬͫͫ͠p̛̰̯̍ͮͮ͛̌̑̉ͥ͢a̜̗̮͍͉̦͎̘͌̑̈ͮr̟̳̖̮͇̈́̉͋̉ͯͪ̇͊s̶̜͑̄̈́ͣ͆́̚͠e̱̯͇̖̳͖̣͇̐́̂̚͡ ̸̣̝͖̙͙̉̂͠h̠̪͕͙͎̝ͧͭ͗͠tͨ̐ͭ̀͟҉̲͎m̴̦̼͈̞̐͛̈́ͭl̷̛ͩͨ̄ͮ̋̏͌ͯ͏̱̝̜̙̙ ̧̘̬̩̩͔̫̥͒̿ͯ͋́̎ͬͫͅŵ̸̩̞̖͇̽͐ͥ̌͟ĭ̶̛̤͕͟t̡̘̥͙̳̖̦͈̦ͥͩh̘̪̪̟͋̊ͨ̈́̏ͬ ̘͚̯̬̼̍͊̓̆̅̀̿̿͡r̵̝̩̻͓̠͍͑́ė̢̛͍̺͓̯̱̝͉̳̾̀͡g̨͕̜̬͂͑͐ͬ̄ͫ͗ͫͅe̟ͮͨͨ̌̐̄x̐͏̲͖̗
 
C4u
6:38 PM
Well... then tell me how to get an element without knowing anything about it?
 
well, that was encrypted
 
4426
A: RegEx match open tags except XHTML self-contained tags

bobinceYou can't parse [X]HTML with regex. Because HTML can't be parsed by regex. Regex is not a tool that can be used to correctly parse HTML. As I have answered in HTML-and-regex questions here so many times before, the use of regex will not allow you to consume HTML. Regular expressions are a tool th...

 
You don't. HTML was not designed for querying and no reliable querying language for HTML exists
(to my knowledge)
 
C4u
Oh ok. Ill quit my job then.
^^
 
That's the spirit
 
6:39 PM
Leave now before they make you create a JS Framework
 
C4u
Not helping.
Pff.. Ill get the source and just string-split it until I get whats left. I dont mind.
 
I think we need to know more about what you're actually trying to do
 
In ASP.NET, is there a way to use the presence of query parameters to determine routing?
 
C4u
You dont. There's no way around that. Source-code -> I know the div-id -> I need the id of the last input element.
I mean. There is nothing around it. No access to anything. And no, its not my homework.
Maybe I'll just iterate the childs till the end.
 
138
A: What is the best way to parse html in C#?

Mark CidadeHtml Agility Pack This is an agile HTML parser that builds a read/write DOM and supports plain XPATH or XSLT (you actually don't HAVE to understand XPATH nor XSLT to use it, don't worry...). It is a .NET code library that allows you to parse "out of the web" HTML files. The parser is very tol...

 
6:42 PM
@MorganThrapp sure
 
@juanvan Sweet! How would I do that? Could you point me to a resource?
 
but tl;dr use some form of html parser. Don't attempt to parse it yourself
 
C4u
Nah.
Windows.Forms.HtmlElement.
 
Specifically, I need Foo/Bar?a= to route differently than Foo/Bar?b=.
 
C4u
Im getting the source through a webBrowser-Control.
So I already got the document as HtmlDocument.
 
6:44 PM
You just hit the trifecta of "shitty things to have to deal with"
 
[Route("Foo/Bar/A")] vs [Route("Foo/Bar/B")]
 
I need them to be query parameters though, I can't have them be part of the slash pattern.
 
You mean part of the URL?
 
Yeah.
 
@C4u all of the googling I'm doing is saying use HTML Agility Pack
You could do the traversal from scratch if you really hate yourself blog.olussier.net/2010/03/30/…
> The HtmlDocument object provides a getElementById method that let you target a specific node using its Id. You can use properties such as ChildNodes, FirstChild, NextSibling and ParentNode to navigate through the nodes. You can also use the Ancestors and Descendants methods to respectively get a list of all the ancestors or descendants of a node
 
C4u
6:47 PM
@mikeTheLiar I guess you are complicating things arnt you?
Missunderstood me maybe?
 
Hey, you're the one trying to parse HTML with regex.
 
C4u
I mean Ill just get the div (by id) and iterate through its childs.
Im still not parsing anything.
Im grabbing out a simple string.
I got an alternative way. Thanks for your efforts anyway. I've got some other cases that are even more complex. But I already solved them. This simple case I couldn't.
 
If you know the element's parent and you know that it's a div and you know it has an id and you know that it matches something you have and you know between zero and one child elements will match some other criterion then yeah sure, you can parse that
 
C4u
As I used regex for the others, my first try was for sure using regex again.
Well these id's are generated randomly :)
But as I already got behind that algo I havnt said anything about it.
This one wasnt about "right" or "wrong" way. I was just interested in the how-to according regex. Next time, you can annoy me again with the most effective right and correct way to go ^^.
 
The problem is that it only works in the specific cases that you've proved it to work for
Slightly different, breaks your app
 
C4u
6:54 PM
Yeah. Thats right.
But where random data is coming in it gets hard.
 
@MorganThrapp are they going to the same Action? This is MVC?
 
7:12 PM
@juanvan No, different actions. I actually figured out a way around it for the moment, thanks!
 
ok that was the real problem
 
7:35 PM
Hi. I'd to store document text into a binary column datatype in sql server. So I converted document text into an byte array and subsequently stored the byte array stream into database. However, now I'm not able to interpret the value that got stored in database in binary format. It's not making any sense to me
 
Does anyone know if C# projects just naturally compile faster than VB.NET projects? I've got two solutions, one that's exclusively C# and the other is VB.NET, the C# project will Build almost instantly while the VB.NET solution needs a good 15 seconds to build.
 
@hilli_micha the question is so vague as to be meaningless
 
Figured that'd be the answer.
I realize that there's so many variables in play here, but I was optimistically hoping for a "YEAH VB IS SUCH CRAP IT NEEDS A FEW EXTRA SECONDS TO STAVE OFF SUICIDE BEFORE BUILDING.", alas. lol
 
7:57 PM
 
8:23 PM
Why would adding & using an optional boolean parameter in a constructor cause Error CS0012 The type 'RetryPolicy' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling, Version=6.0.0.0,...?
 
@MikeAsdf can you post the ctor or at least the signature?
 
changing protected BaseDao(DatabaseName connectionName, IConfigurationAdapter configurationAdapter) into protected BaseDao(DatabaseName connectionName, IConfigurationAdapter configurationAdapter, bool herp = false)
DatabaseName is an enum
The error occurs in a subclass usage of the constructor, only if it passes the extra bool
Splitting into multiple constructors doesn't help
There's another constructor on BaseDao, which does include a RetryPolicy
But it's never provoked this ambiguity before
protected BaseDao(DatabaseName connectionName, RetryPolicy connectionRetryPolicy, RetryPolicy commandRetryPolicy, IConfigurationAdapter configurationAdapter = null)
 
I would guess that it's because there are a couple different optionals. Does herp have to be in there? If it does, then is it possible/feasible to just use herp: false or IConfigureAdapter: ca at the end of all calls?
 
removing all optional parameters (by creating more overloaded constructors) gives same error
yeah maybe I could try specifying by name...
 
Well, what about referencing them explicitly?
 
8:36 PM
referencing what?
 
If there aren't too many calls, then it wouldn't be too hard to just add them in.
var derp = BaseDao(connectionName, configurationAdapter, herp: false);
I don't know what the terminology for that is, but I use that kind of syntax sometimes, especially with some interop stuff.
 
Holy fuck, explicitly naming the arguments when calling base solves it without adding assembly references
 
Are you actually referencing the assembly in question?
 
No, why should I have to?
I never had to before without the bool arg.
 
Presumably because you're using a type from that assembly
 
8:38 PM
Yes, in another constructor
 
I have no idea why an extra parameter would change it though
 
I'm going to assume the extra one provoked the compiler to do additional constructor-scanning while attempting to do resolution
And that explicitly naming them short-circuits that
Now to add a resharper annotation comment to keep it from informing me "you don't need to name these arguments"...
 
lmao
 
@MikeAsdf we usually name arguments if they're non-descriptive like bool or something
 
Yeah that smells like a better practice than our usual bool comments: ... , false, true); //The false+true means it will also update the preferences
 
8:45 PM
@MikeAsdf you can disable it in r# config
and check it in so it is shared
 
Oh yeah, R#'s shared options is neat
 
My convention is to put things on separate lines when naming
var foo = new Foo(
    herp: true,
    derp: true);
 
Huh, I suspect triggering the error has to do with the number of arguments
Since this is the first time that a 3-argument constructor was used, aside from the RetryPolicy one
So all the 2-argument usages never caused it to attempt to resolve what a RetryPolicy is
lol, yep, adding additional (superfluous) bool arguments also avoids the error
 
9:00 PM
do you have any custom analyzers installed?
 
Like StyleCop or FxCop? nope
 
if you mean the roslyn versions yes
 
Yeah I was just looking that up
AFAIK this is vanilla msbuild
 
could be a bug in a vs analyzer
or maybe they do something really retarded with reflection so that the warning is about a real issue :D
you can ask here
or post an issue on roslyn, sounds like you have a nice repro
 
9:43 PM
Hey all ! I created a c'tor in a class 'A' that gets another class object 'B' as a parameter. now i have an object 'B'-typed in class 'A' that i want to copy all parameter values
does it need memberwiseclone() usage ?
 
@JohanLarsson Yep, I was able to create a tiny example sln easily enough
roslyn issue created
@ItayZaguri what exactly do you mean by "object 'B'-typed in class 'A' "?
 
ok, I'll stalk you from now on
 
B extends A?
gl, I'll just create more burner github accounts
Although I like how the gravitar became a :-| face
 
@MikeAsdf composition. A class has B-typed variable
 
Ah, so you're asking about how to best copy the argument B into A's variable-or-property of type B
it depends
if B is immutable, you can just assign it.
if B has only primitive & immutable properties, you can use memberwiseclone
if B has sub-objects like C and D as properties or variables, then you'll need to consider a deep cloning strategy
 
9:49 PM
actually B has sub objects
damn thats confusing so much :o
 
You can also ask yourself the question "how much do I care that this is a separate thing that other code can edit without worry of screwing up the original"
 
here is a lib that should handle that copy and other things.
probably not worth a dependency if it is only a couple of types
 
I've seen one project where they used a binary serializer to do deep cloning. We found the performance sucked with objects containing huge lists though. (like hundreds of thousands of objects)
So we made custom clone methods on those objects, and rigorous unit tests that slapped anyone that added properties without adding code to the clone methods.
 
B is actually a vehicle that has 3 childs-car motor and truck, and each child use an Engine that is a class by itself with 2 childs - fuel and electric
there are many variables involved
this is the class
public class ParkedVehicleInGarage
{

string m_OwnerName;
string m_OwnerPhone;
object m_vehicle;
carCondition m_CarCondition = carCondition.Repaired;

public ParkedVehicleInGarage(string i_OwnerName, string i_OwnersPhone,Vehicle i_Vehicle)
{
this.m_OwnerName = i_OwnerName;
this.m_OwnerPhone = i_OwnersPhone;
}
}
i don't understand how to do the copying from Vehicle i_Vehicle to m_Vehicle
 
10:04 PM
for starters, object m_vehicle; is a bad code smell. Why is it declared as an object?
Why not private Vehicle m_vehicle; ?
 
yeah my mistake forgot to remake it Vehicle
it was Vehicle i just tried something
 
do you have to copy? why not just assign it?
 
can i assign all i_Vehicle values ? it has other objects in it also
 
10:25 PM
@MikeAsdf I ask something else, i made a c'tor for a class, how can I get the c'tor to take all its' abstract base class values ?
 
ctor, c'tor looks like french :)
I don't understand the question
 
çtor
@ItayZaguri explicitly
 
lol ok
Vehicle is an abstract class and Car is derived form it , now when i create a new car i want to put Vehicle parameters as well @JohanLarsson
 
    public abstract class Vehicle
    {
        private readonly string meh;

        protected Vehicle(string meh)
        {
            this.meh = meh;
        }
    }

    pubic class Car : Vehicle
    {
        public Car(string meh)
            : base(meh)
        {
        }
    }
maybe ^ is what you want, idk
pseudo code unless it happens to compile
 
So i cant use a copy constructor ? i have to copy each variable ?
 
10:35 PM
pretty sure I did not understand the question
you can add another ctor to car:
 
you did .. this is what i'm asking . the thing is i have many variables in Vehicle class
 
public Car(car other)
    : base(other)
{
}
 
Motor and truck are also derived from it .. so i have to do the same with them ? isnt it double coding ?
 
and
protected Vehicle(Vehicle other)
    : this(other.meh)
{
}
I rarely write ctors like that but nothing wrong with it
like mike said, this is going to need tests
probably tests using reflection and maybe autofixture
if you can make the stuff immutable things become trivial and beautiful
 
so how u do it usually ? copying all the parameters for each class ?
 
10:42 PM
for cloning serialize/deserialize as mike suggested is the first thing that comes to mind
 
i havent studied that
 
wwhoops, I somehow missed this when searching for preexisting roslyn issues github.com/dotnet/roslyn/issues/9370
Apparently it's a known breaking change
 
hard to find it
they could have fixed the bug if they wanted to avoid dupes :)
 
@JohanLarsson this is my ctor for car:
public Car(string i_ModelName, string i_RegistrationName, float i_PowerLeftPercentage, Engine i_Engine, int i_NumOfDoors, color i_Color, Wheel i_Wheel)

While ModelName,RegistrationName,PowerLeft,Engine are in Vehicle
i guess its not the right way to do that
 
what would you name a parameter of type phone?
 
10:49 PM
what do you mean ?
 
just a lame joke caused you your i_x naming convention, sry about that
 
lol .. my lecturer has specific rules
 
tell him to install stylecop and learn a more widespread convention
 
the thing is - is it ok to have it like that or do i need to use a Vehicle ctor for its variables ?
yeah he told us to use that
 
ok, good
 
10:52 PM
i actually failed last project because I didnt use that
 
that is a little harsh perhaps
 
I made a freaking Othello game and he failed me for not using that lol
 
@ItayZaguri Vehicle needs a ctor for initializing its private and readonly members
 
so how i replace all these parameters ?
with Vehicle i_Vehicle?
 
if you decide to do copy ctors you should chain them
 
10:55 PM
Is there a more standard way than copy ctors ?
 
    protected Vehicle(Vehicle other)
        : this(other.meh)
    {
    }

    protected Vehicle(string meh)
    {
        this.meh = meh;
    }
@ItayZaguri if things are seralizable for other reasons maybe serialize/deserialize is more standard but I don't know
there is also IClonable but it is not very nice
the smell in your code is perhaps the need to copy things in the first place
if they were immutable the references could be shared
now when you copy things risk getting out of sync
 
@JohanLarsson what do you mean by copying things ?
 
I disliked the old MS C++ convention of putting m_ in front of member variables. I REALLY hate it in C#. :{
 
@ItayZaguri I must try to sleep here, night
 
@ItayZaguri He means basically creating a whole new object in memory that matches the other object as opposed to a copy of the reference.
 
11:08 PM
public static IEnumerable<TBase> Upcast<TBase, TDerived>(this IEnumerable<TDerived> @this) where TDerived : class, TBase
{
	return @this;
}
^ is there a way to make this code not require passing the second type parameter?
(i.e. making it so enumerable_of_strings.Upcast<object>() is legal)
 
Can you not use linq for some reason?
 
@JohanLarsson night.. thanks
 
@milleniumbug Why do you need to have an upcast method?
 
Linq has a Cast<>() method
 
You can just assign an IEnumerable<Derived> to a variable of type IEnumerable<Base>
Due to covariance or contravariance (I forget which term)
 
My point is if you're trying to cast up instead of down, you don't even need a cast.
 
@MikeAsdf .Cast<>, and others will compile if the target type is derived. that one will not
 
my dotnetfiddle compiles
oh and I see you're just returning @this
maybe I'm misunderstanding the need
 
@MikeAsdf can't .Concat() a enumerable of DirectoryInfo with an enumerable of FileInfo, so I need to upcast
 
ah
 
11:16 PM
currently doing dir.EnumerateDirectories().Select((FileSystemInfo f) => f).Concat(dir.EnumerateFiles())
but that doesn't seem to convey the purpose
so I wanted to name it
maybe I'll assign to a named variable instead
 
I can see the appeal in such a thing, but I'm not sure how to get away from needing to pass the 2nd generic arg
 
They share a common base class
 
since as far as I know if you pass one generic arg you pass them all
 
@MikeAsdf it's okay, that's all I needed to know
 
One sec
 
11:21 PM
You're only allowed a freebie if the compiler can infer all the generic args at once
@milleniumbug wait I've got it dotnetfiddle.net/LAulIi
Just leave it at one generic arg and the compiler doesn't care
 
hehe, that one was simpler than I thought
thanks
 
thanks covariance
 
Or this
If you have to use var for some reason
 
11:41 PM
Kind of a long shot here, but does anyone know of a good way to provide a common base class/functionality when using soap web services where the endpoints are broken up by functionality? In my scenario the responses and requests have a lot of identical things in common but since they live in different namespaces (the service reference generator doesn't combine very nicely) it doesn't quite work.
 
Could you pull the objects into a separate project?
 
I could, but trying to find a way to do this without manually creating the objects/wsdl each time
there's a lot of code there
each wsdl service reference has ~20k lines of code
 
Still thinking your best bet is somehow pulling the similar members out of both the request and response and using it as a base class in a separate project.
You could try using reflection to compare the request and response objects, find identical members and then build out the class using the info.
 
yeah that's what I'm actually trying now
seeing how that works
the reflection
I thought about pulling out the members, but if I had to do that I'll probably just keep repeating the code in this case since it would be less effort
tried playing around with the partial class and a common interface but didn't quite work as expected
 
Hey All , I got this Constructor

public Car(Vehicle i_Vehicle, int i_NumOfDoors, color i_Color, Rim i_Rim)
: base(i_Vehicle.ModelName,i_Vehicle.RegistrationNumber,i_Vehicle.PowerLeftPercentage, i_Vehicle.Engine)
Vehicle is an Abstract Class , how can i Initialize a car ?
when i type Vehicle car = new Car(...) i cant pass values to Vehicle's Constructor
And i cant make a new Vehicle inside the () because it's an abstract class
 
11:56 PM
You can't
Unless you have a class that can make a dummy Vehicle
 
so what's the Alternative for that ?
 

« first day (2293 days earlier)      last day (2661 days later) »