public void ExportInterfaceWithTypeOf2() { var builder = new ConventionBuilder(); builder.ForType(typeof(FooImpl)).Export((c) => c.AsContractType(typeof(IFoo))); Collections.Generic.IEnumerable <ExportAttribute> exports = builder.GetDeclaredAttributes(typeof(FooImpl), typeof(FooImpl).GetTypeInfo()).Where <Attribute>(e => e is ExportAttribute).Cast <ExportAttribute>(); Assert.Equal(1, exports.Count()); Assert.Equal(exports.First().ContractType, typeof(IFoo)); }
public void ExportInterfaceWithTypeOf1() { var builder = new ConventionBuilder(); builder.ForType <FooImpl>().Export <IFoo>(); Collections.Generic.IEnumerable <ExportAttribute> exports = builder.GetCustomAttributes(typeof(FooImpl), typeof(FooImpl).GetTypeInfo()).Where <Attribute>(e => e is ExportAttribute).Cast <ExportAttribute>(); Assert.Equal(1, exports.Count()); Assert.Equal(typeof(IFoo), exports.First().ContractType); }
private static string Normalize(string s) { Collections.Generic.IEnumerable <string> lines = s .Replace("\r\n", "\n") .Split(new[] { '\n' }) .Select(line => line.Trim()) .Where(line => line != "" && !line.StartsWith("//")); return(string.Join("\n", lines)); }
private static string Normalize(string s) { var normalizeRegex = new Regex(@"lambda_method[0-9]*"); Collections.Generic.IEnumerable <string> lines = s .Split(new[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries) .Where(line => !line.StartsWith("//")) .Select(beforeLambdaUniquifierRemoval => normalizeRegex.Replace(beforeLambdaUniquifierRemoval, "lambda_method")); return(string.Join("\n", lines)); }
private static string Normalize(string s) { Collections.Generic.IEnumerable <string> lines = s .Replace("\r\n", "\n") .Split(new[] { '\n' }) .Select(line => line.Trim()) .Where(line => line != "" && !line.StartsWith("//")); string beforeLambdaUniquifierRemoval = string.Join("\n", lines); return(Regex.Replace(beforeLambdaUniquifierRemoval, "lambda_method[0-9]*", "lambda_method")); }
private static bool TryCheckNeutralResourcesLanguageAttribute(CompilationAnalysisContext context, out AttributeData attributeData) { INamedTypeSymbol attribute = WellKnownTypes.NeutralResourcesLanguageAttribute(context.Compilation); INamedTypeSymbol @string = WellKnownTypes.String(context.Compilation); Collections.Generic.IEnumerable <AttributeData> attributes = context.Compilation.Assembly.GetAttributes().Where(d => d.AttributeClass?.Equals(attribute) == true); foreach (AttributeData data in attributes) { if (data.ConstructorArguments.Any(c => c.Type?.Equals(@string) == true && !string.IsNullOrWhiteSpace((string)c.Value))) { // found one that already does right thing. attributeData = data; return(true); } } // either we couldn't find one or existing one is wrong. attributeData = attributes.FirstOrDefault(); return(false); }
/// <summary> /// Determines whether the specified sequences are considered equal. /// </summary> /// <typeparam name="TElement">The type of the elements in both sequences.</typeparam> /// <typeparam name="TEnumerator">The type of the enumerator for the <see cref="ISequence{TElement, TEnumerator}"/>.</typeparam> /// <param name="first">The first sequence to compare.</param> /// <param name="second">The second sequence to compare.</param> /// <returns><see langword="true"/> if the objects are considered equal; otherwise, <see langword="false"/>. If both <paramref name="first"/> and <paramref name="second"/> are <see langword="null"/>, the method returns <see langword="true"/>.</returns> public static Boolean Equals <TElement, TEnumerator>(ISequence <TElement, TEnumerator>?first, Collections.Generic.IEnumerable <TElement>?second) where TEnumerator : notnull, ICount, ICurrent <TElement>, IMoveNext, IReset { if (first is null && second is null) { return(true); } if (first is null || second is null) { return(false); } TEnumerator fst = first.GetEnumerator(); using Collections.Generic.IEnumerator <TElement> snd = second.GetEnumerator(); while (fst.MoveNext() && snd.MoveNext()) { if (!Equals(fst.Current, snd.Current)) { return(false); } } if (fst.MoveNext() || snd.MoveNext()) { return(false); } // If either of the enumerators can still be moved the sequences are different lengths return(true); }
/// <summary> /// Applies the transformations. /// </summary> /// <returns>The bundle response.</returns> public override BundleResponse ApplyTransforms(BundleContext context, string bundleContent, Collections.Generic.IEnumerable <BundleFile> bundleFiles) { const string pragma = "/** @jsx React.DOM */"; if (!bundleContent.TrimStart().StartsWith(pragma)) { bundleContent = pragma + bundleContent; } return(base.ApplyTransforms(context, bundleContent, bundleFiles)); }