当前位置: 首页>>代码示例>>C#>>正文


C# AssemblyIdentity类代码示例

本文整理汇总了C#中AssemblyIdentity的典型用法代码示例。如果您正苦于以下问题:C# AssemblyIdentity类的具体用法?C# AssemblyIdentity怎么用?C# AssemblyIdentity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AssemblyIdentity类属于命名空间,在下文中一共展示了AssemblyIdentity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AssemblyReference

 /// <summary>
 /// Allocates a reference to a .NET assembly.
 /// </summary>
 /// <param name="host">Provides a standard abstraction over the applications that host components that provide or consume objects from the metadata model.</param>
 /// <param name="assemblyIdentity">The identity of the referenced assembly.</param>
 /// <param name="isRetargetable">True if the implementation of the referenced assembly used at runtime is not expected to match the version seen at compile time.</param>
 /// <param name="containsForeignTypes">
 /// True if the referenced assembly contains types that describe objects that are neither COM objects nor objects that are managed by the CLR.
 /// Instances of such types are created and managed by another runtime and are accessed by CLR objects via some form of interoperation mechanism.
 /// </param>
 public AssemblyReference(IMetadataHost host, AssemblyIdentity assemblyIdentity, bool isRetargetable = false, bool containsForeignTypes = false)
 {
     this.host = host;
       this.assemblyIdentity = assemblyIdentity;
       this.isRetargetable = isRetargetable;
       this.containsForeignTypes = containsForeignTypes;
 }
开发者ID:rasiths,项目名称:visual-profiler,代码行数:17,代码来源:PlatformTypes.cs

示例2: FusionAssemblyNameRoundTrip

        public void FusionAssemblyNameRoundTrip()
        {
            RoundTrip(new AssemblyName("foo"));
            RoundTrip(new AssemblyName { Name = "[email protected]#$%^&*()_+={}:\"<>?[];',./" });
            RoundTrip(new AssemblyName("\\,"));
            RoundTrip(new AssemblyName("\\\""));

            RoundTrip(new AssemblyIdentity("foo").ToAssemblyName());

            // 0xffff version is not included in AssemblyName.FullName for some reason:
            var name = new AssemblyIdentity("foo", version: new Version(0xffff, 0xffff, 0xffff, 0xffff)).ToAssemblyName();
            RoundTrip(name, testFullName: false);
            var obj = FusionAssemblyIdentity.ToAssemblyNameObject(name);
            var display = FusionAssemblyIdentity.GetDisplayName(obj, FusionAssemblyIdentity.ASM_DISPLAYF.FULL);
            Assert.Equal("foo, Version=65535.65535.65535.65535, Culture=neutral, PublicKeyToken=null", display);

            RoundTrip(new AssemblyIdentity("foo", version: new Version(1, 2, 3, 4)).ToAssemblyName());
            RoundTrip(new AssemblyName("foo") { Version = new Version(1, 2, 3, 4) });

            RoundTrip(new AssemblyIdentity("foo", cultureName: CultureInfo.CurrentCulture.Name).ToAssemblyName());
            RoundTrip(new AssemblyIdentity("foo", cultureName: "").ToAssemblyName());
            RoundTrip(new AssemblyName("foo") { CultureInfo = CultureInfo.InvariantCulture });

            RoundTrip(new AssemblyIdentity("foo", version: new Version(1, 2, 3, 4), cultureName: "en-US").ToAssemblyName());
            RoundTrip(new AssemblyIdentity("foo", publicKeyOrToken: new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 }.AsImmutableOrNull()).ToAssemblyName());
            RoundTrip(new AssemblyIdentity("foo", version: new Version(1, 2, 3, 4), cultureName: CultureInfo.CurrentCulture.Name, publicKeyOrToken: new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 }.AsImmutableOrNull()).ToAssemblyName());

            RoundTrip(new AssemblyIdentity("foo", isRetargetable: true).ToAssemblyName());
            RoundTrip(new AssemblyIdentity("foo", contentType: AssemblyContentType.WindowsRuntime).ToAssemblyName());
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:30,代码来源:FusionAssemblyIdentityTests.cs

