These are chat archives for Ruhrpottpatriot/GW2.NET

4th
Oct 2015
Steven Liekens
@StevenLiekens
Oct 04 2015 07:25
I'll make a separate script that creates a config file for all .nupkg files in the same directory as the script
that way you can still tweak what gets added to the config after running NuGetPackEverything
Steven Liekens
@StevenLiekens
Oct 04 2015 07:45
@Ruhrpottpatriot this package looks like it replaces the old compiler in VS2013 with roslyn https://www.nuget.org/packages/Microsoft.Net.Compilers/
meaning C# 6 support even in VS2013
Steven Liekens
@StevenLiekens
Oct 04 2015 11:19
there seems to be a bug in nuget.exe that prevents us from packing PCL assemblies
but when I build nuget.exe from source and run it again, the problem disappears
so wtf
it works in 3.0.0-preview but not in the official 3.2.0
wtf nuget...
Steven Liekens
@StevenLiekens
Oct 04 2015 13:25
ok well, looks like we have to wait for a fix before we can publish packages for 2.0.0
or use a nuget.exe that was compiled from the latest sources
Robert Logiewa
@Ruhrpottpatriot
Oct 04 2015 14:39
ok
I'm currently thinking, where I could put the schema validation in the code
Steven Liekens
@StevenLiekens
Oct 04 2015 14:51
uhm
well
that might be difficult
we don't buffer the json string anywhere
Robert Logiewa
@Ruhrpottpatriot
Oct 04 2015 14:52
it has to be before we convert
Steven Liekens
@StevenLiekens
Oct 04 2015 14:53
the response stream is passed to json.net
i don't know if we can pass a schema
Robert Logiewa
@Ruhrpottpatriot
Oct 04 2015 14:54
i think I have an idea
Steven Liekens
@StevenLiekens
Oct 04 2015 14:55
what is it
Robert Logiewa
@Ruhrpottpatriot
Oct 04 2015 14:55
naw, does not work
I thought I could Intercept before the conversion, but then we already populated the json object
Steven Liekens
@StevenLiekens
Oct 04 2015 14:56
the problem is that the response stream can only be read once
Robert Logiewa
@Ruhrpottpatriot
Oct 04 2015 14:56
then we have to save the stream into a local variable
Steven Liekens
@StevenLiekens
Oct 04 2015 14:56
yeah but that kills performance
there's a reason why the library is as fast as it is
the json doesn't get buffered into memory
Robert Logiewa
@Ruhrpottpatriot
Oct 04 2015 14:57
couldn't we just read the stream as a string?
brb in 2 min
Steven Liekens
@StevenLiekens
Oct 04 2015 14:57
same thing, kills performance
especially for bulk expanded responses with up to 200 items
Robert Logiewa
@Ruhrpottpatriot
Oct 04 2015 15:00
then we basically give up any possibility of validating the json.
Steven Liekens
@StevenLiekens
Oct 04 2015 15:00
how about if instead of adding schema validation to the core library, we write specialized tests that do schema validation for all endpoints?
did you want to change how the code behaves based on the schema?
Robert Logiewa
@Ruhrpottpatriot
Oct 04 2015 15:01
My train of thought was the following:
  1. Call the api and get the schema
  2. Call the api and get the response
  3. Validate the response with the schema
  4. If the result is valid, deserialise, if not, either throw an exception or return the default
Steven Liekens
@StevenLiekens
Oct 04 2015 15:02
why would the result ever be invalid if we always get the most up to date schema?
Robert Logiewa
@Ruhrpottpatriot
Oct 04 2015 15:02
a bad api result?
Steven Liekens
@StevenLiekens
Oct 04 2015 15:03
try
  1. call the api and get the response
  2. validate the response with the schema that the code was written for
