private static TypeDefinitionName Translate <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly>(Type type, IOutput output, IDecodeMetaData <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly> mdDecoder) { Type parent; if (mdDecoder.IsNested(type, out parent)) { TypeDefinitionName parentDef = Translate(parent, output, mdDecoder); TypeDefinitionName nested = TypeDefinitionName.FromName(0, mdDecoder.IsStruct(type), parentDef, mdDecoder.Name(type)); return(nested); } string moduleName = mdDecoder.DeclaringModuleName(type); if (moduleName == null) { // can't translate this as a type definition output.WriteLine("Can't translate type {0} as a type definition", mdDecoder.Name(type)); throw new NotImplementedException(); } Microsoft.Research.DataStructures.IIndexable <Type> formals; string[] args; if (mdDecoder.IsGeneric(type, out formals, true)) { args = TranslateTypeFormals(formals, output, mdDecoder); } else { args = new string[0]; } return(TypeDefinitionName.FromName(ShortAssemblyName.FromName(mdDecoder.DeclaringModuleName(type)), 0, mdDecoder.IsStruct(type), mdDecoder.Namespace(type), mdDecoder.Name(type), args)); }
private static void SuggestPostConditionViaPex <Local, Parameter, Method, Field, Property, Event, Type, Expression, Variable, Attribute, Assembly>(IExpressionContext <Local, Parameter, Method, Field, Type, Expression, Variable> context, int rank, string symptom, IOutput output, IDecodeMetaData <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly> mdDecoder, string post) where Type : IEquatable <Type> { #if INCLUDE_PEXINTEGRATION IFeedbackManager feedbackManager = GetFeedbackConnection(); if (feedbackManager != null) { MethodDefinitionName target = Translate(context.MethodContext.CurrentMethod, output, mdDecoder); string group = Guid.NewGuid().ToString(); var microsoftContractsAssembly = ShortAssemblyName.FromName("Microsoft.Contracts"); CodeUpdate update = CodeUpdate.InsertCheck("Ensures", target, MakePostconditionString(post), new[] { "System.Diagnostics.Contracts" }, new[] { microsoftContractsAssembly }, "Clousot"); CodeFix fix = CodeFix.FromUpdate("Clousot", symptom, group, update, rank, CodeFixImage.Message); try { feedbackManager.AddFix(fix); } catch { } } #endif }
static XunitTestFrameworkMetadata() { Assembly_XunitAssert = ShortAssemblyName.FromName("xunit.assert"); Assembly_XunitCore = ShortAssemblyName.FromName("xunit.core"); Type_Assert = MakeTypeName("Assert"); Type_AssertException = MakeTypeName("XunitException", Namespace_XunitSdk, Assembly_XunitAssert); Type_FactAttribute = MakeTypeName("FactAttribute"); Type_TheoryAttribute = MakeTypeName("TheoryAttribute"); Type_TraitAttribute = MakeTypeName("TraitAttribute"); Ctor_FactAttribute = MetadataBuilderHelper.Attributes.ConstructorName(Type_FactAttribute.Definition); Ctor_TraitAttribute = MetadataBuilderHelper.Attributes.ConstructorName(Type_TraitAttribute.Definition); Method_PexAssertInconclusive = new Lazy<Method>(() => MakePexAssertInconclusive()); MethodDefinition_AssertEqual = MakeAssertEqual(); MethodDefinition_AssertNotEqual = MakeAssertNotEqual(); MethodDefinition_AssertNotNull = MakeAssertNotNull(); MethodDefinition_AssertNull = MakeAssertNull(); MethodDefinition_AssertTrue = MakeAssertTrue(); Property_Skip = new PropertyDefinitionName(Assembly_XunitCore, -1, Type_FactAttribute.Definition, "Skip", SystemTypes.String.SerializableName).SelfInstantiation; }
static XunitTestFrameworkMetadata() { Assembly_XunitAssert = ShortAssemblyName.FromName("xunit.assert"); Assembly_XunitCore = ShortAssemblyName.FromName("xunit.core"); Type_Assert = MakeTypeName("Assert"); Type_AssertException = MakeTypeName("XunitException", Namespace_XunitSdk, Assembly_XunitAssert); Type_FactAttribute = MakeTypeName("FactAttribute"); Type_TheoryAttribute = MakeTypeName("TheoryAttribute"); Type_TraitAttribute = MakeTypeName("TraitAttribute"); Ctor_FactAttribute = MetadataBuilderHelper.Attributes.ConstructorName(Type_FactAttribute.Definition); Ctor_TraitAttribute = MetadataBuilderHelper.Attributes.ConstructorName(Type_TraitAttribute.Definition); Method_PexAssertInconclusive = new Lazy <Method>(() => MakePexAssertInconclusive()); MethodDefinition_AssertEqual = MakeAssertEqual(); MethodDefinition_AssertNotEqual = MakeAssertNotEqual(); MethodDefinition_AssertNotNull = MakeAssertNotNull(); MethodDefinition_AssertNull = MakeAssertNull(); MethodDefinition_AssertTrue = MakeAssertTrue(); Property_Skip = new PropertyDefinitionName(Assembly_XunitCore, -1, Type_FactAttribute.Definition, "Skip", SystemTypes.String.SerializableName).SelfInstantiation; }
/// <inheritdoc/> public override bool TryGetAssemblyName(out ShortAssemblyName assemblyName) { assemblyName = XunitTestFrameworkMetadata.Assembly_XunitCore; return true; }
static TypeName MakeTypeName(string name, string @namespace = null, ShortAssemblyName assembly = null) { SafeDebug.AssumeNotNullOrEmpty(name, "name"); return TypeDefinitionName.FromName(assembly ?? Assembly_XunitCore, -1, false, @namespace ?? Namespace_Xunit, name).SelfInstantiation; }
static TypeName MakeTypeName(string name, string @namespace = null, ShortAssemblyName assembly = null) { SafeDebug.AssumeNotNullOrEmpty(name, "name"); return(TypeDefinitionName.FromName(assembly ?? Assembly_XunitCore, -1, false, @namespace ?? Namespace_Xunit, name).SelfInstantiation); }
/// <inheritdoc/> public override bool TryGetAssemblyName(out ShortAssemblyName assemblyName) { assemblyName = XunitTestFrameworkMetadata.Assembly_XunitCore; return(true); }