Browsing 16016 questions and answers with Jon Skeet

Avoid Google Calendar API adding an actual event in peoples calendars?

I am using the Google Calendar API with a service account. Idea is that we want to use it purely as an API backend, so we don't have to code it ourselves. That means we do not...
Jon Skeet
people
quotationmark

It sounds like your application needs its own calendar - so create one (see Calendars.insert for how to do this programmatically). Whether you need a single calendar for the whole application, regardless of user (in which case you'd... more 10/16/2017 4:45:38 PM

people

GetMethod equivalent in .NET Standard

In .NET Framework you can easily reflect methods. E.g.: var methodInfo = typeof(object).GetMethod("MemberwiseClone", bindingFlags); In a .NET Standard project, however, the...
Jon Skeet
people
quotationmark

For almost all reflection in .NET Core 1.x, you need a TypeInfo instead of Type. There's an extension method of GetTypeInfo in the System.Reflection namespace, so you want: using System.Reflection; // For GetTypeInfo ... var methodInfo =... more 10/16/2017 11:36:51 AM

people

name of class with generic parameters?

I'm trying to generate code for series of generic classes using T4. I want to know how to get full class name using reflection? public class Foo<TFirst, TSecond> {} var...
Jon Skeet
people
quotationmark

You can access the type parameter names by reflection using Type.GetGenericArguments: using System; public class Foo<TFirst, TSecond> {} class Test { static void Main() { var type = typeof(Foo<,>); ... more 10/14/2017 2:18:28 PM

people

does task.delay infinite code after it executed?

Just a quick question. We're having some misunderstanding here. for simplicity some code is removed: public async Task ConsumeAsync<T>(CancellationToken...
Jon Skeet
people
quotationmark

Should the last logline be logged or not when a cancel is requested? No, because the task returned by Task.Delay will be faulted, as is normal when a task is cancelled. more 10/11/2017 7:14:16 AM

people

Difference between suppressedException and cause

I have my own exception, thrown by my class, BrowserException. It may be because some internal problem, i.e. UnsupporderEncodingException. Now I have 2 options: ...
Jon Skeet
people
quotationmark

A suppressed exception is one which would have happened if another exception hadn't occurred. I'm only aware of one case where this happens, which is with a try-with-resources statement. The JLS (14.20.3) says: Resources are closed in... more 10/11/2017 7:12:33 AM

people

Joda time off by one error when counting days after 1918 03 24

Calculating the number of days between 1900-01-01 and a date after 1918-03-24 using Joda-Time seems to give an off-by-one result. Using Java 8 java.time gives the correct result....
Jon Skeet
people
quotationmark

The problem is that your DateTimeFormatter is using the system default time zone. Ideally, you should parse to LocalDate values instead of DateTime, but you can fix it by using UTC for the formatter anyway: DateTimeFormatter dateDecoder =... more 10/10/2017 9:54:20 AM

people

java: timezone getTimeZone("GMT 0700")' timezone useDaylight incorrect

I want to get the time zone information for Los Angeles, now 10/10/2017 is daylight saving time, But I got a different result when I got the time zone in Los Angeles in two...
Jon Skeet
people
quotationmark

I want to get the time zone information for Los Angeles, now 10/10/2017 is daylight saving time So you should ask for the "America/Los_Angeles" zone. That's what it's there for. The "GMT-07:00" zone is a fixed-offset zone - it's only... more 10/10/2017 7:25:07 AM

people

C# ValueTuple properties naming

I'm trying ValueTuple Class in C#, and i have a doubt about properties naming, let's see: If instantiate a ValueTuple declaring the object like this: var tuple1 = (Name: "Name1",...
Jon Skeet
people
quotationmark

There are two different "kinds" of tuples involved here: the .NET ValueTuple<...> types, and C# tuple types. C# tuple types can have element names; ValueTuple<...> types can't. (There's simply nowhere in the type system for... more 10/6/2017 9:03:45 AM

people

ObjectOutputStream does not write objects when taking BufferedOutputStream

I've done my research but it seems I can't find enough documentation on the subject. When trying out some code on Object streams, I came to notice that putting a...
Jon Skeet
people
quotationmark

You're trying to create the ObjectInputStream on the same file that you're writing to - you never even get into the body of your try-with-resources block. Here's what happens: Create the FileOutputStream: file is empty Wrap it in... more 10/5/2017 2:56:56 PM

people

Object from class library not contains methods

Trying to build and use class library in C#. Creating class library: File-New Project-Windows-Classic Desktop-Class Library Code: namespace ClassLibrary2 { public class...
Jon Skeet
people
quotationmark

Add is a static method. You can't call static methods "via" instances in C#. That has nothing to do with it being in a different library. You can call the method as: long result = ClassLibrary2.Class1.Add(10, 20); or if you actually... more 10/5/2017 9:22:33 AM

people