示例3: GetErrorMessageAndMissingAssemblyIdentities

        internal string GetErrorMessageAndMissingAssemblyIdentities(DiagnosticBag diagnostics, DiagnosticFormatter formatter, CultureInfo preferredUICulture, AssemblyIdentity linqLibrary, out bool useReferencedModulesOnly, out ImmutableArray<AssemblyIdentity> missingAssemblyIdentities)
        {
            var errors = diagnostics.AsEnumerable().Where(d => d.Severity == DiagnosticSeverity.Error);
            foreach (var error in errors)
            {
                missingAssemblyIdentities = this.GetMissingAssemblyIdentities(error, linqLibrary);
                if (!missingAssemblyIdentities.IsDefault)
                {
                    break;
                }
            }

            if (missingAssemblyIdentities.IsDefault)
            {
                missingAssemblyIdentities = ImmutableArray<AssemblyIdentity>.Empty;
            }

            useReferencedModulesOnly = errors.All(HasDuplicateTypesOrAssemblies);

            var firstError = errors.FirstOrDefault();
            Debug.Assert(firstError != null);

            var simpleMessage = firstError as SimpleMessageDiagnostic;
            return (simpleMessage != null) ?
                simpleMessage.GetMessage() :
                formatter.Format(firstError, preferredUICulture ?? CultureInfo.CurrentUICulture);
        }
开发者ID:GloryChou,项目名称:roslyn,代码行数:27,代码来源:EvaluationContextBase.cs

示例4: AssemblyIdentityAndLocation

            public AssemblyIdentityAndLocation(AssemblyIdentity identity, string location)
            {
                Debug.Assert(identity != null && location != null);

                this.Identity = identity;
                this.Location = location;
            }
开发者ID:robertoenbarcelona,项目名称:roslyn,代码行数:7,代码来源:InteractiveAssemblyLoader.cs

示例5: AddMissingReferenceCodeAction

 public AddMissingReferenceCodeAction(Project project, string title, ProjectReference projectReferenceToAdd, AssemblyIdentity missingAssemblyIdentity)
 {
     _project = project;
     Title = title;
     _projectReferenceToAdd = projectReferenceToAdd;
     _missingAssemblyIdentity = missingAssemblyIdentity;
 }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:7,代码来源:AddMissingReferenceCodeAction.cs

示例6: MultipleAssemblyArguments

 public void MultipleAssemblyArguments()
 {
     var identity1 = new AssemblyIdentity(GetUniqueName());
     var identity2 = new AssemblyIdentity(GetUniqueName());
     Assert.Equal(identity1, GetMissingAssemblyIdentity(ErrorCode.ERR_NoTypeDef, identity1, identity2));
     Assert.Equal(identity2, GetMissingAssemblyIdentity(ErrorCode.ERR_NoTypeDef, identity2, identity1));
 }
开发者ID:cristinamanum,项目名称:roslyn,代码行数:7,代码来源:MissingAssemblyTests.cs

示例7: LoadedAssemblyInfo

            public LoadedAssemblyInfo(Assembly assembly, AssemblyIdentity identity, string locationOpt)
            {
                Debug.Assert(assembly != null && identity != null);

                Assembly = assembly;
                Identity = identity;
                LocationOpt = locationOpt;
            }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:8,代码来源:InteractiveAssemblyLoader.cs

示例8: ExternAliasRecord

        public ExternAliasRecord(string alias, AssemblyIdentity targetIdentity)
        {
            Debug.Assert(alias != null);
            Debug.Assert(targetIdentity != null);

            Alias = alias;
            TargetAssembly = targetIdentity;
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:8,代码来源:ExternAliasRecord.cs

示例9: UnifiedAssembly

        public UnifiedAssembly(AssemblySymbol targetAssembly, AssemblyIdentity originalReference)
        {
            Debug.Assert(originalReference != null);
            Debug.Assert(targetAssembly != null);

            this.OriginalReference = originalReference;
            this.TargetAssembly = targetAssembly;
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:8,代码来源:UnifiedAssembly.cs

示例10: Equality_InvariantCulture

        public void Equality_InvariantCulture()
        {
            var neutral1 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "NEUtral", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false);
            var neutral2 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), null, RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false);
            var neutral3 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "neutral", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false);
            var invariant = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false);

            Assert.True(neutral1.Equals(invariant));
            Assert.True(neutral2.Equals(invariant));
            Assert.True(neutral3.Equals(invariant));
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:11,代码来源:AssemblyIdentityTests.cs

