* Enable SA1210 - using directives within a C# code file are sorted alphabetically by namespace

* Enable SA1008 - An opening parenthesis within a C# statement is not spaced correctly.

* Enable SA1129 - DoNotUseDefaultValueTypeConstructor.

* Enable SA1131 - A comparison was made between a variable and a literal or constant value, and the variable appeared on the right-hand side of the expression.

* Enable SA1308 - A field name in C# is prefixed with m_ or s_.

* Enable AS1309 - A field name in C# begins with an underscore.

* Fix SA1210 due to case sensitive issue
This commit is contained in:
Philip Lin 2019-08-29 15:05:38 -07:00 коммит произвёл GitHub
Родитель 89f5ca5ca6
Коммит 36af98b646
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
38 изменённых файлов: 177 добавлений и 191 удалений

Просмотреть файл

@ -100,7 +100,7 @@
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=SuggestUseVarKeywordEvident/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UnusedMember_002ELocal/@EntryIndexedValue">SUGGESTION</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UnusedParameter_002ELocal/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=Azure_002EIoT_002EEdge/@EntryIndexedValue">&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;Profile name="Azure.IoT.Edge"&gt;&lt;AspOptimizeRegisterDirectives&gt;True&lt;/AspOptimizeRegisterDirectives&gt;&lt;HtmlReformatCode&gt;True&lt;/HtmlReformatCode&gt;&lt;CSArrangeThisQualifier&gt;True&lt;/CSArrangeThisQualifier&gt;&lt;CSRemoveCodeRedundancies&gt;True&lt;/CSRemoveCodeRedundancies&gt;&lt;CSMakeFieldReadonly&gt;True&lt;/CSMakeFieldReadonly&gt;&lt;CSUpdateFileHeader&gt;True&lt;/CSUpdateFileHeader&gt;&lt;CSOptimizeUsings&gt;&lt;OptimizeUsings&gt;True&lt;/OptimizeUsings&gt;&lt;EmbraceInRegion&gt;False&lt;/EmbraceInRegion&gt;&lt;RegionName&gt;&lt;/RegionName&gt;&lt;/CSOptimizeUsings&gt;&lt;CSShortenReferences&gt;True&lt;/CSShortenReferences&gt;&lt;CSReformatCode&gt;True&lt;/CSReformatCode&gt;&lt;VBOptimizeImports&gt;True&lt;/VBOptimizeImports&gt;&lt;VBShortenReferences&gt;True&lt;/VBShortenReferences&gt;&lt;VBReformatCode&gt;True&lt;/VBReformatCode&gt;&lt;JsInsertSemicolon&gt;True&lt;/JsInsertSemicolon&gt;&lt;JsReformatCode&gt;True&lt;/JsReformatCode&gt;&lt;CssAlphabetizeProperties&gt;True&lt;/CssAlphabetizeProperties&gt;&lt;CssReformatCode&gt;True&lt;/CssReformatCode&gt;&lt;CSUseVar&gt;&lt;BehavourStyle&gt;CAN_CHANGE_TO_EXPLICIT&lt;/BehavourStyle&gt;&lt;LocalVariableStyle&gt;IMPLICIT_EXCEPT_SIMPLE_TYPES&lt;/LocalVariableStyle&gt;&lt;ForeachVariableStyle&gt;IMPLICIT_EXCEPT_SIMPLE_TYPES&lt;/ForeachVariableStyle&gt;&lt;/CSUseVar&gt;&lt;XMLReformatCode&gt;True&lt;/XMLReformatCode&gt;&lt;StyleCop.Documentation&gt;&lt;SA1600ElementsMustBeDocumented&gt;False&lt;/SA1600ElementsMustBeDocumented&gt;&lt;SA1604ElementDocumentationMustHaveSummary&gt;False&lt;/SA1604ElementDocumentationMustHaveSummary&gt;&lt;SA1609PropertyDocumentationMustHaveValueDocumented&gt;False&lt;/SA1609PropertyDocumentationMustHaveValueDocumented&gt;&lt;SA1611ElementParametersMustBeDocumented&gt;False&lt;/SA1611ElementParametersMustBeDocumented&gt;&lt;SA1615ElementReturnValueMustBeDocumented&gt;True&lt;/SA1615ElementReturnValueMustBeDocumented&gt;&lt;SA1617VoidReturnValueMustNotBeDocumented&gt;True&lt;/SA1617VoidReturnValueMustNotBeDocumented&gt;&lt;SA1618GenericTypeParametersMustBeDocumented&gt;False&lt;/SA1618GenericTypeParametersMustBeDocumented&gt;&lt;SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes&gt;True&lt;/SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes&gt;&lt;SA1628DocumentationTextMustBeginWithACapitalLetter&gt;True&lt;/SA1628DocumentationTextMustBeginWithACapitalLetter&gt;&lt;SA1629DocumentationTextMustEndWithAPeriod&gt;True&lt;/SA1629DocumentationTextMustEndWithAPeriod&gt;&lt;SA1633SA1641UpdateFileHeader&gt;Ignore&lt;/SA1633SA1641UpdateFileHeader&gt;&lt;SA1639FileHeaderMustHaveSummary&gt;False&lt;/SA1639FileHeaderMustHaveSummary&gt;&lt;SA1642ConstructorSummaryDocumentationMustBeginWithStandardText&gt;True&lt;/SA1642ConstructorSummaryDocumentationMustBeginWithStandardText&gt;&lt;SA1643DestructorSummaryDocumentationMustBeginWithStandardText&gt;True&lt;/SA1643DestructorSummaryDocumentationMustBeginWithStandardText&gt;&lt;SA1644DocumentationHeadersMustNotContainBlankLines&gt;True&lt;/SA1644DocumentationHeadersMustNotContainBlankLines&gt;&lt;/StyleCop.Documentation&gt;&lt;CSReorderTypeMembers&gt;True&lt;/CSReorderTypeMembers&gt;&lt;CSArrangeQualifiers&gt;True&lt;/CSArrangeQualifiers&gt;&lt;FormatAttributeQuoteDescriptor&gt;True&lt;/FormatAttributeQuoteDescriptor&gt;&lt;PublicModifierStyleTs&gt;True&lt;/PublicModifierStyleTs&gt;&lt;ExplicitAnyTs&gt;True&lt;/ExplicitAnyTs&gt;&lt;TypeAnnotationStyleTs&gt;True&lt;/TypeAnnotationStyleTs&gt;&lt;RelativePathStyleTs&gt;True&lt;/RelativePathStyleTs&gt;&lt;OptimizeReferenceCommentsTs&gt;True&lt;/OptimizeReferenceCommentsTs&gt;&lt;OptimizeImportsTs&gt;True&lt;/OptimizeImportsTs&gt;&lt;RemoveRedundantQualifiersTs&gt;True&lt;/RemoveRedundantQualifiersTs&gt;&lt;CSFixBuiltinTypeReferences&gt;True&lt;/CSFixBuiltinTypeReferences&gt;&lt;CSCodeStyleAttributes ArrangeTypeAccessModifier="True" ArrangeTypeMemberAccessModifier="True" SortModifiers="True" RemoveRedundantParentheses="False" AddMissingParentheses="True" ArrangeAttributes="True" /&gt;&lt;/Profile&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=Azure_002EIoT_002EEdge/@EntryIndexedValue">&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;Profile name="Azure.IoT.Edge"&gt;&lt;AspOptimizeRegisterDirectives&gt;True&lt;/AspOptimizeRegisterDirectives&gt;&lt;HtmlReformatCode&gt;True&lt;/HtmlReformatCode&gt;&lt;CSArrangeThisQualifier&gt;True&lt;/CSArrangeThisQualifier&gt;&lt;CSRemoveCodeRedundancies&gt;True&lt;/CSRemoveCodeRedundancies&gt;&lt;CSMakeFieldReadonly&gt;True&lt;/CSMakeFieldReadonly&gt;&lt;CSUpdateFileHeader&gt;True&lt;/CSUpdateFileHeader&gt;&lt;CSOptimizeUsings&gt;&lt;OptimizeUsings&gt;True&lt;/OptimizeUsings&gt;&lt;EmbraceInRegion&gt;False&lt;/EmbraceInRegion&gt;&lt;RegionName&gt;&lt;/RegionName&gt;&lt;/CSOptimizeUsings&gt;&lt;CSReformatCode&gt;True&lt;/CSReformatCode&gt;&lt;VBOptimizeImports&gt;True&lt;/VBOptimizeImports&gt;&lt;VBShortenReferences&gt;True&lt;/VBShortenReferences&gt;&lt;VBReformatCode&gt;True&lt;/VBReformatCode&gt;&lt;JsInsertSemicolon&gt;True&lt;/JsInsertSemicolon&gt;&lt;JsReformatCode&gt;True&lt;/JsReformatCode&gt;&lt;CssAlphabetizeProperties&gt;True&lt;/CssAlphabetizeProperties&gt;&lt;CssReformatCode&gt;True&lt;/CssReformatCode&gt;&lt;CSUseVar&gt;&lt;BehavourStyle&gt;CAN_CHANGE_TO_EXPLICIT&lt;/BehavourStyle&gt;&lt;LocalVariableStyle&gt;IMPLICIT_EXCEPT_SIMPLE_TYPES&lt;/LocalVariableStyle&gt;&lt;ForeachVariableStyle&gt;IMPLICIT_EXCEPT_SIMPLE_TYPES&lt;/ForeachVariableStyle&gt;&lt;/CSUseVar&gt;&lt;XMLReformatCode&gt;True&lt;/XMLReformatCode&gt;&lt;StyleCop.Documentation&gt;&lt;SA1600ElementsMustBeDocumented&gt;False&lt;/SA1600ElementsMustBeDocumented&gt;&lt;SA1604ElementDocumentationMustHaveSummary&gt;False&lt;/SA1604ElementDocumentationMustHaveSummary&gt;&lt;SA1609PropertyDocumentationMustHaveValueDocumented&gt;False&lt;/SA1609PropertyDocumentationMustHaveValueDocumented&gt;&lt;SA1611ElementParametersMustBeDocumented&gt;False&lt;/SA1611ElementParametersMustBeDocumented&gt;&lt;SA1615ElementReturnValueMustBeDocumented&gt;True&lt;/SA1615ElementReturnValueMustBeDocumented&gt;&lt;SA1617VoidReturnValueMustNotBeDocumented&gt;True&lt;/SA1617VoidReturnValueMustNotBeDocumented&gt;&lt;SA1618GenericTypeParametersMustBeDocumented&gt;False&lt;/SA1618GenericTypeParametersMustBeDocumented&gt;&lt;SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes&gt;True&lt;/SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes&gt;&lt;SA1628DocumentationTextMustBeginWithACapitalLetter&gt;True&lt;/SA1628DocumentationTextMustBeginWithACapitalLetter&gt;&lt;SA1629DocumentationTextMustEndWithAPeriod&gt;True&lt;/SA1629DocumentationTextMustEndWithAPeriod&gt;&lt;SA1633SA1641UpdateFileHeader&gt;Ignore&lt;/SA1633SA1641UpdateFileHeader&gt;&lt;SA1639FileHeaderMustHaveSummary&gt;False&lt;/SA1639FileHeaderMustHaveSummary&gt;&lt;SA1642ConstructorSummaryDocumentationMustBeginWithStandardText&gt;True&lt;/SA1642ConstructorSummaryDocumentationMustBeginWithStandardText&gt;&lt;SA1643DestructorSummaryDocumentationMustBeginWithStandardText&gt;True&lt;/SA1643DestructorSummaryDocumentationMustBeginWithStandardText&gt;&lt;SA1644DocumentationHeadersMustNotContainBlankLines&gt;True&lt;/SA1644DocumentationHeadersMustNotContainBlankLines&gt;&lt;/StyleCop.Documentation&gt;&lt;CSReorderTypeMembers&gt;True&lt;/CSReorderTypeMembers&gt;&lt;CSArrangeQualifiers&gt;True&lt;/CSArrangeQualifiers&gt;&lt;FormatAttributeQuoteDescriptor&gt;True&lt;/FormatAttributeQuoteDescriptor&gt;&lt;PublicModifierStyleTs&gt;True&lt;/PublicModifierStyleTs&gt;&lt;ExplicitAnyTs&gt;True&lt;/ExplicitAnyTs&gt;&lt;TypeAnnotationStyleTs&gt;True&lt;/TypeAnnotationStyleTs&gt;&lt;RelativePathStyleTs&gt;True&lt;/RelativePathStyleTs&gt;&lt;OptimizeReferenceCommentsTs&gt;True&lt;/OptimizeReferenceCommentsTs&gt;&lt;OptimizeImportsTs&gt;True&lt;/OptimizeImportsTs&gt;&lt;RemoveRedundantQualifiersTs&gt;True&lt;/RemoveRedundantQualifiersTs&gt;&lt;CSFixBuiltinTypeReferences&gt;True&lt;/CSFixBuiltinTypeReferences&gt;&lt;CSCodeStyleAttributes ArrangeTypeAccessModifier="True" ArrangeTypeMemberAccessModifier="True" SortModifiers="True" RemoveRedundantParentheses="False" AddMissingParentheses="True" ArrangeAttributes="True" /&gt;&lt;/Profile&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=Default/@EntryIndexedValue"></s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=Default/@EntryIndexRemoved">True</s:Boolean>
@ -121,6 +121,7 @@
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_LINQ_QUERY/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_ARGUMENT/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_ARRAY_AND_OBJECT_INITIALIZER/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_BINARY_EXPRESSIONS_CHAIN/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ANONYMOUS_METHOD_DECLARATION_BRACES/@EntryValue">NEXT_LINE</s:String>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/BLANK_LINES_AFTER_START_COMMENT/@EntryValue">0</s:Int64>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/BLANK_LINES_AROUND_NAMESPACE/@EntryValue">1</s:Int64>

