本文整理汇总了C#中TypeNode类的典型用法代码示例。如果您正苦于以下问题:C# TypeNode类的具体用法?C# TypeNode怎么用?C# TypeNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeNode类属于命名空间,在下文中一共展示了TypeNode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Check
public override ProblemCollection Check(TypeNode type)
{
Type runtimeType = type.GetRuntimeType();
if ( IsTestFixture( runtimeType ) )
{
System.Reflection.MethodInfo[] methods = runtimeType.GetMethods( BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly );
// Note that if an method with an invalid signature is marked as a setup method, then
// it will be considered as not marked and hence setupMethod will be null.
// Same applies for tearDownMethod.
System.Reflection.MethodInfo setupMethod = Reflect.GetSetUpMethod( runtimeType );
System.Reflection.MethodInfo tearDownMethod = Reflect.GetTearDownMethod( runtimeType );
System.Reflection.MethodInfo fixtureSetupMethod = Reflect.GetFixtureSetUpMethod( runtimeType );
System.Reflection.MethodInfo fixtureTearDownMethod = Reflect.GetFixtureTearDownMethod( runtimeType );
foreach( System.Reflection.MethodInfo methodInfo in methods )
{
if ( !IsTestCaseMethod( methodInfo ) &&
( methodInfo != setupMethod ) &&
( methodInfo != tearDownMethod ) &&
( methodInfo != fixtureSetupMethod ) &&
( methodInfo != fixtureTearDownMethod ) )
{
Resolution resolution = GetResolution( methodInfo.Name );
Problem problem = new Problem( resolution );
base.Problems.Add( problem );
}
}
if ( base.Problems.Count > 0 )
return base.Problems;
}
return base.Check (type);
}
开发者ID:vboctor,项目名称:FxCop4NUnit,代码行数:35,代码来源:TestFixturesPublicMethodsShouldBeMarkedRule.cs
示例2: Check
/// <summary>
/// Checks the specified type.
/// </summary>
/// <param name="type">The type.</param>
/// <returns></returns>
public override ProblemCollection Check(TypeNode type)
{
AttributeNode attribute = SemanticRulesUtilities.GetAttribute(type, ServiceContractAttribute);
if (SemanticRulesUtilities.HasAttribute<ServiceContractAttribute>(attribute))
{
List<string> duplicated = new List<string>();
foreach (Member member in type.Members)
{
if (SemanticRulesUtilities.GetAttribute(member, OperationContractAttribute) != null)
{
if (duplicated.Contains(member.Name.Name))
{
Resolution resolution = base.GetResolution(member.FullName);
Problem problem = new Problem(resolution, type.SourceContext);
base.Problems.Add(problem);
}
else
{
duplicated.Add(member.Name.Name);
}
}
}
}
return base.Problems;
}
开发者ID:Phidiax,项目名称:open-wssf-2015,代码行数:31,代码来源:DuplicatedOperations.cs
示例3: Check
public override ProblemCollection Check(TypeNode type)
{
Type runtimeType = type.GetRuntimeType();
if ( IsTestFixture( runtimeType ) )
{
PropertyInfo[] properties;
// check for instance public properties
properties = runtimeType.GetProperties( BindingFlags.Instance | BindingFlags.Public );
foreach( PropertyInfo instanceProperty in properties )
{
Resolution resolution = GetResolution( instanceProperty.DeclaringType.Name, instanceProperty.Name );
Problem problem = new Problem( resolution );
base.Problems.Add( problem );
}
// check for static public properties, whether declared in the class
// or one of its base classes.
properties = runtimeType.GetProperties( BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy );
foreach( PropertyInfo staticProperty in properties )
{
Resolution resolution = GetResolution( staticProperty.DeclaringType.Name, staticProperty.Name );
Problem problem = new Problem( resolution );
base.Problems.Add( problem );
}
}
if ( base.Problems.Count > 0 )
return base.Problems;
return base.Check (type);
}
开发者ID:BackupTheBerlios,项目名称:fxcop4nunit-svn,代码行数:32,代码来源:TestFixturesShouldNotContainPublicPropertiesRule.cs
示例4: IsTypeSafe
/// <summary>
/// Numeric, bool, DateTime, etc. types are safe from SQL/XSS injection. User-defined types composed entirely of safe types are also safe.
/// </summary>
protected bool IsTypeSafe(TypeNode t, HashSet<string> checkedTypes = null)
{
if (t == null)
return true;
if (checkedTypes == null)
checkedTypes = new HashSet<string>();
else if (checkedTypes.Contains(t.FullName)) //don't recurse infinitely into self-referencing types
return true;
checkedTypes.Add(t.FullName);
if (IsStringIsh(t) || (t.TemplateArguments != null && t.TemplateArguments.Any(a => IsStringIsh(a))))
return false;
if (t.IsPrimitiveNumeric || t is EnumNode)
return true;
if (_maybeSafeGenericTypes.Any(a => t.IsDerivedFrom(a)) && t.TemplateArguments != null && t.TemplateArguments.All(a => IsTypeSafe(a, checkedTypes)))
return true;
if (_safeTypes.Contains(t.FullName))
return true;
return t.Members.Where(w => w.Name.Name != "ToString").All(a => IsTypeSafe(a, checkedTypes));
}
开发者ID:phanhuy,项目名称:FxCop,代码行数:28,代码来源:BaseRule.cs
示例5: ProcessChildNode
void ProcessChildNode(TypeNode node, MethodReference changedInvokerMethod)
{
var childEventInvoker = FindEventInvokerMethodRef(node.TypeDefinition);
if (childEventInvoker == null)
{
if (changedInvokerMethod != null)
{
if (node.TypeDefinition.BaseType.IsGenericInstance)
{
var methodReference = MakeGeneric(node.TypeDefinition.BaseType, changedInvokerMethod);
changedInvokerMethod = methodReference;
}
}
}
else
{
changedInvokerMethod = childEventInvoker;
}
node.IsChangedInvoker = changedInvokerMethod;
foreach (var childNode in node.Nodes)
{
ProcessChildNode(childNode, changedInvokerMethod);
}
}
开发者ID:dj-pgs,项目名称:PropertyChanged,代码行数:26,代码来源:IsChangedMethodFinder.cs
示例6: Check
public override ProblemCollection Check(TypeNode type)
{
Type runtimeType = type.GetRuntimeType();
if ( IsTestFixture( runtimeType ) )
{
// if more than one setup, trigger error.
if ( GetTestSetupMethodsCount( runtimeType ) > 1 )
{
Resolution resolution = GetNamedResolution( "SetUp", type.Name.Name );
Problem problem = new Problem( resolution );
base.Problems.Add( problem );
return base.Problems;
}
// if more than one setup, trigger error.
if ( GetFixtureSetupMethodsCount( runtimeType ) > 1 )
{
Resolution resolution = GetNamedResolution( "TestFixtureSetUp", type.Name.Name );
Problem problem = new Problem( resolution );
base.Problems.Add( problem );
return base.Problems;
}
}
return base.Check (type);
}
开发者ID:vboctor,项目名称:FxCop4NUnit,代码行数:26,代码来源:TestFixturesShouldHaveSingleSetupMethodRule.cs
示例7: GetOnChangedMethods
IEnumerable<OnChangedMethod> GetOnChangedMethods(TypeNode notifyNode)
{
var methods = notifyNode.TypeDefinition.Methods;
var onChangedMethods = methods.Where(x => !x.IsStatic &&
!x.IsAbstract &&
//(IsNoArgOnChangedMethod(x) ||
//IsBeforeAfterOnChangedMethod(x)) &&
x.Name.StartsWith("On") &&
x.Name.EndsWith("Changed"));
foreach (var methodDefinition in onChangedMethods)
{
var typeDefinitions = new Stack<TypeDefinition>();
typeDefinitions.Push(notifyNode.TypeDefinition);
if (IsNoArgOnChangedMethod(methodDefinition))
{
yield return new OnChangedMethod
{
OnChangedType = OnChangedTypes.NoArg,
MethodReference = GetMethodReference(typeDefinitions, methodDefinition)
};
}
else if (IsBeforeAfterOnChangedMethod(methodDefinition))
{
yield return new OnChangedMethod
{
OnChangedType = OnChangedTypes.BeforeAfter,
MethodReference = GetMethodReference(typeDefinitions, methodDefinition)
};
}
}
}
开发者ID:visi,项目名称:PropertyChanged,代码行数:34,代码来源:OnChangedWalker.cs
示例8: TypeCache
public TypeCache (string fullName)
{
this.cache_is_valid = false;
this.have_type = false;
this.cache = default(TypeNode);
this.full_name = fullName;
}
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:TypeCache.cs
示例9: Duplicator
/// <param name="module">The module into which the duplicate IR will be grafted.</param>
/// <param name="type">The type into which the duplicate Member will be grafted. Ignored if entire type, or larger unit is duplicated.</param>
public Duplicator(Module/*!*/ module, TypeNode type) {
this.TargetModule = module;
this.TargetType = this.OriginalTargetType = type;
this.DuplicateFor = new TrivialHashtable();
this.TypesToBeDuplicated = new TrivialHashtable();
//^ base();
}
开发者ID:modulexcite,项目名称:IL2JS,代码行数:9,代码来源:Duplicator.cs
示例10: Check
public override ProblemCollection Check(TypeNode type)
{
Type runtimeType = type.GetRuntimeType();
if ( IsTestFixture( runtimeType ) && !runtimeType.IsAbstract && type.IsVisibleOutsideAssembly )
{
MemberList constructors = type.GetConstructors();
for ( int i = 0; i < constructors.Length; ++i )
{
Member constructor = constructors[i];
// only examine non-static constructors
Microsoft.Cci.InstanceInitializer instanceConstructor =
constructor as Microsoft.Cci.InstanceInitializer;
if ( instanceConstructor == null )
continue;
// trigger errors for non-default constructors.
if ( ( instanceConstructor.Parameters.Length != 0 ) &&
( !instanceConstructor.IsPrivate ) )
{
Resolution resolution = GetResolution( runtimeType.Name );
Problem problem = new Problem( resolution );
base.Problems.Add( problem );
}
}
if ( base.Problems.Count > 0 )
return base.Problems;
}
return base.Check (type);
}
开发者ID:vboctor,项目名称:FxCop4NUnit,代码行数:34,代码来源:TestFixturesShouldOnlyContainDefaultConstructorsRule.cs
示例11: ExistingTypeNodeUpdater
public ExistingTypeNodeUpdater(Lazy<IMethodAnnotations> methodAnnotations, ModuleDocumentNode modNode, MergedImportedType type) {
targetType = type.TargetType;
ownerModule = targetType.Module;
origTypeDefOptions = new TypeDefOptions(targetType);
newTypeDefOptions = type.NewTypeDefOptions;
typeNode = modNode.Context.DocumentTreeView.FindNode(targetType);
if (typeNode == null)
throw new InvalidOperationException();
nestedTypes1 = type.NewOrExistingNestedTypes.OfType<MergedImportedType>().Select(a => new ExistingTypeNodeUpdater(methodAnnotations, modNode, a)).ToArray();
nestedTypes2 = type.NewOrExistingNestedTypes.OfType<NewImportedType>().Select(a => new NestedTypeNodeCreator(modNode, typeNode, a.TargetType)).ToArray();
if (nestedTypes1.Length + nestedTypes2.Length != type.NewOrExistingNestedTypes.Count)
throw new InvalidOperationException();
fields = type.NewFields.Select(a => new FieldNodeCreator(modNode, typeNode, a)).ToArray();
var specialMethods = GetSpecialMethods(type);
methods = type.NewMethods.Where(a => !specialMethods.Contains(a)).Select(a => new MethodNodeCreator(modNode, typeNode, a)).ToArray();
events = type.NewEvents.Select(a => new EventNodeCreator(modNode, typeNode, a)).ToArray();
properties = type.NewProperties.Select(a => new PropertyNodeCreator(modNode, typeNode, a)).ToArray();
editedFields = type.EditedFields.Select(a => new EditedFieldUpdater(modNode, a.OriginalField, a.FieldDefOptions)).ToArray();
editedMethods = type.EditedMethods.Select(a => new EditedMethodUpdater(methodAnnotations, modNode, a.OriginalMethod, a.NewBody, a.MethodDefOptions)).ToArray();
editedProperties = type.EditedProperties.Select(a => new EditedPropertyUpdater(modNode, a.OriginalProperty, a.PropertyDefOptions)).ToArray();
editedEvents = type.EditedEvents.Select(a => new EditedEventUpdater(modNode, a.OriginalEvent, a.EventDefOptions)).ToArray();
deletedTypes = type.DeletedNestedTypes.Select(a => new DeletedTypeUpdater(modNode, a)).ToArray();
deletedFields = type.DeletedFields.Select(a => new DeletedFieldUpdater(modNode, a)).ToArray();
deletedMethods = type.DeletedMethods.Select(a => new DeletedMethodUpdater(modNode, a)).ToArray();
deletedProperties = type.DeletedProperties.Select(a => new DeletedPropertyUpdater(modNode, a)).ToArray();
deletedEvents = type.DeletedEvents.Select(a => new DeletedEventUpdater(modNode, a)).ToArray();
}
开发者ID:manojdjoshi,项目名称:dnSpy,代码行数:27,代码来源:ExistingTypeNodeUpdater.cs
示例12: ProcessChildNode
void ProcessChildNode(TypeNode node, EventInvokerMethod eventInvoker)
{
var childEventInvoker = FindEventInvokerMethod(node.TypeDefinition);
if (childEventInvoker == null)
{
if (node.TypeDefinition.BaseType.IsGenericInstance)
{
var methodReference = MakeGeneric(node.TypeDefinition.BaseType, eventInvoker.MethodReference);
eventInvoker = new EventInvokerMethod
{
InvokerType = eventInvoker.InvokerType,
MethodReference = methodReference,
};
}
}
else
{
eventInvoker = childEventInvoker;
}
node.EventInvoker = eventInvoker;
foreach (var childNode in node.Nodes)
{
ProcessChildNode(childNode, eventInvoker);
}
}
开发者ID:pH200,项目名称:PropertyChanging.ReactiveUI.WinRT,代码行数:27,代码来源:MethodFinder.cs
示例13: VisitTypeNode
public override TypeNode VisitTypeNode(TypeNode typeNode) {
TypeNode savedCurrentType = this.currentType;
this.currentType = typeNode;
TypeNode result = base.VisitTypeNode(typeNode);
this.currentType = savedCurrentType;
return result;
}
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:7,代码来源:Optimizer.cs
示例14: Test
public void Test()
{
var gen = new XmlResultsGenerator(null,null,null, null, null);
var muSession = new MutationTestingSession();
var mutar = new MutationTarget(new MutationVariant());
var ass = new AssemblyNode("Assembly");
muSession.MutantsGrouped.Add(ass);
var nodeNamespace = new TypeNamespaceNode(ass, "Namespace");
ass.Children.Add(nodeNamespace);
var nodeType = new TypeNode(nodeNamespace, "Type");
nodeNamespace.Children.Add(nodeType);
var nodeMethod = new MethodNode(nodeType, "Method", null, true);
nodeType.Children.Add(nodeMethod);
var nodeGroup = new MutantGroup("Gr1", nodeMethod);
nodeMethod.Children.Add(nodeGroup);
var nodeMutant = new Mutant("m1", nodeGroup, mutar);
nodeGroup.Children.Add(nodeMutant);
XDocument generateResults = gen.GenerateResults(muSession, false, false, ProgressCounter.Inactive(), CancellationToken.None).Result;
Console.WriteLine(generateResults.ToString());
//gen.
}
开发者ID:Refresh06,项目名称:visualmutator,代码行数:27,代码来源:XmlResultsGeneratorTests.cs
示例15: ProcessField
void ProcessField(TypeNode node, FieldDefinition field)
{
var name = field.Name;
if (!field.IsPublic || field.IsStatic || !char.IsUpper(name, 0))
{
return;
}
if (node.TypeDefinition.HasGenericParameters)
{
var message = string.Format("Skipped converting public field '{0}.{1}' to a property because generic types are not currently supported. You should make this a public property instead.", node.TypeDefinition.Name, field.Name);
logger.LogWarning(message);
return;
}
field.Name = string.Format("<{0}>k__BackingField", name);
field.IsPublic = false;
field.IsPrivate = true;
var get = GetGet(field, name);
node.TypeDefinition.Methods.Add(get);
var set = GetSet(field, name);
node.TypeDefinition.Methods.Add(set);
var propertyDefinition = new PropertyDefinition(name, PropertyAttributes.None, field.FieldType)
{
GetMethod = get,
SetMethod = set
};
foreach (var customAttribute in field.CustomAttributes)
{
propertyDefinition.CustomAttributes.Add(customAttribute);
}
node.TypeDefinition.Properties.Add(propertyDefinition);
ForwardedFields.Add(field, propertyDefinition);
}
开发者ID:marcuswhit,项目名称:NotifyPropertyWeaver,代码行数:34,代码来源:FieldToPropertyConverter.cs
示例16: Check
public override ProblemCollection Check(TypeNode type)
{
if (type == null) return Problems;
if (!IsPresenterImplementation(type)) return Problems;
var basePresenter = GetBasePresenterTypeNode(type);
if (basePresenter == null)
throw new InvalidOperationException("Failed to find WebFormsMvp.Presenter`1 even though we found WebFormsMvp.IPresenter.");
var baseType = type;
// We have an extra level of base type checking here so that we skip System.Object
while (baseType.BaseType != null &&
baseType.BaseType.BaseType != null)
{
baseType = baseType.BaseType;
}
if (baseType.Template != basePresenter)
{
Problems.Add(new Problem(
GetResolution(type.FullName)) {
Certainty = 100,
FixCategory = FixCategories.NonBreaking,
MessageLevel = MessageLevel.Warning
});
}
return Problems;
}
开发者ID:unochild,项目名称:webformsmvp,代码行数:30,代码来源:PresentersShouldUseProvidedBaseImplementation.cs
示例17: Check
public override ProblemCollection Check(TypeNode type)
{
Type runtimeType = type.GetRuntimeType();
if ( IsTestFixture( runtimeType ) )
{
System.Reflection.MethodInfo[] methods = runtimeType.GetMethods();
foreach( System.Reflection.MethodInfo methodInfo in methods )
{
// if method starts with "test" and is not marked as [Test],
// then an explicit [Test] should be added since NUnit will
// treat it as a test case.
if ( IsTestCaseMethod( methodInfo ) && !Reflect.HasTestAttribute( methodInfo ) )
{
Resolution resolution = GetResolution( methodInfo.Name );
Problem problem = new Problem( resolution );
base.Problems.Add( problem );
}
}
if ( base.Problems.Count > 0 )
return base.Problems;
}
return base.Check (type);
}
开发者ID:vboctor,项目名称:FxCop4NUnit,代码行数:26,代码来源:TestCasesShouldBeMarkedWithTestCaseAttributeRule.cs
示例18: Process
public void Process(TypeNode node)
{
foreach (var propertyDefinition in node.TypeDefinition.Properties)
{
Read(propertyDefinition, node);
}
}
开发者ID:marcuswhit,项目名称:NotifyPropertyWeaver,代码行数:7,代码来源:DependsOnDataAttributeReader.cs
示例19: Check
public override ProblemCollection Check(TypeNode typeNode)
{
if (typeNode.Interfaces.Any())
{
InterfaceNode foundServiceInterface = typeNode.Interfaces.First(i => i.FullName.EndsWith(".IBaseService"));
if (foundServiceInterface!=null)
{
bool foundUsage = false;
TypeNode serviceManagerTypeNode = foundServiceInterface.DeclaringModule.Types.First(t => t.FullName.EndsWith(".ServiceManager"));
if (serviceManagerTypeNode != null)
{
Member member = serviceManagerTypeNode.Members.First(t => t.FullName.EndsWith(".RegisterAllServices"));
var method = member as Method;
if (method != null)
{
foundUsage = method.Instructions.Any(opcode => opcode.Value != null && opcode.Value.ToString().Contains(typeNode.FullName + "("));
}
}
if (!foundUsage)
{
Resolution resolution = GetResolution(typeNode.FullName);
var problem = new Problem(resolution);
Problems.Add(problem);
}
}
}
return Problems;
}
开发者ID:constructor-igor,项目名称:TechSugar,代码行数:29,代码来源:ServiceShouldBeRegistered.cs
示例20: PropertyWeaver
public PropertyWeaver(ModuleWeaver moduleWeaver, PropertyData propertyData, TypeNode typeNode, TypeSystem typeSystem )
{
this.moduleWeaver = moduleWeaver;
this.propertyData = propertyData;
this.typeNode = typeNode;
this.typeSystem = typeSystem;
}
开发者ID:jbruening,项目名称:PropertyChanged,代码行数:7,代码来源:PropertyWeaver.cs
注:本文中的TypeNode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论