示例11: MetadataAsSourceGeneratedFileInfo

        public MetadataAsSourceGeneratedFileInfo(string rootPath, Project sourceProject, INamedTypeSymbol topLevelNamedType)
        {
            this.SourceProjectId = sourceProject.Id;
            this.Workspace = sourceProject.Solution.Workspace;
            this.LanguageName = sourceProject.Language;
            this.References = sourceProject.MetadataReferences.ToImmutableArray();
            this.AssemblyIdentity = topLevelNamedType.ContainingAssembly.Identity;

            var extension = sourceProject.Language == LanguageNames.CSharp ? ".cs" : ".vb";

            var directoryName = Guid.NewGuid().ToString("N");
            this.TemporaryFilePath = Path.Combine(rootPath, directoryName, topLevelNamedType.Name + extension);
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:13,代码来源:MetadataAsSourceGeneratedFileInfo.cs

示例12: MetadataDefinitionItem

 public MetadataDefinitionItem(
     ImmutableArray<string> tags,
     ImmutableArray<TaggedText> displayParts,
     bool displayIfNoReferences,
     Solution solution, ISymbol definition)
     : base(tags, displayParts,
           GetOriginationParts(definition),
           ImmutableArray<DocumentLocation>.Empty,
           displayIfNoReferences)
 {
     _workspace = solution.Workspace;
     _symbolKey = definition.GetSymbolKey();
     _symbolAssemblyIdentity = definition.ContainingAssembly?.Identity;
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:14,代码来源:DefinitionItem.SymbolDefinitionItem.cs

示例13: Equality

        public void Equality()
        {
            var id1 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKey1, hasPublicKey: true, isRetargetable: false);
            var id11 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKey1, hasPublicKey: true, isRetargetable: false);
            var id2 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false);
            var id22 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false);

            var id3 = new AssemblyIdentity("Foo!", new Version(1, 0, 0, 0), "", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false);
            var id4 = new AssemblyIdentity("Foo", new Version(1, 0, 1, 0), "", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false);
            var id5 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "en-US", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false);
            var id6 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", default(ImmutableArray<byte>), hasPublicKey: false, isRetargetable: false);
            var id7 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKeyToken1, hasPublicKey: true, isRetargetable: false);
            var id8 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKey1, hasPublicKey: true, isRetargetable: true);

            var win1 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKey1, hasPublicKey: true, isRetargetable: false, contentType: AssemblyContentType.WindowsRuntime);
            var win2 = new AssemblyIdentity("Bar", new Version(1, 0, 0, 0), "", RoPublicKey1, hasPublicKey: true, isRetargetable: false, contentType: AssemblyContentType.WindowsRuntime);
            var win3 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKey1, hasPublicKey: true, isRetargetable: false, contentType: AssemblyContentType.WindowsRuntime);

            Assert.True(id1.Equals(id1));
            Assert.True(id1.Equals(id2));
            Assert.True(id2.Equals(id1));
            Assert.True(id1.Equals(id11));
            Assert.True(id11.Equals(id1));
            Assert.True(id2.Equals(id22));
            Assert.True(id22.Equals(id2));

            Assert.False(id1.Equals(id3));
            Assert.False(id1.Equals(id4));
            Assert.False(id1.Equals(id5));
            Assert.False(id1.Equals(id6));
            Assert.False(id1.Equals(id7));
            Assert.False(id1.Equals(id8));

            Assert.Equal((object)id1, id1);
            Assert.NotNull(id1);
            Assert.False(id2.Equals((AssemblyIdentity)null));

            Assert.Equal(id1.GetHashCode(), id2.GetHashCode());

            Assert.False(win1.Equals(win2));
            Assert.False(win1.Equals(id1));
            Assert.True(win1.Equals(win3));

            Assert.Equal(win1.GetHashCode(), win3.GetHashCode());
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:45,代码来源:AssemblyIdentityTests.cs