Robert Logiewa
@Ruhrpottpatriot
Oct 04 2015 15:03
or like this
we could locally save the schema
since Iye basically confimed that it is not going to change much
but it is a good way to validate api results
hah
we might have a way
JSchema schema = JsonSchema.Parse(@"{
  'type': 'array',
  'item': {'type':'string'}
}");
JsonTextReader reader = new JsonTextReader(new StringReader(@"[
  'Developer',
  'Administrator'
]"));

JSchemaValidatingReader validatingReader = new JSchemaValidatingReader(reader);
validatingReader.Schema = schema;

JsonSerializer serializer = new JsonSerializer();
List<string> roles = serializer.Deserialize<List<string>>(validatingReader);
JSON.NET offers a validating reader
Steven Liekens
@StevenLiekens
Oct 04 2015 15:05
great
Robert Logiewa
@Ruhrpottpatriot
Oct 04 2015 15:05
we read the json in the service client, right?
Steven Liekens
@StevenLiekens
Oct 04 2015 15:06
yea
Robert Logiewa
@Ruhrpottpatriot
Oct 04 2015 15:06
So, we have to pass a validating reader to the service client
Steven Liekens
@StevenLiekens
Oct 04 2015 15:06
kinda
the service client has a reference to ISerializerFactory
the factory is where you create the reader object
I'm not yet sure how you would pass the schema
I feel like this stuff would be easier with HttpClient
because then you could write a custom HttpMessageHandler that does everything
or better yet
a custom message handler for each schema that needs to be handled
Robert Logiewa
@Ruhrpottpatriot
Oct 04 2015 15:15
paraphrize how the code would change, if we move to HttpClient
Steven Liekens
@StevenLiekens
Oct 04 2015 15:16
HttpClient replaces IServiceClient, HttpRequestMessage replaces IRequest, HttpResponseMessage replaces IResponse
I don't expect it to be wildly different from what we have already
just, more thought out
Robert Logiewa
@Ruhrpottpatriot
Oct 04 2015 15:19
Let me try that in Builds
Robert Logiewa
@Ruhrpottpatriot
Oct 04 2015 15:26
One thing though
we have the option to only read headers with HttpClient
we don't need that now, but if we want to parse the link headers we need to put that in somewhere
we could do that in the repositories, but you will agree that that is bad
Steven Liekens
@StevenLiekens
Oct 04 2015 15:31
well I've always wanted an option to only get the context info from an endpoint
because right now if you want to know the value of the X- headers then you need to download the entire response and then discard it
Robert Logiewa
@Ruhrpottpatriot
Oct 04 2015 15:31
I know, but that would mean, we cannot directly replace IServiceClient with HttpClient
Steven Liekens
@StevenLiekens
Oct 04 2015 15:32
why not
Robert Logiewa
@Ruhrpottpatriot
Oct 04 2015 15:32
we then would have the implement the whole "get headers and parse them" in all repositories
Steven Liekens
@StevenLiekens
Oct 04 2015 15:32
no you have custom handlers for that
write a class that extends HttpMessageHandler
in that class, parse the header
then in the bootstrapper, configure HttpClient to use the custom handler
Robert Logiewa
@Ruhrpottpatriot
Oct 04 2015 15:35
yeah i know you can pass a custom messagehandler to the httpclient
Steven Liekens
@StevenLiekens
Oct 04 2015 15:35
yeah
Steven Liekens
@StevenLiekens
Oct 04 2015 15:56
lol look what I did to SkinRepository
on master
if (responseConverter == null)
{
    throw new ArgumentNullException("responseConverter");
    throw new ArgumentNullException(nameof(responseConverter));
}
Robert Logiewa
@Ruhrpottpatriot
Oct 04 2015 15:57
hehe
yeah
Steven Liekens
@StevenLiekens
Oct 04 2015 15:57
facepalm
Robert Logiewa
@Ruhrpottpatriot
Oct 04 2015 15:58
btw: not in my master
Steven Liekens
@StevenLiekens
Oct 04 2015 15:59
V2?
Robert Logiewa
@Ruhrpottpatriot
Oct 04 2015 15:59
whoops
yeah
I see it now
Steven Liekens
@StevenLiekens
Oct 04 2015 16:00
and that is why you shouldn't write code when you're tired
Steven Liekens
@StevenLiekens
Oct 04 2015 16:14
should we remove synchronous methods ?
the guideline is to expose long running operations ( > 15 ms) as Task
so we probably shouldn't have synchronous FindPage and FindAll methods
Robert Logiewa
@Ruhrpottpatriot
Oct 04 2015 17:04
Damn... I simply cannot get a custom httpmessagehandler to work
and there are no good tutorials on that out there
you got any documents on that?
Steven Liekens
@StevenLiekens
Oct 04 2015 17:16
no
Robert Logiewa
@Ruhrpottpatriot
Oct 04 2015 17:16
damn
I'll try a bit more then
Steven Liekens
@StevenLiekens
Oct 04 2015 17:19
don't get hung up on the details yet
Steven Liekens
@StevenLiekens
Oct 04 2015 17:25
can you do something?
run Update-Package -Reinstall
and check in the changes to all packages.config files
I'm getting weird errors and I think it's because the targetFramework value is wrong everywhere
Steven Liekens
@StevenLiekens
Oct 04 2015 17:47
 Unable to find package 'StyleCop.Analyzers'.
mmm
All packages listed in packages.config are already installed.
mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
Steven Liekens
@StevenLiekens
Oct 04 2015 17:57
OH WELL EXCUSE ME THEN
apparently you got to be explicit and add -Prerelease
or it will complain that the package does not exist
Update-Package -Reinstall -Prerelease
I've just about had it with nuget today

Robert Logiewa
@Ruhrpottpatriot
Oct 04 2015 18:21
lol
Steven Liekens
@StevenLiekens
Oct 04 2015 18:21
not funny
Steven Liekens
@StevenLiekens
Oct 04 2015 18:47
I'm gonna fix everything that I think is wrong with the config/csproj/sln files and submit it all in one PR
Robert Logiewa
@Ruhrpottpatriot
Oct 04 2015 19:23
ok
Steven Liekens
@StevenLiekens
Oct 04 2015 20:44
that one test project is now a PCL too
Steven Liekens
@StevenLiekens
Oct 04 2015 20:54
the diff is messed up again
I don't know why it does that
change in whitespace maybe?