Skip to content

Commit

Permalink
refactor(iot-device, prov-mqtt): Target new DotNetty version when not…
Browse files Browse the repository at this point in the history
… net451 (Azure#2129)
  • Loading branch information
David R. Williamson authored Aug 9, 2021
1 parent 96ed13b commit 9dde006
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 63 deletions.
6 changes: 4 additions & 2 deletions iothub/device/src/Microsoft.Azure.Devices.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,24 @@
<Compile Include="ModernDotNet\HsmAuthentication\Transport\HttpBufferedStream.cs" />
<Compile Include="ModernDotNet\HsmAuthentication\Transport\HttpRequestResponseSerializer.cs" />
<Compile Include="ModernDotNet\HsmAuthentication\Transport\UnixDomainSocketEndPoint.cs" />
<PackageReference Include="DotNetty.Codecs.Mqtt" Version="0.7.0" />
<PackageReference Include="DotNetty.Handlers" Version="0.7.0" />
</ItemGroup>

<!-- net451 only -->
<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
<Compile Include="net451\IotHubClientWebSocket.cs" />
<Compile Include="net451\Common\LegacyClientWebSocketTransport.cs" />
<Compile Include="net451\Common\Interop\UnsafeNativeMethods.cs" />
<PackageReference Include="DotNetty.Codecs.Mqtt" Version="0.6.0" />
<PackageReference Include="DotNetty.Handlers" Version="0.6.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(RootDir)\shared\src\Microsoft.Azure.Devices.Shared.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="DotNetty.Codecs.Mqtt" Version="0.6.0" />
<PackageReference Include="DotNetty.Handlers" Version="0.6.0" />
<PackageReference Include="Microsoft.Azure.Amqp" Version="2.4.7" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="WindowsAzure.Storage" Version="9.3.2" />
Expand Down
20 changes: 8 additions & 12 deletions iothub/device/tests/Microsoft.Azure.Devices.Client.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@
<DefaultItemExcludes>HsmAuthentication/**;$(DefaultItemExcludes)</DefaultItemExcludes>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' != 'net451' ">
<Compile Include="HsmAuthentication\**" />
<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
<PackageReference Include="DotNetty.Codecs.Mqtt" Version="0.6.0" />
<PackageReference Include="DotNetty.Handlers" Version="0.6.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' != 'net451' ">
<Compile Include="HsmAuthentication\**" />
<Compile Remove="ClientWebSocketTransportTests.cs" />
<Compile Remove="Mqtt\ClientWebSocketChannelTests.cs" />
<PackageReference Include="DotNetty.Codecs.Mqtt" Version="0.7.0" />
<PackageReference Include="DotNetty.Handlers" Version="0.7.0" />
</ItemGroup>

<ItemGroup>
Expand All @@ -30,20 +34,12 @@
<PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
<PackageReference Include="NSubstitute" Version="3.1.0" />
<PackageReference Include="Moq" Version="4.10.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<ProjectReference Include="..\src\Microsoft.Azure.Devices.Client.csproj" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net451' Or '$(TargetFramework)' == 'net472' ">
<Reference Include="System.Web" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="DotNetty.Codecs.Mqtt" Version="0.6.0" />
<PackageReference Include="DotNetty.Handlers" Version="0.6.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\src\Microsoft.Azure.Devices.Client.csproj" />
</ItemGroup>
</Project>
55 changes: 8 additions & 47 deletions provisioning/service/src/Config/IndividualEnrollment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ internal IndividualEnrollment(
string eTag,
DeviceCapabilities capabilities)
{
/* SRS_INDIVIDUAL_ENROLLMENT_21_003: [The constructor shall throws ProvisioningServiceClientException if one of the
provided parameters in JSON is not valid.] */
if (attestation == null)
{
throw new ProvisioningServiceClientException("Service respond an individualEnrollment without attestation.");
Expand Down Expand Up @@ -189,8 +187,7 @@ provided parameters in JSON is not valid.] */
/// <returns>The <code>string</code> with the content of this class in a pretty print format.</returns>
public override string ToString()
{
string jsonPrettyPrint = Newtonsoft.Json.JsonConvert.SerializeObject(this, Formatting.Indented);
return jsonPrettyPrint;
return JsonConvert.SerializeObject(this, Formatting.Indented);
}

/// <summary>
Expand All @@ -201,46 +198,13 @@ public override string ToString()
/// </remarks>
/// <exception cref="ArgumentException">if the provided string does not fit the registration Id requirements</exception>
[JsonProperty(PropertyName = "registrationId")]
public string RegistrationId
{
get
{
return _registrationId;
}

private set
{
_registrationId = value;
}
}

private string _registrationId;
public string RegistrationId { get; private set; }

/// <summary>
/// Desired IoT Hub device Id (optional).
/// </summary>
[JsonProperty(PropertyName = "deviceId", DefaultValueHandling = DefaultValueHandling.Ignore)]
public string DeviceId
{
get
{
return _deviceId;
}

set
{
if (value == null)
{
_deviceId = null;
}
else
{
_deviceId = value;
}
}
}

private string _deviceId;
public string DeviceId { get; set; }

/// <summary>
/// Current registration state.
Expand All @@ -260,19 +224,16 @@ public string DeviceId
[JsonIgnore]
public Attestation Attestation
{
get
{
return _attestation.GetAttestation();
}
get => _attestation.GetAttestation();

set
{
if (value is X509Attestation)
if (value is X509Attestation attestation)
{
if ((((X509Attestation)value ?? throw new ArgumentNullException(nameof(value))).ClientCertificates == null) &&
(((X509Attestation)value).CAReferences == null))
if ((attestation ?? throw new ArgumentNullException(nameof(value))).ClientCertificates == null
&& attestation.CAReferences == null)
{
throw new ArgumentNullException($"{nameof(value)} do not contains client certificate or CA reference.");
throw new ArgumentNullException(nameof(value), $"Value does not contain client certificate or CA reference.");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="DotNetty.Codecs.Mqtt" Version="0.6.0" />
<PackageReference Include="DotNetty.Handlers" Version="0.6.0" />
<PackageReference Include="DotNetty.Codecs.Mqtt" Version="0.7.0" />
<PackageReference Include="DotNetty.Handlers" Version="0.7.0" />

<!-- FXCop -->
<PackageReference Condition=" '$(Configuration)' == 'Debug' " Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.1">
Expand Down

0 comments on commit 9dde006

Please sign in to comment.