Exemple #1
0
        //
        // When using assembly public key attributes InternalsVisibleTo key
        // was not checked, we have to do it later when we actually know what
        // our public key token is
        //
        void CheckReferencesPublicToken()
        {
            // TODO: It should check only references assemblies but there is
            // no working SRE API
            foreach (var a in Importer.Assemblies)
            {
                if (public_key != null && !a.HasStrongName)
                {
                    Report.Error(1577, "Referenced assembly `{0}' does not have a strong name",
                                 a.FullName);
                }

                if (!a.IsFriendAssemblyTo(this))
                {
                    continue;
                }

                var attr   = a.GetAssemblyVisibleToName(this);
                var atoken = attr.GetPublicKeyToken();

                if (ArrayComparer.IsEqual(GetPublicKeyToken(), atoken))
                {
                    continue;
                }

                Report.Error(281,
                             "Friend access was granted to `{0}', but the output assembly is named `{1}'. Try adding a reference to `{0}' or change the output assembly name to match it",
                             attr.FullName, FullName);
            }
        }
Exemple #2
0
        //
        // When using assembly public key attributes InternalsVisibleTo key
        // was not checked, we have to do it later when we actually know what
        // our public key token is
        //
        void CheckReferencesPublicToken()
        {
            // TODO: It should check only references assemblies but there is
            // no working SRE API
            foreach (var entry in Importer.Assemblies)
            {
                var a = entry as ImportedAssemblyDefinition;
                if (a == null)
                {
                    continue;
                }

                if (public_key != null && !a.HasStrongName)
                {
                    Report.Error(1577, "Referenced assembly `{0}' does not have a strong name",
                                 a.FullName);
                }

                var ci = a.Assembly.GetName().CultureInfo;
                if (!ci.Equals(System.Globalization.CultureInfo.InvariantCulture))
                {
                    Report.Warning(1607, 1, "Referenced assembly `{0}' has different culture setting of `{1}'",
                                   a.Name, ci.Name);
                }

                if (!a.IsFriendAssemblyTo(this))
                {
                    continue;
                }

                var attr   = a.GetAssemblyVisibleToName(this);
                var atoken = attr.GetPublicKeyToken();

                if (ArrayComparer.IsEqual(GetPublicKeyToken(), atoken))
                {
                    continue;
                }

                Report.SymbolRelatedToPreviousError(a.Location);
                Report.Error(281,
                             "Friend access was granted to `{0}', but the output assembly is named `{1}'. Try adding a reference to `{0}' or change the output assembly name to match it",
                             attr.FullName, FullName);
            }
        }