Skip to content

Commit 45b2209

Browse files
author
Caitlin Bales (MSFT)
authored
Merge pull request #170 from microsoftgraph/dev
August Updates
2 parents 7330fe7 + 6889f68 commit 45b2209

File tree

176 files changed

+3831
-90
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

176 files changed

+3831
-90
lines changed

docs/FAQ.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Frequently Asked Questions
2+
3+
## How do I get past the System.IO.FileLoadException
4+
5+
We built the .Net Microsoft Graph client library against a specific version of the JSON.Net library. That version is specified in the .Net client library assembly manifest. We specify a range of potential JSON.Net versions that can be used by our client library in our Nuget package specification.
6+
7+
Your project may already have a reference to JSON.Net. When you add the Microsoft Graph library via Nuget, Nuget won't install the JSON.Net dependency that was used to build the Microsoft Graph library <u>when</u> you already have a reference to JSON.Net in your project. This may lead to a FileLoadException as the CLR will try to load the version used to build the Microsoft Graph library and won't find it in the case that your project reference to JSON.Net is different than the version of JSON.Net used to build the Microsoft Graph library.
8+
9+
You have three options to get around this scenario:
10+
11+
1. Add a [binding redirect to your application](https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/redirect-assembly-versions#redirecting-assembly-versions-at-the-app-level) to unify the version of JSON.Net used by your application.
12+
2. [Assembly resolution at runtime](https://docs.microsoft.com/en-us/dotnet/framework/app-domains/resolve-assembly-loads) if the binding redirect option is not available. Here's an [AssemblyResolutionDemo](https://github.com/danmalcolm/AssemblyResolutionDemo) that shows how this works.
13+
3. Change the version of the JSON.Net dependency in your project to match the version used by Microsoft Graph .Net client library. This will be your only option for UWP applications at the time of this writing.

docs/overview.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ To begin making requests with the library, you will need to initialize a **Graph
2626

2727
## IAuthenticationProvider
2828

29-
The authentication provider is responsible for authenticating requests before sending them to the service. The Microsoft Graph .NET Client Library doesn't implement any authentication by default. Instead, you will need to retrieve access tokens for the service via the authentication library of their choice or by coding against one of the authentication endpoints directly. Please [read here](https://graph.microsoft.io/en-us/docs/authorization/app_authorization) for more details about authenticating the Microsoft Graph service.
29+
The authentication provider is responsible for authenticating requests before sending them to the service. The Microsoft Graph .NET Client Library doesn't implement any authentication by default. Instead, you will need to retrieve access tokens for the service via the authentication library of your choice or by coding against one of the authentication endpoints directly. Please [read here](https://graph.microsoft.io/en-us/docs/authorization/app_authorization) for more details about authenticating the Microsoft Graph service.
3030

3131
### DelegateAuthenticationProvider
3232

@@ -94,7 +94,7 @@ var calendar = await graphServiceClient
9494
.GetAsync();
9595
```
9696

97-
Any errors while building or sending a request will bubble up as a `ServiceException`. See [errors](/docs/errors.md) on for more information on errors.
97+
Any errors while building or sending a request will bubble up as a `ServiceException`. See [errors](/docs/errors.md) for more information on errors.
9898

9999
## Query options
100100

@@ -112,6 +112,20 @@ All properties other than `Id` will be null on the returned user object.
112112

113113
Expand, Skip, Top, OrderBy, and Filter are also supported via the client library when supported by the Microsoft Graph service for the request type.
114114

115+
## Custom query options
116+
117+
If you need to include more specific behavior during a request that is not supported by the library, you can create a custom queryOptions List that you can add when calling ```Request```:
118+
119+
```chsarp
120+
List<QueryOption> options = new List<QueryOption>
121+
{
122+
new QueryOption("$search", "lunch")
123+
};
124+
var messages = await client.Me.Messages.Request(options).GetAsync();
125+
```
126+
127+
128+
115129
## Collections
116130

117131
Please see [collections](/docs/collections.md) for details on collections and paging.

docs/readme.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Microsoft Graph .Net Client Library
2+
3+
* [Overview](./overview.md)
4+
* [Collections](./collections.md)
5+
* [Errors](./errors.md)
6+
* [Contributions](./contributions.md)
7+
* [FAQ](./FAQ.md)
8+
9+
## How do I work with...
10+
11+
### OneDrive
12+
13+
* [Download a large file from OneDrive](#downloadLargeFile)
14+
15+
16+
17+
18+
19+
20+
<a name="downloadLargeFile"></a>
21+
### Download a large file from OneDrive
22+
23+
```csharp
24+
// Based on question by Pavan Tiwari, 11/26/2012, and answer by Simon Mourier
25+
// https://stackoverflow.com/questions/13566302/download-large-file-in-small-chunks-in-c-sharp
26+
27+
const long DefaultChunkSize = 50 * 1024; // 50 KB, TODO: change chunk size to make it realistic for a large file.
28+
long ChunkSize = DefaultChunkSize;
29+
long offset = 0; // cursor location for updating the Range header.
30+
byte[] bytesInStream; // bytes in range returned by chunk download.
31+
32+
// Get the collection of drive items. We'll only use one.
33+
IDriveItemChildrenCollectionPage driveItems = await graphClient.Me.Drive.Root.Children.Request().GetAsync();
34+
35+
foreach (var item in driveItems)
36+
{
37+
// Let's download the first file we get in the response.
38+
if (item.File != null)
39+
{
40+
// We'll use the file metadata to determine size and the name of the downloaded file
41+
// and to get the download URL.
42+
var driveItemInfo = await graphClient.Me.Drive.Items[item.Id].Request().GetAsync();
43+
44+
// Get the download URL. This URL is preauthenticated and has a short TTL.
45+
object downloadUrl;
46+
driveItemInfo.AdditionalData.TryGetValue("@microsoft.graph.downloadUrl", out downloadUrl);
47+
48+
// Get the number of bytes to download. calculate the number of chunks and determine
49+
// the last chunk size.
50+
long size = (long)driveItemInfo.Size;
51+
int numberOfChunks = Convert.ToInt32(size / DefaultChunkSize);
52+
// We are incrementing the offset cursor after writing the response stream to a file after each chunk.
53+
// Subtracting one since the size is 1 based, and the range is 0 base. There should be a better way to do
54+
// this but I haven't spent the time on that.
55+
int lastChunkSize = Convert.ToInt32(size % DefaultChunkSize) - numberOfChunks - 1;
56+
if (lastChunkSize > 0) { numberOfChunks++; }
57+
58+
// Create a file stream to contain the downloaded file.
59+
using (FileStream fileStream = System.IO.File.Create((@"C:\Temp\" + driveItemInfo.Name)))
60+
{
61+
for (int i = 0; i < numberOfChunks; i++)
62+
{
63+
// Setup the last chunk to request. This will be called at the end of this loop.
64+
if (i == numberOfChunks - 1)
65+
{
66+
ChunkSize = lastChunkSize;
67+
}
68+
69+
// Create the request message with the download URL and Range header.
70+
HttpRequestMessage req = new HttpRequestMessage(HttpMethod.Get, (string)downloadUrl);
71+
req.Headers.Range = new System.Net.Http.Headers.RangeHeaderValue(offset, ChunkSize + offset);
72+
73+
// We can use the the client library to send this although it does add an authentication cost.
74+
// HttpResponseMessage response = await graphClient.HttpProvider.SendAsync(req);
75+
// Since the download URL is preauthenticated, and we aren't deserializing objects,
76+
// we'd be better to make the request with HttpClient.
77+
var client = new HttpClient();
78+
HttpResponseMessage response = await client.SendAsync(req);
79+
80+
using (Stream responseStream = await response.Content.ReadAsStreamAsync())
81+
{
82+
bytesInStream = new byte[ChunkSize];
83+
int read;
84+
do
85+
{
86+
read = responseStream.Read(bytesInStream, 0, (int)bytesInStream.Length);
87+
if (read > 0)
88+
fileStream.Write(bytesInStream, 0, bytesInStream.Length);
89+
}
90+
while (read > 0);
91+
}
92+
offset += ChunkSize + 1; // Move the offset cursor to the next chunk.
93+
}
94+
}
95+
return;
96+
}
97+
}
98+
```
99+
100+
101+

src/Microsoft.Graph.Core/Microsoft.Graph.Core.csproj

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,15 @@
88
<AssemblyVersion>1.5.0</AssemblyVersion>
99
<Authors>Microsoft</Authors>
1010
<TargetFrameworks>netstandard1.1;net45</TargetFrameworks>
11+
<PreserveCompilationContext>false</PreserveCompilationContext>
1112
<AssemblyName>Microsoft.Graph.Core</AssemblyName>
1213
<PackageId>Microsoft.Graph.Core</PackageId>
1314
<PackageTags>Microsoft Office365;Graph;GraphServiceClient;Outlook;OneDrive;AzureAD;GraphAPI;Productivity;SharePoint;SDK</PackageTags>
1415
<PackageReleaseNotes>
15-
June 2017 Release Summary (version 1.5.0)
16+
August 2017 Release Summary (version 1.6.0)
1617

17-
New features
18-
19-
* Support for posting multipart content.
20-
21-
Bug fixes
22-
23-
* Boolean query string parameters are no longer emitted in upper case.
24-
25-
</PackageReleaseNotes>
18+
New Features
19+
* Added Intellisense file to package</PackageReleaseNotes>
2620
<PackageProjectUrl>https://graph.microsoft.io</PackageProjectUrl>
2721
<PackageLicenseUrl>http://aka.ms/devservicesagreement</PackageLicenseUrl>
2822
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
@@ -36,20 +30,33 @@
3630
<GenerateNeutralResourcesLanguageAttribute>false</GenerateNeutralResourcesLanguageAttribute>
3731
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
3832
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
33+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
3934
<SignAssembly>False</SignAssembly>
4035
<DelaySign>True</DelaySign>
4136
<AssemblyOriginatorKeyFile>35MSSharedLib1024.snk</AssemblyOriginatorKeyFile>
37+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
38+
<Version>1.6.0</Version>
39+
</PropertyGroup>
40+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netstandard1.1|AnyCPU'">
41+
<DocumentationFile>bin\Release\netstandard1.1\Microsoft.Graph.Core.xml</DocumentationFile>
42+
</PropertyGroup>
43+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netstandard1.1|AnyCPU'">
44+
<DocumentationFile>bin\Debug\netstandard1.1\Microsoft.Graph.Core.xml</DocumentationFile>
45+
</PropertyGroup>
46+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net45|AnyCPU'">
47+
<DocumentationFile>bin\Release\net45\Microsoft.Graph.xml</DocumentationFile>
48+
</PropertyGroup>
49+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net45|AnyCPU'">
50+
<DocumentationFile>bin\Debug\net45\Microsoft.Graph.xml</DocumentationFile>
4251
</PropertyGroup>
4352

4453
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
4554
<Reference Include="System.Net.Http" />
4655
<Reference Include="System" />
4756
<Reference Include="Microsoft.CSharp" />
48-
<PackageReference Include="Newtonsoft.Json" Version="10.0.2" />
57+
<PackageReference Include="Newtonsoft.Json" Version="[6.0.1,10.0.2]" />
4958
</ItemGroup>
50-
5159
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.1' ">
52-
<PackageReference Include="Newtonsoft.Json" Version="10.0.2" />
60+
<PackageReference Include="Newtonsoft.Json" Version="[9.0.1,10.0.2]" />
5361
</ItemGroup>
54-
5562
</Project>

src/Microsoft.Graph.Core/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
//
2525
// You can specify all the values or you can default the Build and Revision Numbers
2626
// by using the '*' as shown below:
27-
[assembly: AssemblyVersion("1.5.0")]
28-
[assembly: AssemblyFileVersion("1.5.0.0")]
27+
[assembly: AssemblyVersion("1.6.0")]
28+
[assembly: AssemblyFileVersion("1.6.0.0")]
2929

3030
#if DEBUG
3131
[assembly: InternalsVisibleTo("Microsoft.Graph.Core.Test")]

src/Microsoft.Graph.Core/Requests/Options/Option.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
namespace Microsoft.Graph
66
{
7-
public class Option
7+
public abstract class Option
88
{
9-
public Option(string name, string value)
9+
protected Option(string name, string value)
1010
{
1111
this.Name = name;
1212
this.Value = value;

src/Microsoft.Graph/Microsoft.Graph.csproj

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,16 @@
99
<AssemblyVersion>1.4.0</AssemblyVersion>
1010
<Authors>Microsoft</Authors>
1111
<TargetFrameworks>netstandard1.1;net45</TargetFrameworks>
12+
<PreserveCompilationContext>false</PreserveCompilationContext>
1213
<AssemblyName>Microsoft.Graph</AssemblyName>
1314
<PackageId>Microsoft.Graph</PackageId>
1415
<PackageTags>Microsoft Office365;Graph;GraphServiceClient;Outlook;OneDrive;AzureAD;GraphAPI;Productivity;SharePoint;SDK</PackageTags>
15-
<PackageReleaseNotes>
16-
June 2017 Release Summary (version 1.4.0)
16+
<PackageReleaseNotes>August 2017 Release Summary (version 1.5.0)
1717

1818
New features
19-
20-
* OneNote
21-
* Open extensions
22-
* Schema extensions
23-
24-
Updates
25-
26-
* Provided example and tests for scenarios where Microsoft.Graph client library request builders don't support functionality. This way you can make use of the serializer and authentication provider.
27-
* The service metadata doesn't support GetByPath for getting SharePoint sites by relative path. Added functionality to enable this.
28-
* Added FindMeetingTimes test.
29-
30-
Bug fixes
31-
32-
* Large file uploads larger than 2GB is enabled.
33-
34-
</PackageReleaseNotes>
19+
* Access OneNote notebooks through SharePoint
20+
* New Groups functionality
21+
* Added Intellisense file</PackageReleaseNotes>
3522
<PackageProjectUrl>https://graph.microsoft.io</PackageProjectUrl>
3623
<PackageLicenseUrl>http://aka.ms/devservicesagreement</PackageLicenseUrl>
3724
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
@@ -45,9 +32,16 @@
4532
<GenerateNeutralResourcesLanguageAttribute>false</GenerateNeutralResourcesLanguageAttribute>
4633
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
4734
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
35+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
4836
<SignAssembly>False</SignAssembly>
4937
<DelaySign>True</DelaySign>
5038
<AssemblyOriginatorKeyFile>35MSSharedLib1024.snk</AssemblyOriginatorKeyFile>
39+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
40+
<Version>1.5.0</Version>
41+
</PropertyGroup>
42+
43+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netstandard1.1|AnyCPU'">
44+
<DocumentationFile>bin\Release\Microsoft.Graph.xml</DocumentationFile>
5145
</PropertyGroup>
5246

5347
<ItemGroup>
@@ -62,11 +56,9 @@
6256
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
6357
<Reference Include="System" />
6458
<Reference Include="Microsoft.CSharp" />
65-
<PackageReference Include="Newtonsoft.Json" Version="10.0.2" />
59+
<PackageReference Include="Newtonsoft.Json" Version="[6.0.1,10.0.2]" />
6660
</ItemGroup>
67-
6861
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.1' ">
69-
<PackageReference Include="Newtonsoft.Json" Version="10.0.2" />
62+
<PackageReference Include="Newtonsoft.Json" Version="[9.0.1,10.0.2]" />
7063
</ItemGroup>
71-
7264
</Project>

src/Microsoft.Graph/Models/Generated/AssignedLicense.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ public partial class AssignedLicense
2424

2525
/// <summary>
2626
/// Gets or sets disabledPlans.
27+
/// A collection of the unique identifiers for plans that have been disabled.
2728
/// </summary>
2829
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "disabledPlans", Required = Newtonsoft.Json.Required.Default)]
2930
public IEnumerable<Guid> DisabledPlans { get; set; }
3031

3132
/// <summary>
3233
/// Gets or sets skuId.
34+
/// The unique identifier for the SKU.
3335
/// </summary>
3436
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "skuId", Required = Newtonsoft.Json.Required.Default)]
3537
public Guid? SkuId { get; set; }

src/Microsoft.Graph/Models/Generated/AssignedPlan.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,28 @@ public partial class AssignedPlan
2424

2525
/// <summary>
2626
/// Gets or sets assignedDateTime.
27+
/// The date and time at which the plan was assigned; for example: 2013-01-02T19:32:30Z. The Timestamp type represents date and time information using ISO 8601 format and is always in UTC time. For example, midnight UTC on Jan 1, 2014 would look like this: '2014-01-01T00:00:00Z'
2728
/// </summary>
2829
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "assignedDateTime", Required = Newtonsoft.Json.Required.Default)]
2930
public DateTimeOffset? AssignedDateTime { get; set; }
3031

3132
/// <summary>
3233
/// Gets or sets capabilityStatus.
34+
/// For example, “Enabled”.
3335
/// </summary>
3436
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "capabilityStatus", Required = Newtonsoft.Json.Required.Default)]
3537
public string CapabilityStatus { get; set; }
3638

3739
/// <summary>
3840
/// Gets or sets service.
41+
/// The name of the service; for example, “Exchange”.
3942
/// </summary>
4043
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "service", Required = Newtonsoft.Json.Required.Default)]
4144
public string Service { get; set; }
4245

4346
/// <summary>
4447
/// Gets or sets servicePlanId.
48+
/// A GUID that identifies the service plan.
4549
/// </summary>
4650
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "servicePlanId", Required = Newtonsoft.Json.Required.Default)]
4751
public Guid? ServicePlanId { get; set; }

src/Microsoft.Graph/Models/Generated/Attachment.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,30 +28,35 @@ protected internal Attachment()
2828

2929
/// <summary>
3030
/// Gets or sets last modified date time.
31+
/// The Timestamp type represents date and time information using ISO 8601 format and is always in UTC time. For example, midnight UTC on Jan 1, 2014 would look like this: '2014-01-01T00:00:00Z'
3132
/// </summary>
3233
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "lastModifiedDateTime", Required = Newtonsoft.Json.Required.Default)]
3334
public DateTimeOffset? LastModifiedDateTime { get; set; }
3435

3536
/// <summary>
3637
/// Gets or sets name.
38+
/// The attachment's file name.
3739
/// </summary>
3840
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "name", Required = Newtonsoft.Json.Required.Default)]
3941
public string Name { get; set; }
4042

4143
/// <summary>
4244
/// Gets or sets content type.
45+
/// The MIME type.
4346
/// </summary>
4447
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "contentType", Required = Newtonsoft.Json.Required.Default)]
4548
public string ContentType { get; set; }
4649

4750
/// <summary>
4851
/// Gets or sets size.
52+
/// The length of the attachment in bytes.
4953
/// </summary>
5054
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "size", Required = Newtonsoft.Json.Required.Default)]
5155
public Int32? Size { get; set; }
5256

5357
/// <summary>
5458
/// Gets or sets is inline.
59+
/// true if the attachment is an inline attachment; otherwise, false.
5560
/// </summary>
5661
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "isInline", Required = Newtonsoft.Json.Required.Default)]
5762
public bool? IsInline { get; set; }

0 commit comments

Comments
 (0)