示例14: CreateAsync

        public static async Task<CodeAction> CreateAsync(Project project, AssemblyIdentity missingAssemblyIdentity, CancellationToken cancellationToken)
        {
            var dependencyGraph = project.Solution.GetProjectDependencyGraph();

            // We want to find a project that generates this assembly, if one so exists. We therefore 
            // search all projects that our project with an error depends on. We want to do this for
            // complicated and evil scenarios like this one:
            //
            //     C -> B -> A
            //
            //     A'
            //
            // Where, for some insane reason, A and A' are two projects that both emit an assembly 
            // by the same name. So imagine we are using a type in B from C, and we are missing a 
            // reference to A.dll. Both A and A' are candidates, but we know we can throw out A'
            // since whatever type from B we are using that's causing the error, we know that type 
            // isn't referencing A'. Put another way: this code action adds a reference, but should 
            // never change the transitive closure of project references that C has.
            //
            // Doing this filtering also means we get to check less projects (good), and ensures that
            // whatever project reference we end up adding won't add a circularity (also good.)
            foreach (var candidateProjectId in dependencyGraph.GetProjectsThatThisProjectTransitivelyDependsOn(project.Id))
            {
                var candidateProject = project.Solution.GetProject(candidateProjectId);
                if (string.Equals(missingAssemblyIdentity.Name, candidateProject.AssemblyName, StringComparison.OrdinalIgnoreCase))
                {
                    // The name matches, so let's see if the full identities are equal. 
                    var compilation = await candidateProject.GetCompilationAsync(cancellationToken).ConfigureAwait(false);
                    if (missingAssemblyIdentity.Equals(compilation.Assembly.Identity))
                    {
                        // It matches, so just add a reference to this
                        return new AddMissingReferenceCodeAction(project,
                            string.Format(FeaturesResources.Add_project_reference_to_0, candidateProject.Name),
                            new ProjectReference(candidateProjectId), missingAssemblyIdentity);
                    }
                }
            }

            // No matching project, so metadata reference
            var description = string.Format(FeaturesResources.Add_reference_to_0, missingAssemblyIdentity.GetDisplayName());
            return new AddMissingReferenceCodeAction(project, description, null, missingAssemblyIdentity);
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:42,代码来源:AddMissingReferenceCodeAction.cs

示例15: ERR_NoTypeDef

        public void ERR_NoTypeDef()
        {
            var libSource = @"
public class Missing { }
";

            var source = @"
public class C
{
    public void M(Missing parameter)
    {
    }
}
";
            var libRef = CreateCompilationWithMscorlib(libSource, assemblyName: "Lib").EmitToImageReference();
            var comp = CreateCompilationWithMscorlib(source, new[] { libRef }, TestOptions.DebugDll);
            var context = CreateMethodContextWithReferences(comp, "C.M", MscorlibRef);

            var expectedError = "error CS0012: The type 'Missing' is defined in an assembly that is not referenced. You must add a reference to assembly 'Lib, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.";
            var expectedMissingAssemblyIdentity = new AssemblyIdentity("Lib");

            ResultProperties resultProperties;
            string actualError;
            ImmutableArray<AssemblyIdentity> actualMissingAssemblyIdentities;

            context.CompileExpression(
                DefaultInspectionContext.Instance,
                "parameter",
                DkmEvaluationFlags.TreatAsExpression,
                DiagnosticFormatter.Instance,
                out resultProperties,
                out actualError,
                out actualMissingAssemblyIdentities,
                EnsureEnglishUICulture.PreferredOrNull,
                testData: null);
            Assert.Equal(expectedError, actualError);
            Assert.Equal(expectedMissingAssemblyIdentity, actualMissingAssemblyIdentities.Single());
        }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:38,代码来源:MissingAssemblyTests.cs


注:本文中的AssemblyIdentity类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。