public void DiagnosticTypeFromAWGShouldBeType(IAWG awg, DiagnosticType type) { string expectedTypeSyntax; switch (type) { case DiagnosticType.Engineering: expectedTypeSyntax = DiagnosticTypeEngineeringSyntax; break; case DiagnosticType.Manufacturing: expectedTypeSyntax = DiagnosticTypeManufacturingSyntax; break; case DiagnosticType.ORT: expectedTypeSyntax = DiagnosticTypeORTSyntax; break; case DiagnosticType.POST: expectedTypeSyntax = DiagnosticTypePOSTSyntax; break; case DiagnosticType.RTC: expectedTypeSyntax = DiagnosticTypeRTCSyntax; break; default: // DiagnosticType.Normal: expectedTypeSyntax = DiagnosticTypeNormalSyntax; break; } const string possibleErrorMessage = "Checking the copy for the diagnostic type."; Assert.AreEqual(expectedTypeSyntax, awg.DiagnosticType, possibleErrorMessage); }
static DiagnosticMessage MakeInternal(DiagnosticType type, string errorCode, string messageData, MethodDefinition method, Instruction instruction) { var result = new DiagnosticMessage { Column = 0, Line = 0, DiagnosticType = type, File = "" }; var seq = instruction != null?CecilHelpers.FindBestSequencePointFor(method, instruction) : null; if (errorCode.Contains("ICE")) { messageData = messageData + " Seeing this error indicates a bug in the dots compiler. We'd appreciate a bug report (About->Report a Bug...). Thnx! <3"; } var errorType = type == DiagnosticType.Error ? "error" : "warning"; messageData = $"{errorType} {errorCode}: {messageData}"; if (seq != null) { result.File = seq.Document.Url; result.Column = seq.StartColumn; result.Line = seq.StartLine; #if !UNITY_DOTSRUNTIME var shortenedFilePath = seq.Document.Url.Replace($"{Environment.CurrentDirectory}{Path.DirectorySeparatorChar}", ""); result.MessageData = $"{shortenedFilePath}({seq.StartLine},{seq.StartColumn}): {messageData}"; #else result.MessageData = messageData; #endif } else { result.MessageData = messageData; } return(result); }
internal DiagnosticResult(Type serviceType, string description, DiagnosticType diagnosticType, object value) { this.ServiceType = serviceType; this.Description = description; this.DiagnosticType = diagnosticType; this.Value = value; }
/// <summary> /// Change the diag type (aka normal or post) /// </summary> /// <param name="awg"></param> /// <param name="type"></param> public void SendAsTheDiagnosticsTestModeOnAnAWG(IAWG awg, DiagnosticType type) { string typeSyntax; switch (type) { case DiagnosticType.Engineering: typeSyntax = DiagnosticTypeEngineeringSyntax; break; case DiagnosticType.Manufacturing: typeSyntax = DiagnosticTypeManufacturingSyntax; break; case DiagnosticType.ORT: typeSyntax = DiagnosticTypeORTSyntax; break; case DiagnosticType.POST: typeSyntax = DiagnosticTypePOSTSyntax; break; case DiagnosticType.RTC: typeSyntax = DiagnosticTypeRTCSyntax; break; default: // DiagnosticType.Normal: typeSyntax = DiagnosticTypeNormalSyntax; break; } awg.DiagType(typeSyntax); }
public void LogDiagnostics(string message, DiagnosticType logType = DiagnosticType.Warning) { // DiagnosticMessage can't display \n for some reason. // it just cuts it off and we don't see any stack trace. // so let's replace all line breaks so we get the stack trace. // (Unity 2021.2.0b6 apple silicon) //message = message.Replace("\n", "/"); // lets break it into several messages instead so it's easier readable string[] lines = message.Split('\n'); // if it's just one line, simply log it if (lines.Length == 1) { // tests assume exact message log. // don't include 'Weaver: ...' or similar. Add($"{message}", logType); } // for multiple lines, log each line separately with start/end indicators else { // first line with Weaver: ... first Add("----------------------------------------------", logType); foreach (string line in lines) { Add(line, logType); } Add("----------------------------------------------", logType); } }
static DiagnosticMessage MakeInternal(DiagnosticType type, string errorCode, string messageData, MethodDefinition method, Instruction instruction) { var result = new DiagnosticMessage { Column = 0, Line = 0, DiagnosticType = type, File = "" }; var seq = instruction != null?CecilHelpers.FindBestSequencePointFor(method, instruction) : null; if (errorCode.Contains("ICE")) { messageData = messageData + " Seeing this error indicates a bug in the dots compiler. We'd appreciate a bug report (About->Report a Problem). Thnx! <3"; } messageData = $"error {errorCode}: {messageData}"; if (seq != null) { result.File = seq.Document.Url; result.Column = seq.StartColumn; result.Line = seq.StartLine; result.MessageData = $"{seq.Document.Url}:({seq.StartLine},{seq.StartColumn}) {messageData}"; } else { result.MessageData = messageData; } return(result); }
private static DiagnosticMessage Make(DiagnosticType type, string errorCode, string messageData, MethodDefinition method, Instruction instruction) { var seq = method != null?Helpers.FindBestSequencePointFor(method, instruction) : null; return(Make(type, errorCode, messageData, seq)); }
private static DiagnosticMessage MakeInternal(DiagnosticType type, string errorCode, string messageData, MethodDefinition method, Instruction instruction) { var result = new DiagnosticMessage { Column = 0, Line = 0, DiagnosticType = type, File = "" }; var seq = method != null?Helpers.FindBestSequencePointFor(method, instruction) : null; messageData = $"error {errorCode}: {messageData}"; if (seq != null) { result.File = seq.Document.Url; result.Column = seq.StartColumn; result.Line = seq.StartLine; #if UNITY_EDITOR result.MessageData = $"{seq.Document.Url}({seq.StartLine},{seq.StartColumn}): {messageData}"; #else result.MessageData = messageData; #endif } else { result.MessageData = messageData; } return(result); }
private static DiagnosticMessage Make(DiagnosticType type, string errorCode, string messageData, SequencePoint seq) { var result = new DiagnosticMessage { Column = 0, Line = 0, DiagnosticType = type, File = "" }; messageData = $"error {errorCode}: {messageData}"; if (seq != null) { result.File = seq.Document.Url; result.Column = seq.StartColumn; result.Line = seq.StartLine; #if UNITY_EDITOR result.MessageData = $"{seq.Document.Url}({seq.StartLine},{seq.StartColumn}): {messageData}"; #else result.MessageData = messageData; #endif } else { result.MessageData = messageData; } return(result); }
protected override void AssertProducesInternal( Type systemType, DiagnosticType type, string[] shouldContains, bool useFailResolver = false) { var methodToAnalyze = MethodDefinitionForOnlyMethodOf(systemType); var diagnosticMessages = new List <DiagnosticMessage>(); try { foreach (var forEachDescriptionConstruction in LambdaJobDescriptionConstruction.FindIn(methodToAnalyze)) { var(_, rewriteMessages) = LambdaJobsPostProcessor.Rewrite(methodToAnalyze, forEachDescriptionConstruction); diagnosticMessages.AddRange(rewriteMessages); } } catch (FoundErrorInUserCodeException exc) { diagnosticMessages.AddRange(exc.DiagnosticMessages); } Assert.AreEqual(1, diagnosticMessages.Count); Assert.AreEqual(type, diagnosticMessages[0].DiagnosticType); foreach (var str in shouldContains) { Assert.That(diagnosticMessages[0].MessageData.Contains(str), $"Error message \"{diagnosticMessages[0].MessageData}\" does not contain \"{str}\"."); } AssertDiagnosticHasSufficientFileAndLineInfo(diagnosticMessages); }
internal static (string, string) GetErrorCodeMessageTuple(this DiagnosticType diagnosticType) { return(diagnosticType switch { DiagnosticType.MethodWithoutAttribute => DiagnosticTypesTuples.MethodWithoutAttributeErrorTuple, DiagnosticType.MethodInvalidReturnType => DiagnosticTypesTuples.MethodInvalidReturnTypeErrorTuple, _ => throw new ArgumentOutOfRangeException(nameof(diagnosticType), diagnosticType, null) });
private void SetType(DiagnosticType type) { Assertion.NotNull(type, "Tipo não informado.").Validate(); Type = type; Assertion.Equals(Type, type, "Tipo do diagnostico não foi informado corretamente.").Validate(); }
public Diagnostic(DiagnosticIdentifier identifier, string message, TextSpan span, DiagnosticType type, string file) { Identifier = identifier; Message = message; Span = span; Type = type; File = file; }
internal void AddAdditionalInformation(DiagnosticType type, string message) { if (this.additionalInformation is null) { this.additionalInformation = new Dictionary <DiagnosticType, string>(); } this.additionalInformation[type] = message ?? string.Empty; }
internal DiagnosticResult(Type serviceType, string description, DiagnosticType diagnosticType, DiagnosticSeverity severity, object value) { this.ServiceType = serviceType; this.Description = description; this.DiagnosticType = diagnosticType; this.Severity = severity; this.Value = value; }
// Token: 0x06006134 RID: 24884 RVA: 0x0014AE00 File Offset: 0x00149000 public DiagnosticCommand(DiagnosticType command, Guid orgId, Guid entry) : this(command, new Guid[] { orgId }, new Guid[] { entry }) { }
/// <summary> /// Suppressing the supplied <see cref="DiagnosticType"/> for the given registration. /// </summary> /// <param name="type">The <see cref="DiagnosticType"/>.</param> public void SuppressDiagnosticWarning(DiagnosticType type) { if (this.suppressions == null) { this.suppressions = new HashSet <DiagnosticType>(); } this.suppressions.Add(type); }
// Token: 0x06006136 RID: 24886 RVA: 0x0014AE49 File Offset: 0x00149049 public DiagnosticCommand(DiagnosticType command, ICollection <Guid> orgIds, ICollection <Guid> entries) { if (entries == null) { throw new ArgumentNullException("entries"); } this.Command = command; this.Organizations = orgIds; this.CacheEntries = entries; }
internal string GetAdditionalInformation(DiagnosticType type) { if (this.additionalInformation != null && this.additionalInformation.TryGetValue(type, out string message)) { return(message); } return(string.Empty); }
internal static DocumentationAttribute GetDocumentationAttribute(DiagnosticType value) { var members = typeof(DiagnosticType).GetMember(value.ToString()); var attributes = from member in members from attribute in member.GetCustomAttributes(typeof(DocumentationAttribute), false) select(DocumentationAttribute) attribute; return(attributes.FirstOrDefault() ?? new DocumentationAttribute(value.ToString(), string.Empty)); }
private void AddMessage(string message, SequencePoint sequencePoint, DiagnosticType diagnosticType) { Diagnostics.Add(new DiagnosticMessage { DiagnosticType = diagnosticType, File = sequencePoint?.Document.Url.Replace($"{Environment.CurrentDirectory}{Path.DirectorySeparatorChar}", ""), Line = sequencePoint?.StartLine ?? 0, Column = sequencePoint?.StartColumn ?? 0, MessageData = message }); }
void Add(string message, DiagnosticType logType) { Logs.Add(new DiagnosticMessage { // TODO add file etc. for double click opening later? DiagnosticType = logType, // doesn't have .Log File = null, Line = 0, Column = 0, MessageData = message }); }
public static void AppendCollection <TService, TImplementation>( this Container container, Lifestyle lifestyle, DiagnosticType suppression) where TImplementation : class, TService { var reg = lifestyle.CreateRegistration <TImplementation>(container); reg.SuppressDiagnosticWarning(suppression, "For testing"); container.Collection.Append(typeof(TService), reg); }
/// <summary> /// Suppressing the supplied <see cref="DiagnosticType"/> for the given registration. /// </summary> /// <param name="type">The <see cref="DiagnosticType"/>.</param> /// <param name="justification">The justification of why the warning must be suppressed.</param> /// <exception cref="ArgumentNullException">Thrown when <paramref name="justification"/> is a null /// reference.</exception> /// <exception cref="ArgumentException">Thrown when either <paramref name="justification"/> is an /// empty string or when <paramref name="type"/> is not a valid value of <see cref="DiagnosticType"/>. /// </exception> public void SuppressDiagnosticWarning(DiagnosticType type, string justification) { Requires.IsValidEnum(type, nameof(type)); Requires.IsNotNullOrEmpty(justification, nameof(justification)); if (this.suppressions is null) { this.suppressions = new HashSet <DiagnosticType>(); } this.suppressions.Add(type); }
internal DiagnosticGroup(DiagnosticType diagnosticType, Type groupType, string name, string description, IEnumerable<DiagnosticGroup> children, IEnumerable<DiagnosticResult> results) { this.DiagnosticType = diagnosticType; this.GroupType = groupType; this.Name = name; this.Description = description; this.Children = new ReadOnlyCollection<DiagnosticGroup>(children.ToList()); this.Results = new ReadOnlyCollection<DiagnosticResult>(results.ToList()); this.InitializeChildren(); this.InitializeResults(); }
internal RazorCompilerDiagnostic( DiagnosticType type, string sourceFilePath, int line, int column, string message) { Type = type; SourceFilePath = sourceFilePath; Line = line; Column = column; Message = message; }
internal DiagnosticGroup(DiagnosticType diagnosticType, Type groupType, string name, string description, IEnumerable <DiagnosticGroup> children, IEnumerable <DiagnosticResult> results) { this.DiagnosticType = diagnosticType; this.GroupType = groupType; this.Name = name; this.Description = description; this.Children = new ReadOnlyCollection <DiagnosticGroup>(children.ToList()); this.Results = new ReadOnlyCollection <DiagnosticResult>(results.ToList()); this.InitializeChildren(); this.InitializeResults(); }
internal void Set(DiagnosticType diagnosticType, string explain, ExtendedInfo info = null) { if (diagnosticType == DiagnosticType.Error) { error = true; } Write(DateTime.Now.ToString()); Write(" - "); Write(diagnosticType == DiagnosticType.Error ? "ERROR - " : "WARNING - "); WriteLine(explain); if (info != null) { WriteLine(info.ToString()); } }
protected override void AssertProducesInternal(Type systemType, DiagnosticType expectedDiagnosticType, string[] errorIdentifiers, bool useFailResolver = false) { DiagnosticMessage error = null; try { AuthoringComponentPostProcessor.CreateBufferElementDataAuthoringType(TypeDefinitionFor(systemType)); } catch (FoundErrorInUserCodeException exception) { error = exception.DiagnosticMessages.Single(); } Assert.AreEqual(expected: expectedDiagnosticType, actual: error?.DiagnosticType); Assert.IsTrue(error?.MessageData.Contains(errorIdentifiers.Single())); }
void AssertProducesInternal(Type systemType, DiagnosticType type, string[] shouldContains) { var methodToAnalyze = MethodDefinitionForOnlyMethodOf(systemType); var errors = new List <DiagnosticMessage>(); try { foreach (var forEachDescriptionConstruction in LambdaJobDescriptionConstruction.FindIn(methodToAnalyze)) { LambdaJobsPostProcessor.Rewrite(methodToAnalyze, forEachDescriptionConstruction, errors); } } catch (FoundErrorInUserCodeException exc) { errors.AddRange(exc.DiagnosticMessages); } Assert.AreEqual(type, errors[0].DiagnosticType); string diagnostic = errors.Select(dm => dm.MessageData).SeparateByComma(); foreach (var s in shouldContains) { StringAssert.Contains(s, diagnostic); } if (!diagnostic.Contains(".cs")) { Assert.Fail("Diagnostic message had no file info: " + diagnostic); } var match = Regex.Match(diagnostic, "\\.cs:?\\((?<line>.*?),(?<column>.*?)\\)"); if (!match.Success) { Assert.Fail("Diagnostic message had no line info: " + diagnostic); } var line = int.Parse(match.Groups["line"].Value); if (line > 1000) { Assert.Fail("Unreasonable line number in errormessage: " + diagnostic); } }
internal void ReportMethodDiagnostic( DiagnosticType diagnosticType, string methodName, string interfaceFullName, string issuedTypeName, ImmutableArray <Location> locations) { HasReported = true; var(code, message) = diagnosticType.GetErrorCodeMessageTuple(); _context.ReportDiagnostic(Diagnostic.Create( code, "Usage", string.Format(message, methodName, interfaceFullName, issuedTypeName), DiagnosticSeverity.Error, DiagnosticSeverity.Error, true, 0, location: locations[0] )); }
private static void Register(DiagnosticType dtype, object log, Track?track, string message, params object[] values) { #if DEBUG var file = $"{Helpers.DiagnosticHelper.PathLog}\\{DateTime.Now.ToString("yyMMdd")}_0000.log"; #else var file = $"{Helpers.DiagnosticHelper.PathLog}\\{DateTime.Now.ToString("yyMMdd_HH")}00.log"; #endif var time = DateTime.Now.ToString("HH:mm:ss"); var type = dtype.ToString() + new String(' ', 7 - dtype.ToString().Length); var trck = track; if (message is null) { message = "Sorry! No messages logged."; } var msg = Dynamic.StringFormat(message, values); var line = $"{time} {type} - {log} {trck}: {msg}"; Shell.File.Save(line, file, false, true); }
protected override void AssertProducesInternal( Type systemType, DiagnosticType expectedDiagnosticType, string[] errorIdentifiers, bool useFailResolver = false) { DiagnosticMessage error = null; try { AssemblyDefinition assemblyDefinition = AssemblyDefinition.ReadAssembly(systemType.Assembly.Location); TypeDefinition typeDefinitionToTest = assemblyDefinition.MainModule.Types.Single(t => t.Name == systemType.Name); bool _ = AuthoringComponentPostProcessor.RunTest(typeDefinitionToTest); } catch (FoundErrorInUserCodeException exception) { error = exception.DiagnosticMessages.Single(); } Assert.AreEqual(expected: expectedDiagnosticType, actual: error?.DiagnosticType); Assert.IsTrue(error?.MessageData.Contains(errorIdentifiers.Single())); }
// Output level - Low, High // Convertible - true, false // Biopower - true, false // Diagnostics - EOBD, OBD2, LOBD // SAI - true, false // Clutch start - true, false // Tank type - AWD, US, EU public bool GetPI01(out bool convertible, out bool sai, out bool highoutput, out bool biopower, out DiagnosticType diagnosticType, out bool clutchStart, out TankType tankType, out string raw) { convertible = false; sai = false; highoutput = false; biopower = false; raw = string.Empty; diagnosticType = DiagnosticType.EOBD; tankType = TankType.EU; clutchStart = false; byte[] data = RequestECUInfo(0x01); Console.WriteLine("01data: " + data[0].ToString("X2") + " " + data[1].ToString("X2")); if (data[0] == 0x00 && data[1] == 0x00) return false; if (data.Length >= 2) { // -------C biopower = BitTools.GetBit(data[0], 0); // -----C-- convertible = BitTools.GetBit(data[0], 2); // ---01--- US // ---10--- EU // ---11--- AWD switch (data[0] & 0x18) { case 0x08: tankType = TankType.US; break; case 0x10: tankType = TankType.EU; break; case 0x18: tankType = TankType.AWD; break; } // -01----- OBD2 // -10----- EOBD // -11----- LOBD switch (data[0] & 0x60) { case 0x20: diagnosticType = DiagnosticType.OBD2; break; case 0x40: diagnosticType = DiagnosticType.EOBD; break; case 0x60: diagnosticType = DiagnosticType.LOBD; break; default: diagnosticType = DiagnosticType.None; break; } // on = -----10- // off= -----01- clutchStart = !BitTools.GetBit(data[1], 1) && BitTools.GetBit(data[1], 2) ? true : false; // on = ---10--- // off= ---01--- sai = !BitTools.GetBit(data[1], 3) && BitTools.GetBit(data[1], 4) ? true : false; // high= -01----- // low = -10----- highoutput = BitTools.GetBit(data[1], 5) && !BitTools.GetBit(data[1], 6) ? true : false; for (int i = 0; i < data.Length; i++) { raw += "0x" + data[i].ToString("X2") + " "; } } return true; }
public static void SuppressDiagnosticWarning(this Registration registration, DiagnosticType type) { registration.SuppressDiagnosticWarning(type, "Some random justification that we don't care about."); }
public bool SetPI01(bool convertible, bool sai, bool highoutput, bool biopower, DiagnosticType diagnosticType, bool clutchStart, TankType tankType) { bool retval = false; byte[] data = RequestECUInfo(0x01); CANMessage msg = new CANMessage(0x7E0, 0, 7); ulong cmd = 0x0000000000013B06; // -------C data[0] = BitTools.SetBit(data[0], 0, biopower); // -----C-- data[0] = BitTools.SetBit(data[0], 2, convertible); // ---01--- US // ---10--- EU // ---11--- AWD switch (tankType) { case TankType.US: data[0] = BitTools.SetBit(data[0], 3, true); data[0] = BitTools.SetBit(data[0], 4, false); break; case TankType.EU: data[0] = BitTools.SetBit(data[0], 3, false); data[0] = BitTools.SetBit(data[0], 4, true); break; case TankType.AWD: data[0] = BitTools.SetBit(data[0], 3, true); data[0] = BitTools.SetBit(data[0], 4, true); break; } // -01----- OBD2 // -10----- EOBD // -11----- LOBD switch (diagnosticType) { case DiagnosticType.OBD2: data[0] = BitTools.SetBit(data[0], 5, true); data[0] = BitTools.SetBit(data[0], 6, false); break; case DiagnosticType.EOBD: data[0] = BitTools.SetBit(data[0], 5, false); data[0] = BitTools.SetBit(data[0], 6, true); break; case DiagnosticType.LOBD: data[0] = BitTools.SetBit(data[0], 5, true); data[0] = BitTools.SetBit(data[0], 6, true); break; case DiagnosticType.None: default: data[0] = BitTools.SetBit(data[0], 5, false); data[0] = BitTools.SetBit(data[0], 6, false); break; } // on = -----10- // off= -----01- data[1] = BitTools.SetBit(data[1], 1, !clutchStart); data[1] = BitTools.SetBit(data[1], 2, clutchStart); // on = ---10--- // off= ---01--- data[1] = BitTools.SetBit(data[1], 3, !sai); data[1] = BitTools.SetBit(data[1], 4, sai); // high= -01----- // low = -10----- data[1] = BitTools.SetBit(data[1], 5, highoutput); data[1] = BitTools.SetBit(data[1], 6, !highoutput); cmd = AddByteToCommand(cmd, data[0], 3); cmd = AddByteToCommand(cmd, data[1], 4); msg.setData(cmd); m_canListener.setupWaitMessage(0x7E8); if (!canUsbDevice.sendMessage(msg)) { CastInfoEvent("Couldn't send message", ActivityType.ConvertingFile); return false; } CANMessage ECMresponse = new CANMessage(); ECMresponse = m_canListener.waitMessage(timeoutP2ct); ulong rxdata = ECMresponse.getData(); // response should be 0000000000017B02 if (getCanData(rxdata, 1) == 0x7B && getCanData(rxdata, 2) == 0x01) { //7e0 02 27 FD 00 00 00 00 00 request sequrity access FD //7e8 04 67 FD 00 00 00 00 00 RequestSecurityAccess(0); //7e0 07 AE 16 00 00 00 00 00 //7e8 02 EE 16 00 00 00 00 00 SendDeviceControlMessage(0x16); retval = true; } else if (getCanData(rxdata, 1) == 0x7F && getCanData(rxdata, 2) == 0x3B) { CastInfoEvent("Error: " + TranslateErrorCode(getCanData(rxdata, 3)), ActivityType.ConvertingFile); } return retval; }
internal static DocumentationAttribute GetDocumentationAttribute(DiagnosticType value) { var members = typeof(DiagnosticType).Info().GetMember(value.ToString()); var attributes = from member in members from attribute in member.GetCustomAttributes(typeof(DocumentationAttribute), false) select (DocumentationAttribute)attribute; return attributes.FirstOrDefault() ?? new DocumentationAttribute(value.ToString(), string.Empty); }