Просмотреть файл

@ -9,13 +9,13 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Logs
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using akka::Akka;
using akka::Akka.Actor;
using akka::Akka.IO;
using Akka.Streams;
using Akka.Streams.Dsl;
using Microsoft.Azure.Devices.Edge.Storage;
using Microsoft.Azure.Devices.Edge.Util;
using AkkaActor = akka::Akka.Actor;
using AkkaIO = akka::Akka.IO;
using AkkaNet = akka::Akka;
// Processes incoming logs stream and converts to the required format
//
@ -29,20 +29,20 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Logs
// unused
public class LogsProcessor : ILogsProcessor, IDisposable
{
static readonly Flow<ByteString, ByteString, NotUsed> FramingFlow
= Framing.LengthField(4, int.MaxValue, 4, ByteOrder.BigEndian);
static readonly Flow<AkkaIO.ByteString, AkkaIO.ByteString, AkkaNet.NotUsed> FramingFlow
= Framing.LengthField(4, int.MaxValue, 4, AkkaIO.ByteOrder.BigEndian);
static readonly Flow<ByteString, ByteString, NotUsed> SimpleLengthFraming
static readonly Flow<AkkaIO.ByteString, AkkaIO.ByteString, AkkaNet.NotUsed> SimpleLengthFraming
= Framing.SimpleFramingProtocolEncoder(int.MaxValue);
readonly ActorSystem system;
readonly AkkaActor.ActorSystem system;
readonly ActorMaterializer materializer;
readonly ILogMessageParser logMessageParser;
public LogsProcessor(ILogMessageParser logMessageParser)
{
this.logMessageParser = Preconditions.CheckNotNull(logMessageParser, nameof(logMessageParser));
this.system = ActorSystem.Create("LogsProcessor");
this.system = AkkaActor.ActorSystem.Create("LogsProcessor");
this.materializer = this.system.Materializer();
}
@ -106,7 +106,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Logs
? new ArraySegment<byte>(l.FullText.ToBytes())
: new ArraySegment<byte>(l.ToBytes());
var sourceMappers = new List<Func<Source<ArraySegment<byte>, NotUsed>, Source<ArraySegment<byte>, NotUsed>>>();
var sourceMappers = new List<Func<Source<ArraySegment<byte>, AkkaNet.NotUsed>, Source<ArraySegment<byte>, AkkaNet.NotUsed>>>();
if (logOptions.ContentEncoding == LogsContentEncoding.Gzip)
{
@ -134,15 +134,15 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Logs
this.materializer?.Dispose();
}
static Source<ArraySegment<byte>, NotUsed> SimpleLengthFramingMapper(Source<ArraySegment<byte>, NotUsed> s) =>
s.Select(ByteString.FromBytes)
static Source<ArraySegment<byte>, AkkaNet.NotUsed> SimpleLengthFramingMapper(Source<ArraySegment<byte>, AkkaNet.NotUsed> s) =>
s.Select(AkkaIO.ByteString.FromBytes)
.Via(SimpleLengthFraming)
.Select(b => new ArraySegment<byte>(b.ToArray()));
static Source<ArraySegment<byte>, NotUsed> NonGroupingGzipMapper(Source<ArraySegment<byte>, NotUsed> s) =>
static Source<ArraySegment<byte>, AkkaNet.NotUsed> NonGroupingGzipMapper(Source<ArraySegment<byte>, AkkaNet.NotUsed> s) =>
s.Select(m => new ArraySegment<byte>(Compression.CompressToGzip(m.Array)));
static Source<ArraySegment<byte>, NotUsed> GroupingGzipMapper(Source<ArraySegment<byte>, NotUsed> s, LogsOutputGroupingConfig outputGroupingConfig) =>
static Source<ArraySegment<byte>, AkkaNet.NotUsed> GroupingGzipMapper(Source<ArraySegment<byte>, AkkaNet.NotUsed> s, LogsOutputGroupingConfig outputGroupingConfig) =>
s.GroupedWithin(outputGroupingConfig.MaxFrames, outputGroupingConfig.MaxDuration)
.Select(
b =>
@ -154,20 +154,20 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Logs
class GraphBuilder
{
Source<ModuleLogMessageData, NotUsed> parsingGraphSource;
Source<ModuleLogMessageData, AkkaNet.NotUsed> parsingGraphSource;
GraphBuilder(Source<ModuleLogMessageData, NotUsed> parsingGraphSource)
GraphBuilder(Source<ModuleLogMessageData, AkkaNet.NotUsed> parsingGraphSource)
{
this.parsingGraphSource = parsingGraphSource;
}
public static GraphBuilder CreateParsingGraphBuilder(Stream stream, Func<ByteString, ModuleLogMessageData> parserFunc)
public static GraphBuilder CreateParsingGraphBuilder(Stream stream, Func<AkkaIO.ByteString, ModuleLogMessageData> parserFunc)
{
var source = StreamConverters.FromInputStream(() => stream);
var graph = source
.Via(FramingFlow)
.Select(parserFunc)
.MapMaterializedValue(_ => NotUsed.Instance);
.MapMaterializedValue(_ => AkkaNet.NotUsed.Instance);
return new GraphBuilder(graph);
}
@ -199,14 +199,14 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Logs
public IRunnableGraph<Task> GetStreamingGraph<TU, TV>(
Func<TV, Task<TU>> callback,
Func<ModuleLogMessageData, TV> basicMapper,
List<Func<Source<TV, NotUsed>, Source<TV, NotUsed>>> mappers)
List<Func<Source<TV, AkkaNet.NotUsed>, Source<TV, AkkaNet.NotUsed>>> mappers)
{
Source<TV, NotUsed> streamingGraphSource = this.parsingGraphSource
Source<TV, AkkaNet.NotUsed> streamingGraphSource = this.parsingGraphSource
.Select(basicMapper);
if (mappers?.Count > 0)
{
foreach (Func<Source<TV, NotUsed>, Source<TV, NotUsed>> mapper in mappers)
foreach (Func<Source<TV, AkkaNet.NotUsed>, Source<TV, AkkaNet.NotUsed>> mapper in mappers)
{
streamingGraphSource = mapper(streamingGraphSource);
}

Просмотреть файл

@ -1,7 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
namespace Microsoft.Azure.Devices.Edge.Agent.Core.Requests
{
extern alias akka;
using System;
using System.Collections.Generic;
using System.Linq;

Просмотреть файл

@ -1,4 +1,4 @@
// Copyright (c) Microsoft. All rights reserved.
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Microsoft.Azure.Devices.Edge.Agent.Docker.Test")]
[assembly: InternalsVisibleTo("Microsoft.Azure.Devices.Edge.Agent.Docker.Test")]

Просмотреть файл

@ -75,13 +75,13 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Docker
}
return string.Equals(this.Name, other.Name) &&
string.Equals(this.Version, other.Version) &&
string.Equals(this.Type, other.Type) &&
this.DesiredStatus == other.DesiredStatus &&
this.Config.Equals(other.Config) &&
this.RestartPolicy == other.RestartPolicy &&
this.ImagePullPolicy == other.ImagePullPolicy &&
EnvDictionaryComparer.Equals(this.Env, other.Env);
string.Equals(this.Version, other.Version) &&
string.Equals(this.Type, other.Type) &&
this.DesiredStatus == other.DesiredStatus &&
this.Config.Equals(other.Config) &&
this.RestartPolicy == other.RestartPolicy &&
this.ImagePullPolicy == other.ImagePullPolicy &&
EnvDictionaryComparer.Equals(this.Env, other.Env);
}
public virtual bool IsOnlyModuleStatusChanged(IModule other)

Просмотреть файл

@ -4,7 +4,6 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Docker
using System;
using System.Collections.Generic;
using Microsoft.Azure.Devices.Edge.Agent.Core;
using Microsoft.Azure.Devices.Edge.Util;
using Newtonsoft.Json;
public class EdgeAgentDockerRuntimeModule : DockerRuntimeModule, IEdgeAgentModule

Просмотреть файл

@ -15,15 +15,15 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Docker.Commands
public class CreateCommand : ICommand
{
readonly CreateContainerParameters createContainerParameters;
readonly IDockerClient client;
static readonly Dictionary<string, PortBinding> EdgeHubPortBinding = new Dictionary<string, PortBinding>
{
{ "8883/tcp", new PortBinding { HostPort = "8883" } },
{ "443/tcp", new PortBinding { HostPort = "443" } }
};
readonly CreateContainerParameters createContainerParameters;
readonly IDockerClient client;
readonly Lazy<string> id;
public CreateCommand(IDockerClient client, CreateContainerParameters createContainerParameters)

Просмотреть файл

@ -18,6 +18,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Docker.Commands
static readonly ILogger Logger = Util.Logger.Factory.CreateLogger<RemoveCommand>();
readonly IDockerClient client;
readonly DockerModule module;
public RemoveCommand(IDockerClient client, DockerModule module)
{
this.client = Preconditions.CheckNotNull(client, nameof(client));

Просмотреть файл

@ -10,8 +10,8 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Edgelet.Version_2018_06_28
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Azure.Devices.Edge.Agent.Core;
using Microsoft.Azure.Devices.Edge.Agent.Edgelet.Versioning;
using Microsoft.Azure.Devices.Edge.Agent.Edgelet.Version_2018_06_28.GeneratedCode;
using Microsoft.Azure.Devices.Edge.Agent.Edgelet.Versioning;
using Microsoft.Azure.Devices.Edge.Util;
using Microsoft.Azure.Devices.Edge.Util.Edged;
using Microsoft.Azure.Devices.Edge.Util.TransientFaultHandling;

Просмотреть файл

@ -10,8 +10,8 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Edgelet.Version_2019_01_30
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Azure.Devices.Edge.Agent.Core;
using Microsoft.Azure.Devices.Edge.Agent.Edgelet.Versioning;
using Microsoft.Azure.Devices.Edge.Agent.Edgelet.Version_2019_01_30.GeneratedCode;
using Microsoft.Azure.Devices.Edge.Agent.Edgelet.Versioning;
using Microsoft.Azure.Devices.Edge.Util;
using Microsoft.Azure.Devices.Edge.Util.Edged;
using Microsoft.Azure.Devices.Edge.Util.TransientFaultHandling;

Просмотреть файл

@ -91,7 +91,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Test
[Unit]
public async void ReconcileAsyncOnEmptyPlan()
{
var token = new CancellationToken();
var token = default(CancellationToken);
var serde = Mock.Of<ISerde<DeploymentConfigInfo>>();
var mockConfigSource = new Mock<IConfigSource>();
var mockEnvironment = new Mock<IEnvironment>();
@ -146,7 +146,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Test
var mockPlanner = new Mock<IPlanner>();
var mockPlanRunner = new Mock<IPlanRunner>();
var mockReporter = new Mock<IReporter>();
var token = new CancellationToken();
var token = default(CancellationToken);
var currentSet = ModuleSet.Empty;
var mockModuleIdentityLifecycleManager = new Mock<IModuleIdentityLifecycleManager>();
var configStore = Mock.Of<IEntityStore<string, string>>();
@ -182,7 +182,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Test
var mockPlanner = new Mock<IPlanner>();
var mockPlanRunner = new Mock<IPlanRunner>();
var mockReporter = new Mock<IReporter>();
var token = new CancellationToken();
var token = default(CancellationToken);
var currentSet = ModuleSet.Empty;
var mockModuleIdentityLifecycleManager = new Mock<IModuleIdentityLifecycleManager>();
var configStore = Mock.Of<IEntityStore<string, string>>();
@ -217,7 +217,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Test
var mockPlanner = new Mock<IPlanner>();
var mockPlanRunner = new Mock<IPlanRunner>();
var mockReporter = new Mock<IReporter>();
var token = new CancellationToken();
var token = default(CancellationToken);
var mockModuleIdentityLifecycleManager = new Mock<IModuleIdentityLifecycleManager>();
var configStore = Mock.Of<IEntityStore<string, string>>();
var mockEnvironmentProvider = Mock.Of<IEnvironmentProvider>(m => m.Create(It.IsAny<DeploymentConfig>()) == mockEnvironment.Object);
@ -251,7 +251,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Test
var mockPlanner = new Mock<IPlanner>();
var mockPlanRunner = new Mock<IPlanRunner>();
var mockReporter = new Mock<IReporter>();
var token = new CancellationToken();
var token = default(CancellationToken);
var mockModuleIdentityLifecycleManager = new Mock<IModuleIdentityLifecycleManager>();
var configStore = Mock.Of<IEntityStore<string, string>>();
var mockEnvironmentProvider = Mock.Of<IEnvironmentProvider>(m => m.Create(It.IsAny<DeploymentConfig>()) == mockEnvironment.Object);
@ -290,7 +290,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Test
[Unit]
public async void ReconcileAsyncReportsFailedWhenEncryptProviderThrows()
{
var token = new CancellationToken();
var token = default(CancellationToken);
var serde = Mock.Of<ISerde<DeploymentConfigInfo>>();
var mockConfigSource = new Mock<IConfigSource>();
var mockEnvironment = new Mock<IEnvironment>();
@ -364,9 +364,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Test
new TestCommand(TestCommandType.TestRemove, currentModule, recordKeeper)
};
var testPlan = new Plan(commandList);
var token = new CancellationToken();
var token = default(CancellationToken);
var runtimeInfo = Mock.Of<IRuntimeInfo>();
var deploymentConfig = new DeploymentConfig("1.0", runtimeInfo, new SystemModules(null, null), new Dictionary<string, IModule> { ["desired"] = desiredModule });
var deploymentConfigInfo = new DeploymentConfigInfo(0, deploymentConfig);
@ -418,7 +416,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Test
var mockReporter = new Mock<IReporter>();
var runtimeInfo = new Mock<IRuntimeInfo>();
var mockModuleIdentityLifecycleManager = new Mock<IModuleIdentityLifecycleManager>();
var token = new CancellationToken();
var token = default(CancellationToken);
var configStore = Mock.Of<IEntityStore<string, string>>();
var mockEnvironmentProvider = Mock.Of<IEnvironmentProvider>(m => m.Create(It.IsAny<DeploymentConfig>()) == mockEnvironment.Object);
var serde = Mock.Of<ISerde<DeploymentConfigInfo>>();
@ -449,7 +447,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Test
var mockPlanRunner = new Mock<IPlanRunner>();
var mockReporter = new Mock<IReporter>();
var mockModuleIdentityLifecycleManager = new Mock<IModuleIdentityLifecycleManager>();
var token = new CancellationToken();
var token = default(CancellationToken);
var configStore = Mock.Of<IEntityStore<string, string>>();
var mockEnvironmentProvider = Mock.Of<IEnvironmentProvider>(m => m.Create(It.IsAny<DeploymentConfig>()) == mockEnvironment.Object);
var serde = Mock.Of<ISerde<DeploymentConfigInfo>>();
@ -492,7 +490,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Test
{ "mod1", new TestModule("mod1", "1.0", "docker", ModuleStatus.Running, new TestConfig("boo"), RestartPolicy.OnUnhealthy, ImagePullPolicy.OnCreate, new ConfigurationInfo("1"), null) }
});
var deploymentConfigInfo = new DeploymentConfigInfo(0, deploymentConfig);
var token = new CancellationToken();
var token = default(CancellationToken);
mockConfigSource.Setup(cs => cs.GetDeploymentConfigInfoAsync())
.ReturnsAsync(deploymentConfigInfo);
@ -555,7 +553,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Test
var encryptionDecryptionProvider = Mock.Of<IEncryptionProvider>();
var deploymentConfig = new DeploymentConfig("1.0", Mock.Of<IRuntimeInfo>(), new SystemModules(null, null), modules);
var deploymentConfigInfo = new DeploymentConfigInfo(0, deploymentConfig);
var token = new CancellationToken();
var token = default(CancellationToken);
mockConfigSource.Setup(cs => cs.GetDeploymentConfigInfoAsync())
.ReturnsAsync(deploymentConfigInfo);

Просмотреть файл

@ -14,7 +14,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Test
NullEnvironment testNullEnvironment = NullEnvironment.Instance;
Assert.NotNull(testNullEnvironment);
var token = new CancellationToken();
var token = default(CancellationToken);
ModuleSet testModuleSet = await testNullEnvironment.GetModulesAsync(token);
Assert.NotNull(testModuleSet);

Просмотреть файл

@ -46,7 +46,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Test
Assert.True(Plan.Empty.IsEmpty);
Assert.True(plan2.IsEmpty);
var token = new CancellationToken();
var token = default(CancellationToken);
var planRunner = new OrderedPlanRunner();
await planRunner.ExecuteAsync(1, plan1, token);
@ -85,7 +85,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Test
await factory.StopAsync(moduleExecutionList[4].Module),
};
var plan1 = new Plan(commandList);
var token = new CancellationToken();
var token = default(CancellationToken);
var planRunner = new OrderedPlanRunner();
await planRunner.ExecuteAsync(1, plan1, token);
Assert.All(
@ -129,7 +129,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Test
await factory.StopAsync(moduleExecutionList[4].Module),
};
var plan1 = new Plan(commandList);
var token = new CancellationToken();
var token = default(CancellationToken);
var planRunner = new OrderedPlanRunner();
AggregateException ex = await Assert.ThrowsAsync<AggregateException>(async () => await planRunner.ExecuteAsync(1, plan1, token));

Просмотреть файл

@ -31,7 +31,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Test.Commands
{
var g = new GroupCommand(commandList.ToArray());
var token = new CancellationToken();
var token = default(CancellationToken);
await g.ExecuteAsync(token);
@ -48,7 +48,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Test.Commands
{
ICommand g = new GroupCommand(commandList.ToArray());
var token = new CancellationToken();
var token = default(CancellationToken);
await g.UndoAsync(token);

Просмотреть файл

@ -78,7 +78,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Test.Commands
Task<ICommand> commandBeingDecorated,
TestExecutionExpr testExpr)
{
var token = new CancellationToken();
var token = default(CancellationToken);
var logFactoryMock = new Mock<ILoggerFactory>();
var logMock = new Mock<ILogger<LoggingCommandFactory>>();
@ -114,7 +114,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Test.Commands
Task<ICommand> commandBeingDecorated,
TestExecutionExpr testExpr)
{
var token = new CancellationToken();
var token = default(CancellationToken);
var logFactoryMock = new Mock<ILoggerFactory>();
var logMock = new Mock<ILogger<LoggingCommandFactory>>();
@ -144,7 +144,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Test.Commands
Task<ICommand> commandBeingDecorated,
TestExecutionExpr testExpr)
{
var token = new CancellationToken();
var token = default(CancellationToken);
var logFactoryMock = new Mock<ILoggerFactory>();
var logMock = new Mock<ILogger<LoggingCommandFactory>>();
@ -174,7 +174,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Test.Commands
Task<ICommand> commandBeingDecorated,
TestExecutionExpr testExpr)
{
var token = new CancellationToken();
var token = default(CancellationToken);
var logFactoryMock = new Mock<ILoggerFactory>();
var logMock = new Mock<ILogger<LoggingCommandFactory>>();
var factoryMock = new Mock<ICommandFactory>();

Просмотреть файл

@ -13,7 +13,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Test.Commands
public async void NullCommandTestAll()
{
NullCommand n = NullCommand.Instance;
var token = new CancellationToken();
var token = default(CancellationToken);
await n.ExecuteAsync(token);

Просмотреть файл

@ -31,7 +31,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Test.Commands
{
var g = new ParallelGroupCommand(commandList.ToArray());
var token = new CancellationToken();
var token = default(CancellationToken);
await g.ExecuteAsync(token);
@ -48,7 +48,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Test.Commands
{
ICommand g = new ParallelGroupCommand(commandList.ToArray());
var token = new CancellationToken();
var token = default(CancellationToken);
await g.UndoAsync(token);

Просмотреть файл

@ -43,7 +43,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Test.Planners
{
// Arrange
(TestCommandFactory factory, _, _, HealthRestartPlanner planner) = CreatePlanner();
var token = new CancellationToken();
var token = default(CancellationToken);
var expectedExecutionList = new List<TestRecordType>();
// Act

Просмотреть файл

@ -26,7 +26,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Test.Planners
{
var factory = new TestCommandFactory();
var planner = new RestartPlanner(factory);
var token = new CancellationToken();
var token = default(CancellationToken);
var addExecutionList = new List<TestRecordType>();
Plan addPlan = await planner.PlanAsync(ModuleSet.Empty, ModuleSet.Empty, RuntimeInfo, ImmutableDictionary<string, IModuleIdentity>.Empty);
@ -47,7 +47,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Test.Planners
IImmutableDictionary<string, IModuleIdentity> moduleIdentities = GetModuleIdentities(new List<IModule>() { addModule });
var planner = new RestartPlanner(factory);
var token = new CancellationToken();
var token = default(CancellationToken);
ModuleSet addRunning = ModuleSet.Create(addModule);
var addExecutionList = new List<TestRecordType>
@ -73,7 +73,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Test.Planners
IImmutableDictionary<string, IModuleIdentity> moduleIdentities = GetModuleIdentities(new List<IModule>() { stoppedModule });
var planner = new RestartPlanner(factory);
var token = new CancellationToken();
var token = default(CancellationToken);
var addStoppedExecutionList = new List<TestRecordType>
{
@ -97,7 +97,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Test.Planners
IImmutableDictionary<string, IModuleIdentity> moduleIdentities = GetModuleIdentities(new List<IModule>() { desiredModule });
var planner = new RestartPlanner(factory);
var token = new CancellationToken();
var token = default(CancellationToken);
ModuleSet currentSet = ModuleSet.Create(currentModule);
ModuleSet desiredSet = ModuleSet.Create(desiredModule);
@ -120,7 +120,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Test.Planners
{
var factory = new TestCommandFactory();
var planner = new RestartPlanner(factory);
var token = new CancellationToken();
var token = default(CancellationToken);
IModule removeModule = new TestModule("mod1", "version1", "test", ModuleStatus.Running, Config1, RestartPolicy.OnUnhealthy, ImagePullPolicy.OnCreate, DefaultConfigurationInfo, EnvVars);
ModuleSet removeRunning = ModuleSet.Create(removeModule);
@ -141,7 +141,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Core.Test.Planners
public async void RestartPlannerAddRemoveUpdate()
{
var factory = new TestCommandFactory();
var token = new CancellationToken();
var token = default(CancellationToken);
DateTime lastStartTime = DateTime.Parse("2017-08-04T17:52:13.0419502Z", null, DateTimeStyles.RoundtripKind);
DateTime lastExitTime = lastStartTime.AddDays(1);

Просмотреть файл

@ -3,9 +3,9 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Kubernetes.Test
{
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Azure.Devices.Edge.Util.Test.Common;
using Microsoft.Azure.Devices.Edge.Agent.Core;
using Microsoft.Azure.Devices.Edge.Agent.Core.Commands;
using Microsoft.Azure.Devices.Edge.Util.Test.Common;
using Moq;
using Xunit;
@ -31,7 +31,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Kubernetes.Test
Assert.Equal(NullCommand.Instance, await kcf.RestartAsync(mockModule));
var newCommand = await kcf.WrapAsync(mockCommand);
await newCommand.ExecuteAsync(ct);
Mock.Get(mockCommand).Verify( c => c.ExecuteAsync(ct), Times.Once);
Mock.Get(mockCommand).Verify(c => c.ExecuteAsync(ct), Times.Once);
}
}
}
}

Просмотреть файл

@ -8,16 +8,16 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Kubernetes.Test.Commands
using System.Threading;
using System.Threading.Tasks;
using global::Docker.DotNet.Models;
using Microsoft.Azure.Devices.Edge.Agent.Core;
using Microsoft.Azure.Devices.Edge.Agent.Docker;
using Microsoft.Azure.Devices.Edge.Util.Test.Common;
using Moq;
using k8s;
using k8s.Models;
using Microsoft.Azure.Devices.Edge.Agent.Core;
using Microsoft.Azure.Devices.Edge.Agent.Docker;
using Microsoft.Azure.Devices.Edge.Agent.Kubernetes.Commands;
using Xunit;
using Microsoft.Azure.Devices.Edge.Util;
using Microsoft.Azure.Devices.Edge.Util.Test.Common;
using Moq;
using Newtonsoft.Json;
using Xunit;
using Constants = Microsoft.Azure.Devices.Edge.Agent.Kubernetes.Constants;
public class KubernetesCrdCommandTest
@ -62,7 +62,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Kubernetes.Test.Commands
var configProvider = new Mock<ICombinedConfigProvider<CombinedDockerConfig>>();
configProvider.Setup(cp => cp.GetCombinedConfig(km1, Runtime)).Returns(() => null);
var token = new CancellationToken();
var token = default(CancellationToken);
var cmd = new KubernetesCrdCommand<CombinedDockerConfig>(Ns, Hostname, DeviceId, DefaultClient, modules, runtimeOption, DefaultConfigProvider);
await Assert.ThrowsAsync<InvalidModuleException>(() => cmd.ExecuteAsync(token));
}
@ -74,7 +74,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Kubernetes.Test.Commands
IModule m1 = new DockerModule("module1", "v1", ModuleStatus.Running, Core.RestartPolicy.Always, Config1, ImagePullPolicy.OnCreate, DefaultConfigurationInfo, EnvVars);
var km1 = new KubernetesModule<DockerConfig>((IModule<DockerConfig>)m1);
KubernetesModule<DockerConfig>[] modules = { km1 };
var token = new CancellationToken();
var token = default(CancellationToken);
Option<IRuntimeInfo> runtimeOption = Option.Maybe(Runtime);
var auth = new AuthConfig() { Username = "username", Password = "password", ServerAddress = "docker.io" };
var configProvider = new Mock<ICombinedConfigProvider<CombinedDockerConfig>>();
@ -145,7 +145,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Kubernetes.Test.Commands
IModule m1 = new DockerModule("module1", "v1", ModuleStatus.Running, Core.RestartPolicy.Always, Config1, ImagePullPolicy.OnCreate, DefaultConfigurationInfo, EnvVars);
var km1 = new KubernetesModule<DockerConfig>((IModule<DockerConfig>)m1);
KubernetesModule<DockerConfig>[] modules = { km1 };
var token = new CancellationToken();
var token = default(CancellationToken);
Option<IRuntimeInfo> runtimeOption = Option.Maybe(Runtime);
var auth = new AuthConfig() { Username = "username", Password = "password", ServerAddress = "docker.io" };
var configProvider = new Mock<ICombinedConfigProvider<CombinedDockerConfig>>();
@ -217,7 +217,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Kubernetes.Test.Commands
IModule m2 = new DockerModule("module2", "v1", ModuleStatus.Running, Core.RestartPolicy.Always, Config2, ImagePullPolicy.OnCreate, DefaultConfigurationInfo, EnvVars);
var km2 = new KubernetesModule<DockerConfig>((IModule<DockerConfig>)m2);
KubernetesModule<DockerConfig>[] modules = { km1, km2 };
var token = new CancellationToken();
var token = default(CancellationToken);
Option<IRuntimeInfo> runtimeOption = Option.Maybe(Runtime);
var auth = new AuthConfig() { Username = "username", Password = "password", ServerAddress = "docker.io" };
var configProvider = new Mock<ICombinedConfigProvider<CombinedDockerConfig>>();

Просмотреть файл

@ -64,7 +64,8 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Kubernetes.Test.Planners
var planner = new KubernetesPlanner<CombinedDockerConfig>(Ns, Hostname, DeviceId, DefaultClient, DefaultCommandFactory, DefaultConfigProvider);
await Assert.ThrowsAsync<InvalidIdentityException>( () => planner.PlanAsync(addRunning, ModuleSet.Empty, RuntimeInfo, ImmutableDictionary<string, IModuleIdentity>.Empty));
await Assert.ThrowsAsync<InvalidIdentityException>(
() => planner.PlanAsync(addRunning, ModuleSet.Empty, RuntimeInfo, ImmutableDictionary<string, IModuleIdentity>.Empty));
}
[Fact]

Просмотреть файл

@ -13,7 +13,7 @@ namespace Microsoft.Azure.Devices.Edge.Hub.CloudProxy
using static System.FormattableString;
/// <summary>
/// This class creates and manages cloud connections (CloudProxy instances)
/// This class creates and manages cloud connections (CloudProxy instances).
/// </summary>
class ClientTokenCloudConnection : CloudConnection, IClientTokenCloudConnection
{
@ -298,29 +298,19 @@ namespace Microsoft.Azure.Devices.Edge.Hub.CloudProxy
Log.LogDebug((int)EventIds.ObtainedNewToken, Invariant($"Token received for client {identity.Id} expires in {timeRemaining}, and so is not usable. Getting a fresh token..."));
}
internal static void GetNewToken(string id)
{
Log.LogDebug((int)EventIds.CreateNewToken, Invariant($"Getting new token for {id}."));
}
internal static void UsingExistingToken(string id)
{
Log.LogInformation((int)EventIds.CreateNewToken, Invariant($"New token requested by client {id}, but using existing token as it is usable."));
}
internal static void SafeCreateNewToken(string id)
{
Log.LogInformation((int)EventIds.CreateNewToken, Invariant($"Existing token not found for {id}. Getting new token from the client..."));
}
internal static void CreateException(Exception ex, IIdentity identity)
{
Log.LogError((int)EventIds.CloudConnectError, ex, Invariant($"Error creating or updating the cloud proxy for client {identity.Id}"));
}
internal static void UpdatedCloudConnection(IIdentity identity)
internal static void ErrorRenewingToken(Exception ex)
{
Log.LogDebug((int)EventIds.UpdatedCloudConnection, Invariant($"Updated cloud connection for client {identity.Id}"));
Log.LogDebug((int)EventIds.ErrorRenewingToken, ex, "Critical Error trying to renew Token.");
}
internal static void GetNewToken(string id)
{
Log.LogDebug((int)EventIds.CreateNewToken, Invariant($"Getting new token for {id}."));
}
internal static void NewTokenObtained(IIdentity identity, string newToken)
@ -329,9 +319,19 @@ namespace Microsoft.Azure.Devices.Edge.Hub.CloudProxy
Log.LogInformation((int)EventIds.ObtainedNewToken, Invariant($"Obtained new token for client {identity.Id} that expires in {timeRemaining}"));
}
internal static void ErrorRenewingToken(Exception ex)
internal static void SafeCreateNewToken(string id)
{
Log.LogDebug((int)EventIds.ErrorRenewingToken, ex, "Critical Error trying to renew Token.");
Log.LogInformation((int)EventIds.CreateNewToken, Invariant($"Existing token not found for {id}. Getting new token from the client..."));
}
internal static void UpdatedCloudConnection(IIdentity identity)
{
Log.LogDebug((int)EventIds.UpdatedCloudConnection, Invariant($"Updated cloud connection for client {identity.Id}"));
}
internal static void UsingExistingToken(string id)
{
Log.LogInformation((int)EventIds.CreateNewToken, Invariant($"New token requested by client {id}, but using existing token as it is usable."));
}
}
}

Просмотреть файл

@ -2,8 +2,8 @@
namespace Microsoft.Azure.Devices.Routing.Core.Endpoints
{
using System.Threading.Tasks;
using Microsoft.Azure.Devices.Routing.Core.Checkpointers;
using Microsoft.Azure.Devices.Edge.Util;
using Microsoft.Azure.Devices.Routing.Core.Checkpointers;
public class StoringAsyncEndpointExecutorFactory : IEndpointExecutorFactory
{

Просмотреть файл

@ -3,7 +3,7 @@ namespace Microsoft.Azure.Devices.Routing.Core.Query
{
public struct Null
{
public static Null Instance { get; } = new Null();
public static Null Instance { get; } = default(Null);
// Equal
public static Bool operator ==(Null x, Null y) => Bool.True;

Просмотреть файл

@ -9,7 +9,7 @@ namespace Microsoft.Azure.Devices.Routing.Core.Query
static readonly Bool UndefinedBool = Bool.Undefined;
static readonly double UndefinedDouble = double.NaN;
public static Undefined Instance { get; } = new Undefined();
public static Undefined Instance { get; } = default(Undefined);
// Equal
public static Bool operator ==(Undefined x, Undefined y) => Bool.Undefined;

Просмотреть файл

@ -24,13 +24,11 @@ namespace Microsoft.Azure.Devices.Routing.Core.Test.Query
[Unit]
public void TestEquals()
{
var d1 = new Null();
var d2 = new Null();
var d1 = default(Null);
var d2 = default(Null);
Assert.True(d1 == d2);
Assert.False(d1 != d2);
Assert.Equal(Bool.Undefined, Bool.True == d1);
Assert.Equal(Bool.Undefined, Bool.False == d1);
Assert.Equal(Bool.Undefined, d1 == Bool.True);
Assert.Equal(Bool.Undefined, d1 == Bool.False);
}
@ -39,8 +37,8 @@ namespace Microsoft.Azure.Devices.Routing.Core.Test.Query
[Unit]
public void TestArthimetic()
{
var d1 = new Null();
var d2 = new Null();
var d1 = default(Null);
var d2 = default(Null);
Assert.Equal(12.34, d1 + 12.34);
Assert.Equal(12.34, 12.34 + d1);
@ -64,39 +62,39 @@ namespace Microsoft.Azure.Devices.Routing.Core.Test.Query
[Unit]
public void TestComparison()
{
var d1 = new Null();
var d2 = new Null();
var d1 = default(Null);
var d2 = default(Null);
Assert.Equal(Bool.Undefined, d1 < 12.34);
Assert.Equal(Bool.Undefined, 12.34 < d1);
Assert.Equal(Bool.Undefined, d1 > 12.34);
Assert.Equal(Bool.Undefined, d1 < "string");
Assert.Equal(Bool.Undefined, "string" < d1);
Assert.Equal(Bool.Undefined, d1 > "string");
Assert.Equal(Bool.Undefined, d1 < Bool.True);
Assert.Equal(Bool.Undefined, Bool.True < d1);
Assert.Equal(Bool.Undefined, d1 > Bool.True);
Assert.Equal(Bool.False, d1 < d2);
Assert.Equal(Bool.Undefined, d1 > 12.34);
Assert.Equal(Bool.Undefined, 12.34 > d1);
Assert.Equal(Bool.Undefined, d1 < 12.34);
Assert.Equal(Bool.Undefined, d1 > "string");
Assert.Equal(Bool.Undefined, "string" > d1);
Assert.Equal(Bool.Undefined, d1 < "string");
Assert.Equal(Bool.Undefined, d1 > Bool.True);
Assert.Equal(Bool.Undefined, Bool.True > d1);
Assert.Equal(Bool.Undefined, d1 < Bool.True);
Assert.Equal(Bool.False, d1 > d2);
Assert.Equal(Bool.Undefined, d1 <= 12.34);
Assert.Equal(Bool.Undefined, 12.34 <= d1);
Assert.Equal(Bool.Undefined, d1 >= 12.34);
Assert.Equal(Bool.Undefined, d1 <= "string");
Assert.Equal(Bool.Undefined, "string" <= d1);
Assert.Equal(Bool.Undefined, d1 >= "string");
Assert.Equal(Bool.Undefined, d1 <= Bool.True);
Assert.Equal(Bool.Undefined, Bool.True <= d1);
Assert.Equal(Bool.Undefined, d1 >= Bool.True);
Assert.Equal(Bool.True, d1 <= d2);
Assert.Equal(Bool.Undefined, d1 >= 12.34);
Assert.Equal(Bool.Undefined, 12.34 >= d1);
Assert.Equal(Bool.Undefined, d1 <= 12.34);
Assert.Equal(Bool.Undefined, d1 >= "string");
Assert.Equal(Bool.Undefined, "string" >= d1);
Assert.Equal(Bool.Undefined, d1 <= "string");
Assert.Equal(Bool.Undefined, d1 >= Bool.True);
Assert.Equal(Bool.Undefined, Bool.True >= d1);
Assert.Equal(Bool.Undefined, d1 <= Bool.True);
Assert.Equal(Bool.True, d1 >= d2);
}

Просмотреть файл

@ -24,13 +24,11 @@ namespace Microsoft.Azure.Devices.Routing.Core.Test.Query
[Unit]
public void TestEquals()
{
var d1 = new Undefined();
var d2 = new Undefined();
var d1 = default(Undefined);
var d2 = default(Undefined);
Assert.Equal(Bool.Undefined, d1 == d2);
Assert.Equal(Bool.Undefined, d1 != d2);
Assert.Equal(Bool.Undefined, Bool.True == d1);
Assert.Equal(Bool.Undefined, Bool.False == d1);
Assert.Equal(Bool.Undefined, d1 == Bool.True);
Assert.Equal(Bool.Undefined, d1 == Bool.False);
}
@ -47,8 +45,8 @@ namespace Microsoft.Azure.Devices.Routing.Core.Test.Query
[Unit]
public void TestArthimetic()
{
var d1 = new Undefined();
var d2 = new Undefined();
var d1 = default(Undefined);
var d2 = default(Undefined);
Assert.Equal(double.NaN, d1 + 12.34);
Assert.Equal(double.NaN, 12.34 + d1);
@ -71,23 +69,23 @@ namespace Microsoft.Azure.Devices.Routing.Core.Test.Query
[Unit]
public void TestComparison()
{
var d1 = new Undefined();
var d2 = new Undefined();
var d1 = default(Undefined);
var d2 = default(Undefined);
Assert.Equal(Bool.Undefined, d1 < 12.34);
Assert.Equal(Bool.Undefined, 12.34 < d1);
Assert.Equal(Bool.Undefined, d1 > 12.34);
Assert.Equal(Bool.Undefined, d1 < d2);
Assert.Equal(Bool.Undefined, d1 > 12.34);
Assert.Equal(Bool.Undefined, 12.34 > d1);
Assert.Equal(Bool.Undefined, d1 < 12.34);
Assert.Equal(Bool.Undefined, d1 > d2);
Assert.Equal(Bool.Undefined, d1 <= 12.34);
Assert.Equal(Bool.Undefined, 12.34 <= d1);
Assert.Equal(Bool.Undefined, d1 >= 12.34);
Assert.Equal(Bool.Undefined, d1 <= d2);
Assert.Equal(Bool.Undefined, d1 >= 12.34);
Assert.Equal(Bool.Undefined, 12.34 >= d1);
Assert.Equal(Bool.Undefined, d1 <= 12.34);
Assert.Equal(Bool.Undefined, d1 >= d2);
}

Просмотреть файл

@ -9,10 +9,10 @@ namespace DirectMethodCloudSender
using System.Threading.Tasks;
using Microsoft.Azure.Devices;
using Microsoft.Azure.Devices.Client;
using Microsoft.Azure.Devices.Edge.ModuleUtil;
using Microsoft.Azure.Devices.Edge.Util;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.Azure.Devices.Edge.ModuleUtil;
using IotHubConnectionStringBuilder = Microsoft.Azure.Devices.IotHubConnectionStringBuilder;
using Message = Microsoft.Azure.Devices.Client.Message;
using TransportType = Microsoft.Azure.Devices.Client.TransportType;

Просмотреть файл

@ -7,10 +7,10 @@ namespace DirectMethodReceiver
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Azure.Devices.Client;
using Microsoft.Azure.Devices.Edge.ModuleUtil;
using Microsoft.Azure.Devices.Edge.Util;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.Azure.Devices.Edge.ModuleUtil;
class Program
{

Просмотреть файл

@ -8,10 +8,10 @@ namespace DirectMethodSender
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Azure.Devices.Client;
using Microsoft.Azure.Devices.Edge.ModuleUtil;
using Microsoft.Azure.Devices.Edge.Util;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.Azure.Devices.Edge.ModuleUtil;
class Program
{

Просмотреть файл

@ -8,12 +8,11 @@ namespace SimulatedTemperatureSensor
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Azure.Devices.Client;
using Microsoft.Azure.Devices.Edge.ModuleUtil;
using Microsoft.Azure.Devices.Edge.Util;
using Microsoft.Azure.Devices.Edge.Util.Concurrency;
using Microsoft.Azure.Devices.Shared;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.Azure.Devices.Edge.ModuleUtil;
using Newtonsoft.Json;
class Program

Просмотреть файл

@ -8,11 +8,11 @@ namespace TemperatureFilter
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Azure.Devices.Client;
using Microsoft.Azure.Devices.Edge.ModuleUtil;
using Microsoft.Azure.Devices.Edge.Util;
using Microsoft.Azure.Devices.Shared;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.Azure.Devices.Edge.ModuleUtil;
using Newtonsoft.Json;
class Program

Просмотреть файл

@ -6,12 +6,11 @@ namespace LoadGen
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Azure.Devices.Client;
using Microsoft.Azure.Devices.Edge.ModuleUtil;
using Microsoft.Azure.Devices.Edge.Util;
using Microsoft.Azure.Devices.Shared;
using Microsoft.Extensions.Logging;
using Microsoft.Azure.Devices.Edge.ModuleUtil;
using Newtonsoft.Json;
using ILogger = Microsoft.Extensions.Logging.ILogger;
class Program
{

Просмотреть файл

@ -52,7 +52,7 @@ namespace Microsoft.Azure.Devices.Edge.Util.Concurrency
public void Dispose()
{
if (0 == Interlocked.Exchange(ref this.disposed, 1))
if (Interlocked.Exchange(ref this.disposed, 1) == 0)
{
this.toRelease.semaphore.Release();
}

Просмотреть файл

@ -11,17 +11,17 @@ namespace Microsoft.Azure.Devices.Edge.Util.Uds
{
const AddressFamily EndPointAddressFamily = AddressFamily.Unix;
static readonly Encoding s_pathEncoding = Encoding.UTF8;
static readonly Encoding PathEncoding = Encoding.UTF8;
static readonly int s_nativePathOffset = 2; // = offsetof(struct sockaddr_un, sun_path). It's the same on Linux and OSX
static readonly int NativePathOffset = 2; // = offsetof(struct sockaddr_un, sun_path). It's the same on Linux and OSX
static readonly int s_nativePathLength = 91; // sockaddr_un.sun_path at http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_un.h.html, -1 for terminator
static readonly int NativePathLength = 91; // sockaddr_un.sun_path at http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_un.h.html, -1 for terminator
static readonly int s_nativeAddressSize = s_nativePathOffset + s_nativePathLength;
static readonly int NativeAddressSize = NativePathOffset + NativePathLength;
readonly string _path;
readonly string path;
readonly byte[] _encodedPath;
readonly byte[] encodedPath;
public UnixDomainSocketEndPoint(string path)
{
@ -30,10 +30,10 @@ namespace Microsoft.Azure.Devices.Edge.Util.Uds
throw new ArgumentNullException(nameof(path));
}
this._path = path;
this._encodedPath = s_pathEncoding.GetBytes(this._path);
this.path = path;
this.encodedPath = PathEncoding.GetBytes(this.path);
if (path.Length == 0 || this._encodedPath.Length > s_nativePathLength)
if (path.Length == 0 || this.encodedPath.Length > NativePathLength)
{
throw new ArgumentOutOfRangeException(nameof(path), path);
}
@ -47,25 +47,25 @@ namespace Microsoft.Azure.Devices.Edge.Util.Uds
}
if (socketAddress.Family != EndPointAddressFamily ||
socketAddress.Size > s_nativeAddressSize)
socketAddress.Size > NativeAddressSize)
{
throw new ArgumentOutOfRangeException(nameof(socketAddress));
}
if (socketAddress.Size > s_nativePathOffset)
if (socketAddress.Size > NativePathOffset)
{
this._encodedPath = new byte[socketAddress.Size - s_nativePathOffset];
for (int i = 0; i < this._encodedPath.Length; i++)
this.encodedPath = new byte[socketAddress.Size - NativePathOffset];
for (int i = 0; i < this.encodedPath.Length; i++)
{
this._encodedPath[i] = socketAddress[s_nativePathOffset + i];
this.encodedPath[i] = socketAddress[NativePathOffset + i];
}
this._path = s_pathEncoding.GetString(this._encodedPath, 0, this._encodedPath.Length);
this.path = PathEncoding.GetString(this.encodedPath, 0, this.encodedPath.Length);
}
else
{
this._encodedPath = Array.Empty<byte>();
this._path = string.Empty;
this.encodedPath = Array.Empty<byte>();
this.path = string.Empty;
}
}
@ -73,21 +73,21 @@ namespace Microsoft.Azure.Devices.Edge.Util.Uds
public override SocketAddress Serialize()
{
var result = new SocketAddress(AddressFamily.Unix, s_nativeAddressSize);
Debug.Assert(this._encodedPath.Length + s_nativePathOffset <= result.Size, "Expected path to fit in address");
var result = new SocketAddress(AddressFamily.Unix, NativeAddressSize);
Debug.Assert(this.encodedPath.Length + NativePathOffset <= result.Size, "Expected path to fit in address");
for (int index = 0; index < this._encodedPath.Length; index++)
for (int index = 0; index < this.encodedPath.Length; index++)
{
result[s_nativePathOffset + index] = this._encodedPath[index];
result[NativePathOffset + index] = this.encodedPath[index];
}
result[s_nativePathOffset + this._encodedPath.Length] = 0; // path must be null-terminated
result[NativePathOffset + this.encodedPath.Length] = 0; // path must be null-terminated
return result;
}
public override EndPoint Create(SocketAddress socketAddress) => new UnixDomainSocketEndPoint(socketAddress);
public override string ToString() => this._path;
public override string ToString() => this.path;
}
}

Просмотреть файл

@ -1,36 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="Azure IoT Edge StyleCop Ruleset" Description="These StyleCop rules are customized for Azure IoT Edge projects." ToolsVersion="15.0">
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
<Rule Id="SA0001" Action="None" />
<Rule Id="SA1008" Action="None" />
<Rule Id="SA1009" Action="None" />
<Rule Id="SA1009" Action="None" />
<Rule Id="SA1108" Action="None" />
<Rule Id="SA1118" Action="None" />
<Rule Id="SA1124" Action="None" />
<Rule Id="SA1129" Action="None" />
<Rule Id="SA1131" Action="None" />
<Rule Id="SA1201" Action="None" />
<Rule Id="SA1202" Action="None" />
<Rule Id="SA1204" Action="None" />
<Rule Id="SA1210" Action="None" />
<Rule Id="SA1308" Action="None" />
<Rule Id="SA1309" Action="None" />
<Rule Id="SA1310" Action="None" />
<Rule Id="SA1311" Action="None" />
<Rule Id="SA1313" Action="None" />
<Rule Id="SA1313" Action="None" />
<Rule Id="SA1118" Action="None" />
<Rule Id="SA1124" Action="None" />
<Rule Id="SA1201" Action="None" />
<Rule Id="SA1202" Action="None" />
<Rule Id="SA1204" Action="None" />
<Rule Id="SA1310" Action="None" />
<Rule Id="SA1311" Action="None" />
<Rule Id="SA1313" Action="None" />
<Rule Id="SA1400" Action="None" />
<Rule Id="SA1401" Action="None" />
<Rule Id="SA1401" Action="None" />
<Rule Id="SA1402" Action="None" />
<Rule Id="SA1405" Action="None" />
<Rule Id="SA1405" Action="None" />
<Rule Id="SA1407" Action="None" />
<Rule Id="SA1413" Action="None" />
<Rule Id="SA1503" Action="None" />
<Rule Id="SA1515" Action="None" />
<Rule Id="SA1516" Action="None" />
<Rule Id="SA1516" Action="None" />
<Rule Id="SA1600" Action="None" />
<Rule Id="SA1602" Action="None" />
<Rule Id="SA1649" Action="None" />
<Rule Id="SA1649" Action="None" />
<Rule Id="SA1652" Action="None" />
</Rules>
</RuleSet>

Просмотреть файл

@ -2,9 +2,9 @@
namespace Microsoft.Azure.Devices.Edge.Test.Common
{
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;